microsoft / HoloLens2ForCV

Sample code and documentation for using the Microsoft HoloLens 2 for Computer Vision research.
MIT License
479 stars 144 forks source link

PV camera frame's origin #155

Open emaschino opened 1 year ago

emaschino commented 1 year ago

Hello,

As we all know, OpenCV image origin [0,0] is the top, left corner of the image, +Y pointing down [1].

When retrieving HoloLens 2 PV camera frames using Media Foundation, the CameraIntrinsics.PrincipalPoint API documentation clearly states that "The origin [0,0] is the bottom, left corner of the image (+Y pointing up)" [2]. So the Y axis is reversed w.r.t. the OpenCV coordinate frame.

In the StreamRecorder sample [3], PrincipalPoint.y data is however passed as-is, whereas I was expecting CameraIntrinsics.ImageHeight() - PrincipalPoint.y. This has no effect in the context of the StreamRecorder sample, as the data are simply logged to a file. But a similar discrepancy can also be observed in the older HoloLensForCV repository sample when initializing cy component in the camera matrix later used for image undistortion [4].

What am I missing here? I've experimentally determined the HoloLens[2]ForCV samples being correct, i.e. taking PrincipalPoint.y as-is for OpenCV camera matrix cy component gives the correct visual result (with a sample app of my own), but I would also be very surprised that the CameraIntrinsics.PrincipalPoint API documentation could be so wrong, with a remark section even emphasizing the frame origin peculiarity from other image frameworks.

Thanks for any input/suggestion/clarification.

[1] https://docs.opencv.org/4.0.1/d9/d0c/group__calib3d.html [2] https://learn.microsoft.com/en-us/uwp/api/windows.media.devices.core.cameraintrinsics.principalpoint?view=winrt-17763#windows-media-devices-core-cameraintrinsics-principalpoint [3] https://github.com/microsoft/HoloLens2ForCV/blob/207205596840ae6e7b8c2a795d35c3c4e7bec22e/Samples/StreamRecorder/StreamRecorderApp/VideoFrameProcessor.cpp#L177 [4] https://github.com/microsoft/HoloLensForCV/blob/master/Samples/ComputeOnDevice/AppMain.cpp#L138

emaschino commented 1 year ago

The documentation counterpart [1].

[1] https://github.com/MicrosoftDocs/winrt-api/issues/2312