@@ -117,6 +117,39 @@ void bind_pointclouddata(pybind11::module& m, void* pCallstack) {
117117 .def (" getTimestamp" , &PointCloudData::Buffer::getTimestamp, DOC (dai, Buffer, getTimestamp))
118118 .def (" getTimestampDevice" , &PointCloudData::Buffer::getTimestampDevice, DOC (dai, Buffer, getTimestampDevice))
119119 .def (" getSequenceNum" , &PointCloudData::Buffer::getSequenceNum, DOC (dai, Buffer, getSequenceNum))
120+ .def (" setPoints" , [](py::object& obj, py::array_t <float >& arr) {
121+ if (arr.ndim () != 2 || arr.shape (1 ) != 3 ) {
122+ throw std::runtime_error (" Input must be a 2D numpy array of points with the shape of (N, 3)" );
123+ }
124+ dai::PointCloudData& data = obj.cast <dai::PointCloudData&>();
125+ std::vector<Point3f> points;
126+ points.reserve (arr.shape (0 ));
127+ auto ra = arr.unchecked ();
128+ for (int i = 0 ; i < arr.shape (0 ); i++) {
129+ points.emplace_back (ra (i, 0 ), ra (i, 1 ), ra (i, 2 ));
130+ }
131+ data.setPoints (points);
132+ })
133+ .def (" setPointsRGB" , [](py::object& obj, py::array_t <float >& points, py::array_t <uint8_t >& colors) {
134+ if (points.ndim () != 2 || points.shape (1 ) != 3 ) {
135+ throw std::runtime_error (" Points input must be a 2D numpy array of points with the shape of (N, 3)" );
136+ }
137+ if (colors.ndim () != 2 || colors.shape (1 ) != 4 ) {
138+ throw std::runtime_error (" Colors input must be a 2D numpy array of colors with the shape of (N, 4)" );
139+ }
140+ if (points.shape (0 ) != colors.shape (0 )) {
141+ throw std::runtime_error (" Points and Colors must have the same number of rows" );
142+ }
143+ dai::PointCloudData& data = obj.cast <dai::PointCloudData&>();
144+ std::vector<Point3fRGBA> pointsRGBA;
145+ pointsRGBA.reserve (points.shape (0 ));
146+ auto ra1 = points.unchecked ();
147+ auto ra2 = colors.unchecked ();
148+ for (int i = 0 ; i < points.shape (0 ); i++) {
149+ pointsRGBA.emplace_back (ra1 (i, 0 ), ra1 (i, 1 ), ra1 (i, 2 ), ra2 (i, 0 ), ra2 (i, 1 ), ra2 (i, 2 ), ra2 (i, 3 ));
150+ }
151+ data.setPointsRGB (pointsRGBA);
152+ })
120153 .def (" setWidth" , &PointCloudData::setWidth, DOC (dai, PointCloudData, setWidth))
121154 .def (" setHeight" , &PointCloudData::setHeight, DOC (dai, PointCloudData, setHeight))
122155 .def (" setSize" ,
0 commit comments