| 13 | namespace py = pybind11; |
| 14 | |
| 15 | void BindFeatureTypes(py::module& m) { |
| 16 | py::enum_<FeatureExtractorType>(m, "FeatureExtractorType") |
| 17 | .value("UNDEFINED", FeatureExtractorType::UNDEFINED) |
| 18 | .value("SIFT", FeatureExtractorType::SIFT) |
| 19 | .value("ALIKED_N16ROT", FeatureExtractorType::ALIKED_N16ROT) |
| 20 | .value("ALIKED_N32", FeatureExtractorType::ALIKED_N32); |
| 21 | |
| 22 | // Define both classes first without cross-referencing methods. |
| 23 | auto PyFeatureDescriptors = |
| 24 | py::classh<FeatureDescriptors>(m, "FeatureDescriptors") |
| 25 | .def(py::init<>()) |
| 26 | .def(py::init<FeatureExtractorType, FeatureDescriptorsData>(), |
| 27 | "type"_a, |
| 28 | "data"_a) |
| 29 | .def_readwrite("type", &FeatureDescriptors::type) |
| 30 | .def_readwrite("data", &FeatureDescriptors::data); |
| 31 | auto PyFeatureDescriptorsFloat = |
| 32 | py::classh<FeatureDescriptorsFloat>(m, "FeatureDescriptorsFloat") |
| 33 | .def(py::init<>()) |
| 34 | .def(py::init<FeatureExtractorType, FeatureDescriptorsFloatData>(), |
| 35 | "type"_a, |
| 36 | "data"_a) |
| 37 | .def_readwrite("type", &FeatureDescriptorsFloat::type) |
| 38 | .def_readwrite("data", &FeatureDescriptorsFloat::data); |
| 39 | |
| 40 | // Add cross-referencing methods after both classes are defined. |
| 41 | PyFeatureDescriptors |
| 42 | .def_static("from_float", |
| 43 | &FeatureDescriptors::FromFloat, |
| 44 | "float_desc"_a, |
| 45 | "Create from float descriptors by reinterpreting float32 " |
| 46 | "data as uint8 bytes.") |
| 47 | .def("to_float", |
| 48 | &FeatureDescriptors::ToFloat, |
| 49 | "Convert to float descriptors by reinterpreting uint8 data as " |
| 50 | "float32."); |
| 51 | PyFeatureDescriptorsFloat |
| 52 | .def_static("from_bytes", |
| 53 | &FeatureDescriptorsFloat::FromBytes, |
| 54 | "byte_desc"_a, |
| 55 | "Create from byte descriptors by reinterpreting uint8 " |
| 56 | "data as float32.") |
| 57 | .def("to_bytes", |
| 58 | &FeatureDescriptorsFloat::ToBytes, |
| 59 | "Convert to byte descriptors by reinterpreting float32 data as " |
| 60 | "uint8."); |
| 61 | |
| 62 | MakeDataclass(PyFeatureDescriptors); |
| 63 | MakeDataclass(PyFeatureDescriptorsFloat); |
| 64 | |
| 65 | auto PyFeatureKeypoint = |
| 66 | py::classh<FeatureKeypoint>(m, "FeatureKeypoint") |
| 67 | .def(py::init<>()) |
| 68 | .def_readwrite("x", &FeatureKeypoint::x) |
| 69 | .def_readwrite("y", &FeatureKeypoint::y) |
| 70 | .def_readwrite("a11", &FeatureKeypoint::a11) |
| 71 | .def_readwrite("a12", &FeatureKeypoint::a12) |
| 72 | .def_readwrite("a21", &FeatureKeypoint::a21) |
no test coverage detected