Community
cancel
Showing results for 
Search instead for 
Did you mean: 
carlos_c_6
Beginner
41 Views

Capture Depth Points

Hi Guys.

I tried to get 3D depth points, but I do not know if this correct.

below, the code:

 

for (int i = 0; i < MAX_FRAMES; i++) {
			if(mPXC.AcquireFrame(true) == pxcmStatus.PXCM_STATUS_NO_ERROR){
				PXCMCapture.Sample sample = mPXC.QuerySample();
				if (sample.depth != null) {
					
					PXCMImage.ImageData cData = new PXCMImage.ImageData();
					
					sample.depth.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_DEPTH, cData);
					mDepthBuffer = cData.ToShortArray(0, mDepthBuffer);
					
					int gridSize = 3;
					
					// populate mDepthPoints
					int cId = 0;
					for (int dy = 0; dy < height; ++dy) {
						for (int dx = 0; dx < width; ++dx) {
							PXCMPoint3DF32 cPoint = new PXCMPoint3DF32();
							cPoint.x = dx;
							cPoint.y = dy;
							cPoint.z = (float) mDepthBuffer[cId];
							mDepthPoints[cId] = cPoint;
							++cId;
						}
					}
					
					sample.depth.ReleaseAccess(cData);
				}
			}
			mPXC.ReleaseFrame();
		}

 

I wonder if there examples in Java or C sharp to show how I can capture the 3D points of depth using the camera realsense

0 Kudos
1 Reply
jb455
Valued Contributor II
41 Views

That looks about right, if you only need the depths for depth image coordinates.If you want camera coordinates (where x & y are distances from the centre in mm rather than pixel coordinates) you can use QueryVertices (search the docs or the forum for info on how to use it), and if you want to map the depths to the colour image you can use CreateDepthImageMappedToColor.

Reply