Items with no label
3335 Discussions

Question about the point cloud acquired from the 'pc.calculate' in pyrealsense2

DDD
New Contributor I
1,453 Views

I used the the code from the python wrapper to get point cloud:

depth = frames.get_depth_frame()

color = frames.get_color_frame()

if not depth or not color:

continue

pc.map_to(color)

points = pc.calculate(depth)

Then I transform the vertex to ndarray:

vtx = np.asarray(points.get_vertices())

vtx_list=vtx.tolist()

vtx=np.array(vtx_list, 'float')

And I try to plot the vertex as scatter points:

fig = pyplot.figure()

ax = Axes3D(fig)

ax.scatter(vtx[:,0], vtx[:,1], vtx[:,2])

pyplot.show()

I get following result:

The graph does not look like it is supposed to be (It should not be just a few straight lines). Anyone knows what I am missing? Thanks MartyG

0 Kudos
1 Solution
DDD
New Contributor I
452 Views

Update:

I just found the problem is because of scaling, since the viewer will scale the point cloud according to the XYZ values. I deleted the outliers (i.e. threshold XYZ at 10), and I finally saw my expected result.

View solution in original post

0 Kudos
4 Replies
MartyG
Honored Contributor III
452 Views

I'm not sure, but I recall a recent case where a point cloud generated in Python was missing data points because their depth was registering as invalid NaN values. I found that someone had written scripting that includes the coordinates of those points in the cloud by making all NaN values have a depth value of '0'.

Once the user had integrated the NaN fix into their application, they kindly posted their script so others could benefit from it.

0 Kudos
DDD
New Contributor I
452 Views

I checked the depth frame data. There are around 197371 zeros values out of 640*480=307200, which is weird.

I just checked the color-depth alignment example, it also has lots of zeros values. Seems like the depth frame is fine, and the problem is from the 'pc.map_to' or 'pc.calculate'

0 Kudos
DDD
New Contributor I
453 Views

Update:

I just found the problem is because of scaling, since the viewer will scale the point cloud according to the XYZ values. I deleted the outliers (i.e. threshold XYZ at 10), and I finally saw my expected result.

0 Kudos
MartyG
Honored Contributor III
452 Views

Awesome news - thanks for the update!

0 Kudos
Reply