@@ -50,20 +50,33 @@ void init_keypoint_detection(nb::module_& m) {
5050
5151 return self.inferBatch (input_mats);
5252 })
53- .def (" postprocess" ,
54- [](KeypointDetectionModel& self, InferenceResult& infResult) {
55- return self.postprocess (infResult);
56- })
5753 .def_prop_ro_static (" __model__" , [](nb::object) {
5854 return KeypointDetectionModel::ModelType;
5955 });
6056
6157 nb::class_<KeypointDetectionResult, ResultBase>(m, " KeypointDetectionResult" )
6258 .def (nb::init<int64_t , std::shared_ptr<MetaData>>(), nb::arg (" frameId" ) = -1 , nb::arg (" metaData" ) = nullptr )
63- .def_ro (" poses" , &KeypointDetectionResult::poses);
64-
65- nb::class_<DetectedKeypoints>(m, " DetectedKeypoints" )
66- .def (nb::init<>())
67- .def_ro (" keypoints" , &DetectedKeypoints::keypoints)
68- .def_ro (" scores" , &DetectedKeypoints::scores);
59+ .def_prop_ro (" keypoints" , [](const KeypointDetectionResult& result) {
60+ if (!result.poses .empty ()) {
61+ std::vector<size_t > shape = {result.poses [0 ].keypoints .size (), 2 };
62+ return nb::ndarray<float , nb::numpy, nb::c_contig>(
63+ const_cast <void *>(static_cast <const void *>(result.poses [0 ].keypoints .data ())),
64+ shape.size (),
65+ shape.data ());
66+ }
67+ return nb::ndarray<float , nb::numpy, nb::c_contig>();
68+ },
69+ nb::rv_policy::reference_internal)
70+ .def_prop_ro (" scores" , [](const KeypointDetectionResult& result) {
71+ if (!result.poses .empty ()) {
72+ std::vector<size_t > shape = {result.poses [0 ].scores .size ()};
73+ return nb::ndarray<float , nb::numpy, nb::c_contig>(
74+ const_cast <void *>(static_cast <const void *>(result.poses [0 ].scores .data ())),
75+ shape.size (),
76+ shape.data ());
77+ }
78+ return nb::ndarray<float , nb::numpy, nb::c_contig>();
79+ },
80+ nb::rv_policy::reference_internal
81+ );
6982}
0 commit comments