Pointcloud data of L515
I'm working on a project, and now I need to process the depth and pointcloud data of L515.
First I'm trying to get the data, but the result is not what I want
here is my code and results
rs2::pointcloud pc;
rs2::points points;
auto depth = frames.get_depth_frame();
points = pc.calculate(depth);
printf("%p || %p\n", &points, &depth);
What I want is the numeric data like a 2Darray which index number is the position and array value is the depth data. But the result is two string which not even change
Can someone tell me what to do to get my data.
-
Hi Albert,
You are printing out the pointer address.
Here is an example for point cloud vertices.
auto vertices = points.get_vertices();
for (int i = 0; i < points.size(); i++) {
rs2::vertex vertex = vertices[i];
if (vertex.z) {
std::cout << vertex.x << " " << vertex.y << " " << vertex.z << " " << std::endl;
}
}For depth you can use something like
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++)
{
auto dist = depth.get_distance(x, y);
std::cout << (x + 1) << "," << (y + 1) << "," << dist << std::endl;
}
}Hope this helps.
Regards,
Rizal
-
Hi Rizal, thanks for your answer. It really helps a lot.
But now I have a little problem, I use C++ to get the x&y&dist data, and the height(y) and width(x) of frame is 480 and 640.
If I need to save it into a 2Darray and doing my calculate, it will cost a lot of time. Is there a solution about this problem?
-
Hi Albert,
You could try using unit transform to speed up extracting the distance.
You could use the following template as a guide.
... rs2::units_transform ut; rs2::pipeline pipe; pipe.start(); while (...) { rs2::frameset data = pipe.wait_for_frames(); if (auto depth_raw_frame = data.get_depth_frame()) { auto depth_metric_frame = ut.process(depth_raw_frame); // Add your code here } }
Regards,
Rizal
Please sign in to leave a comment.
Comments
3 comments