From 5248efe69ff116e7b58e722c2bea6c96280393ac Mon Sep 17 00:00:00 2001 From: asahtik Date: Mon, 4 Mar 2024 20:33:51 +0100 Subject: [PATCH 1/3] Fixed windows build --- src/pipeline/datatype/PointCloudDataBindings.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pipeline/datatype/PointCloudDataBindings.cpp b/src/pipeline/datatype/PointCloudDataBindings.cpp index 560e219e0..7cf99053d 100644 --- a/src/pipeline/datatype/PointCloudDataBindings.cpp +++ b/src/pipeline/datatype/PointCloudDataBindings.cpp @@ -55,8 +55,9 @@ void bind_pointclouddata(pybind11::module& m, void* pCallstack){ .def("getPoints", [](py::object &obj){ // creates numpy array (zero-copy) which holds correct information such as shape, ... dai::PointCloudData& data = obj.cast(); - py::array_t arr({data.getPoints().size(), 3UL}); + py::array_t arr({(unsigned long)(data.getData().size() / sizeof(float)), 3UL}); auto ra = arr.mutable_unchecked(); + #pragma clang for (int i = 0; i < data.getPoints().size(); i++) { ra(i, 0) = data.getPoints()[i].x; ra(i, 1) = -data.getPoints()[i].y; From 3dcae95c357d321386cf38e303e859ac7d8ece9f Mon Sep 17 00:00:00 2001 From: asahtik Date: Mon, 4 Mar 2024 20:43:59 +0100 Subject: [PATCH 2/3] Optimized getPoints --- src/pipeline/datatype/PointCloudDataBindings.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pipeline/datatype/PointCloudDataBindings.cpp b/src/pipeline/datatype/PointCloudDataBindings.cpp index 7cf99053d..a1d98341f 100644 --- a/src/pipeline/datatype/PointCloudDataBindings.cpp +++ b/src/pipeline/datatype/PointCloudDataBindings.cpp @@ -55,13 +55,13 @@ void bind_pointclouddata(pybind11::module& m, void* pCallstack){ .def("getPoints", [](py::object &obj){ // creates numpy array (zero-copy) which holds correct information such as shape, ... dai::PointCloudData& data = obj.cast(); - py::array_t arr({(unsigned long)(data.getData().size() / sizeof(float)), 3UL}); + py::array_t arr({(unsigned long)(data.getData().size() / sizeof(Point3f)), 3UL}); + Point3f* points = (Point3f*)data.getData().data(); auto ra = arr.mutable_unchecked(); - #pragma clang - for (int i = 0; i < data.getPoints().size(); i++) { - ra(i, 0) = data.getPoints()[i].x; - ra(i, 1) = -data.getPoints()[i].y; - ra(i, 2) = data.getPoints()[i].z; + for (int i = 0; i < data.getData().size() / sizeof(Point3f); i++) { + ra(i, 0) = points[i].x; + ra(i, 1) = -points[i].y; + ra(i, 2) = points[i].z; } return arr; }) From 42c3a2dae74d24eb92f6090513e2e37f120e6757 Mon Sep 17 00:00:00 2001 From: asahtik Date: Mon, 4 Mar 2024 20:49:43 +0100 Subject: [PATCH 3/3] Minor fixes --- src/pipeline/datatype/PointCloudDataBindings.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pipeline/datatype/PointCloudDataBindings.cpp b/src/pipeline/datatype/PointCloudDataBindings.cpp index a1d98341f..d2e9299b7 100644 --- a/src/pipeline/datatype/PointCloudDataBindings.cpp +++ b/src/pipeline/datatype/PointCloudDataBindings.cpp @@ -55,10 +55,11 @@ void bind_pointclouddata(pybind11::module& m, void* pCallstack){ .def("getPoints", [](py::object &obj){ // creates numpy array (zero-copy) which holds correct information such as shape, ... dai::PointCloudData& data = obj.cast(); - py::array_t arr({(unsigned long)(data.getData().size() / sizeof(Point3f)), 3UL}); Point3f* points = (Point3f*)data.getData().data(); + unsigned long size = data.getData().size() / sizeof(Point3f); + py::array_t arr({size, 3UL}); auto ra = arr.mutable_unchecked(); - for (int i = 0; i < data.getData().size() / sizeof(Point3f); i++) { + for (int i = 0; i < size; i++) { ra(i, 0) = points[i].x; ra(i, 1) = -points[i].y; ra(i, 2) = points[i].z;