Skip to content

A question about getting the 3D coordinates in world space coordinates system according to a pv image point #164

@Tolerm

Description

@Tolerm

Hello guys! I want to get the 3D coordinates of a real world object with the HoloLens2 cameras, but disappointed, the result is far from the true value. And my method is:

  1. get the (u,v) coordinates of the object center in PV Camera image space through object detection
  2. transform the (u,v) to (U,V,W,1) in Unity world coordinate system

(1) transform the (u,v) to (X,Y,Z) which Z=1 through PV Camera UnprojectAtUnitDepth() method
(2) transform the (X,Y,-Z,1) to homogeneous coordinates (U,V,W,1) in Unity world coordinate system by multiplying the extrinsics, and the extrinsics got from pv_frame.CoordinateSystem().TryGetTransformTo(m_worldCoordSystem) method , and the m_worldCoordSystem is set to Unity Coordinate System

  1. transform the (U,V,W,1) to (u,v) in Depth Camera image coordinates and the Depth Camera runs on the LongThrow Mode

(1) transform the (U,V,W,1) to (X,Y,Z) in Depth Camera space by multiplying the Inv(extrinsics_depth) , extrinsics_depth refers to Unity Coordinate System
(2) transform the ( X/Z ,Y/Z, Z/Z)_depth (divide by Z to make Z = 1) to (u,v)_depth though MapCameraSpaceToImagePoint() method

  1. Until now, I have made the (u,v)_pv to (u,v)_depth, next just calculate the 3D coordinates according the (u,v)_depth

(1) get depth D of this uv point , and get the camera space coordinates through MapImagePointToCameraUnitPlane(uv_depth, xy)
(2) set an intermediate variable, tempPoint = D /1000 * 1/sqrt(x^2+y^2+1) * ( x , y , z =1)
(3) get the final result by pointInWorld = tempPoint * extrinsics_depth , and X = pointInWorld.X, Y = pointInWorld.Y , Z = - pointInWorld.Z

Can anyone tell what is wrong with above actions? Or my code has error? Any help would be appreciated!
My code referenced Samples/StreamRecorder/StreamRecoderApp/VideoFrameProcessor.cpp and petergu684's repo https://github.com/petergu684/HoloLens2-ResearchMode-Unity/ , thanks for the work! And I will show my code in the comment area

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions