Software Archive
Read-only legacy content

How can I get distance?

Shoichi_I_
Beginner
463 Views

Hi,

I want to use distance(z position), but I dont know how to get distance with x, y, position.

Could you tell me, how to get ?

regards,

shoichi

0 Kudos
3 Replies
samontab
Valued Contributor II
463 Views

Hi shoichi,

You can use the depth channel to get the XYZ coordinates of each point. You can then just use the Z component or get the norm of that vector to get the distance from the center of the camera to that point in space, depending on what you need.

To get the XYZ coordinates in mm, you can just use QueryVertices from pxcprojection with your depth image:

/** 
    @brief Retrieve the vertices for the specific depth image. The vertices is a PXCPoint3DF32 array of depth 
    size width*height. The world coordiantes units are in mm.
    @param[in]  depth        The depth image instance.
    @param[out] vertices     The 3D vertices in World coordinates, to be returned.
    @return PXC_STATUS_NO_ERROR Successful execution.
*/ 
virtual pxcStatus PXCAPI QueryVertices(PXCImage *depth, PXCPoint3DF32 *vertices)=0;

 

0 Kudos
Thoriq_S_
Beginner
463 Views

i think globalPosition has x, y, and z coordinate

0 Kudos
Adi_P_
Beginner
463 Views

Thanks :)

 

samontab wrote:

Hi shoichi,

You can use the depth channel to get the XYZ coordinates of each point. You can then just use the Z component or get the norm of that vector to get the distance from the center of the camera to that point in space, depending on what you need.

To get the XYZ coordinates in mm, you can just use QueryVertices from pxcprojection with your depth image:

/** 
    @brief Retrieve the vertices for the specific depth image. The vertices is a PXCPoint3DF32 array of depth 
    size width*height. The world coordiantes units are in mm.
    @param[in]  depth        The depth image instance.
    @param[out] vertices     The 3D vertices in World coordinates, to be returned.
    @return PXC_STATUS_NO_ERROR Successful execution.
*/ 
virtual pxcStatus PXCAPI QueryVertices(PXCImage *depth, PXCPoint3DF32 *vertices)=0;

 

0 Kudos
Reply