| 94 | } // namespace |
| 95 | |
| 96 | void BindVisualIndex(py::module& m) { |
| 97 | auto PyImageScore = py::classh<ImageScore>(m, "ImageScore") |
| 98 | .def(py::init<>()) |
| 99 | .def_readonly("image_id", &ImageScore::image_id) |
| 100 | .def_readonly("score", &ImageScore::score); |
| 101 | MakeDataclass(PyImageScore); |
| 102 | |
| 103 | py::classh<VisualIndex, PyVisualIndexImpl> PyVisualIndex(m, "VisualIndex"); |
| 104 | |
| 105 | auto PyIndexOptions = |
| 106 | py::classh<VisualIndex::IndexOptions>(PyVisualIndex, "IndexOptions") |
| 107 | .def(py::init<>()) |
| 108 | .def_readwrite("num_neighbors", |
| 109 | &VisualIndex::IndexOptions::num_neighbors) |
| 110 | .def_readwrite("num_checks", &VisualIndex::IndexOptions::num_checks) |
| 111 | .def_readwrite("num_threads", |
| 112 | &VisualIndex::IndexOptions::num_threads); |
| 113 | MakeDataclass(PyIndexOptions); |
| 114 | |
| 115 | auto PyQueryOptions = |
| 116 | py::classh<VisualIndex::QueryOptions>(PyVisualIndex, "QueryOptions") |
| 117 | .def(py::init<>()) |
| 118 | .def_readwrite("max_num_images", |
| 119 | &VisualIndex::QueryOptions::max_num_images) |
| 120 | .def_readwrite("num_neighbors", |
| 121 | &VisualIndex::QueryOptions::num_neighbors) |
| 122 | .def_readwrite("num_checks", &VisualIndex::QueryOptions::num_checks) |
| 123 | .def_readwrite("num_threads", &VisualIndex::QueryOptions::num_threads) |
| 124 | .def_readwrite( |
| 125 | "num_images_after_verification", |
| 126 | &VisualIndex::QueryOptions::num_images_after_verification); |
| 127 | MakeDataclass(PyQueryOptions); |
| 128 | |
| 129 | auto PyBuildOptions = |
| 130 | py::classh<VisualIndex::BuildOptions>(PyVisualIndex, "BuildOptions") |
| 131 | .def(py::init<>()) |
| 132 | .def_readwrite("num_visual_words", |
| 133 | &VisualIndex::BuildOptions::num_visual_words) |
| 134 | .def_readwrite("num_iterations", |
| 135 | &VisualIndex::BuildOptions::num_iterations) |
| 136 | .def_readwrite("num_rounds", &VisualIndex::BuildOptions::num_rounds) |
| 137 | .def_readwrite("num_checks", &VisualIndex::BuildOptions::num_checks) |
| 138 | .def_readwrite("num_threads", |
| 139 | &VisualIndex::BuildOptions::num_threads); |
| 140 | MakeDataclass(PyBuildOptions); |
| 141 | |
| 142 | PyVisualIndex.def(py::init<>()) |
| 143 | .def_static("create", &VisualIndex::Create) |
| 144 | .def("add", |
| 145 | static_cast<void (VisualIndex::*)( |
| 146 | const typename VisualIndex::IndexOptions&, |
| 147 | int, |
| 148 | const FeatureKeypoints&, |
| 149 | const FeatureDescriptorsFloat&)>(&VisualIndex::Add), |
| 150 | py::call_guard<py::gil_scoped_release>()) |
| 151 | .def("is_image_indexed", &VisualIndex::IsImageIndexed) |
| 152 | .def("num_visual_words", &VisualIndex::NumVisualWords) |
| 153 | .def("num_images", &VisualIndex::NumImages) |
no test coverage detected