## Extract Coordinates From Depth Camera

Typically: "How do I... ", "How can I... " questions
davicarnauba84
Posts: 9
Joined: 09 Jan 2018, 17:14

### Extract Coordinates From Depth Camera

Hello,

How can I extract the coordinates of a single line of the image captured by depth camera. Also, how can I retrieve these coordinates using Java remoteApi?

Bests.

Zhuang
Posts: 28
Joined: 02 Aug 2017, 14:43

### Re: Extract Coordinates From Depth Camera

Hi,
viewtopic.php?f=9&t=7128&p=28171&hilit=zhuang#p28171

davicarnauba84
Posts: 9
Joined: 09 Jan 2018, 17:14

### Re: Extract Coordinates From Depth Camera

Hello,

I'm trying to extract the coordinates manually from depth image.
• So, first I'm calculating the angle of a pixel relative to the robot using

Code: Select all

angle = ((double)posx/(viewWidth-1))*fov - fov/2
where posx is the position of the pixel in range of 0 to viewWidth-1 and fov is the field of view of the depth camera.
• The relative distance between the pixel and the camera I'm calculating using:

Code: Select all

distance = (farClippingPlane - nearClippingPlane) * depth + nearClippingPlane
distanceFromCamera = Math.abs(distance/Math.sin(Math.toRadians(angle)))
where depth is the intensity - a value between 0 and 1 - of the pixel given by the camera.
• and finally the relative position of a pixel I'm calculating using:

Code: Select all

distanceFromCamera*Math.cos(Math.toRadians(angle)),
distanceFromCamera*Math.sin(Math.toRadians(angle )));
It works but sometimes it gives some noise specially when the robot is running.

So, Is there something that I'm doing wrong?