Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use convert_depth_pixel_to_metric_coordinate? #8270

Closed
monacv opened this issue Jan 29, 2021 · 3 comments
Closed

How to use convert_depth_pixel_to_metric_coordinate? #8270

monacv opened this issue Jan 29, 2021 · 3 comments

Comments

@monacv
Copy link

monacv commented Jan 29, 2021

I have a keypoint that has x and y and I want to convert this x and y into metric value as well as its z.

I want to know how I could exactly use the convert_depth_pixel_to_metric_coordinate method given these inputs:

keypoint_x  # x value of a keypoint
keypoint_y  # y value of a keypoint

and
depth_frame where its type and shape are:

<class 'numpy.ndarray'>
(720, 1280)

My goal is to get as output the x, y, and z in metric coordinates.

Please note I only consider the keypoint_x and keypoint_y that are inside the image.

essentially I am not sure how to get
x, y, z = convert_depth_pixel_to_metric_coordinate(depth_frame[i][j], keypoint_x, keypoint_y, intrinsic)

I want to know how I find the pixel i and j that refers to this keypoint? Perhaps this is supposed to be very easy but I am trying to wrap my head in the web and can't find much of such example usage.

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jan 29, 2021

Hi @monacv There is a documentation page about the convert_depth_pixel_to_metric_coordinate function at the link below if you have not seen it already.

http://docs.ros.org/en/kinetic/api/librealsense2/html/namespacehelper__functions.html#a62de489bd3774e8f44fbbffdc406269f

Depth is described as "The depth value of the image point".

The way that I interpret the structure of the function, as described in this link, is that it is requesting the XYZ coordinates of the pixel, except that the function orders it as ZXY (depth coordinate Z, pixel X value, pixel Y value).

image

The problem therefore becomes how to convert a 2D xy pixel coordinate into a 3D XYZ world coordinate. Typically, this may be done through using rs2_deproject_pixel_to_point

The output of convert_depth_pixel_to_metric_coordinate should be the x, y and z value in meters.


It seems as though this may be an over-complicated method of getting the depth value of a specific pixel and that you could instead use i and j to get the depth value of a specific pixel using the method in the link below:

#2200 (comment)

@MartyG-RealSense
Copy link
Collaborator

Hi @monacv Do you require further assistance with this case, please? Thanks!

@MartyG-RealSense
Copy link
Collaborator

Case closed due to no further comments received.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants