google-ar / arcore-unreal-sdk

ARCore SDK for Unreal
https://developers.google.com/ar/
Apache License 2.0
277 stars 122 forks source link

Acquire FOV from ARCore #52

Closed error454 closed 5 years ago

error454 commented 5 years ago

I am trying to fit some 3D menu items to fill the screen and it would be very helpful to be able to query the horizontal or vertical field of view when using ARCore.

I tried looking at the projection matrix calculation but the implementation for ArCamera_getProjectionMatrix seems to be in another library. If I could see how this matrix is constructed, I could work backward.

bopangzz commented 5 years ago

Check out the ComputerVision sample. It calculated the camera FOV based on the camera intrinsics there.

error454 commented 5 years ago

Thanks, I did find it tucked away in one of those BP's. If it helps anyone, here is the C++ equivalent using the image intrinsics:

const float FOVHor = 2.f * FMath::RadiansToDegrees(FMath::Atan2(ImageSizeX, 2.f * FocalLengthX));
const float FOVVer = 2.f * FMath::RadiansToDegrees(FMath::Atan2(ImageSizeY, 2.f * FocalLengthY));