-
Notifications
You must be signed in to change notification settings - Fork 145
Description
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:
- get the (u,v) coordinates of the object center in PV Camera image space through object detection
- 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 frompv_frame.CoordinateSystem().TryGetTransformTo(m_worldCoordSystem)method , and the m_worldCoordSystem is set to Unity Coordinate System
- 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_depthrefers 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 thoughMapCameraSpaceToImagePoint()method
- 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
Dof this uv point , and get the camera space coordinates throughMapImagePointToCameraUnitPlane(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 bypointInWorld = tempPoint * extrinsics_depth, andX = 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