Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

ARFoundation Camera Intrinsic Params

Discussion in 'AR' started by ibrahimpenekli, Dec 25, 2018.

  1. ibrahimpenekli

    ibrahimpenekli

    Joined:
    Mar 10, 2015
    Posts:
    29
    Hi,

    Is there a way to get camera intrinsic parameters via ARFoundation interface? (Focal length and principal point etc)
     
  2. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    605
    Not currently, but there will be in the next release.
     
  3. EdwinLyons

    EdwinLyons

    Joined:
    Oct 4, 2012
    Posts:
    84
    Just like to vote for this feature - it used to be possible to get this when using the ARKit Unity plugin, but it appears to have been removed in recent releases, so I'm now left with no way to do this (without patching the ARKit plugin myself to add it back in).
     
  4. ecr23

    ecr23

    Joined:
    Mar 18, 2019
    Posts:
    1
    Can we calculate the camera intrinsic using existing APIs?
     
  5. camogram

    camogram

    Joined:
    Jul 11, 2018
    Posts:
    23
    I'd also like to vote for this one!
     
  6. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    605
  7. HyperLethalVector92

    HyperLethalVector92

    Joined:
    Jun 13, 2017
    Posts:
    11
    Hi, I've managed to pull the camera image, however the 'TryGetIntrinsics' Method always returns false, is there something special I should be doing for the build to be able to do this?
     
  8. avilleret

    avilleret

    Joined:
    Oct 21, 2019
    Posts:
    5
    how is it possible to retrieve the intrinsic parameter of the new iPad depth camera ? it is available through Apple ARKit but I can't find it in the ARFoundation 4.01-preview7 documentation.
     
  9. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    605
    It is not currently exposed, but you can get a pointer to the ARFrame and access it from there if you're wiling to write a bit of Objective-C. See https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.1/manual/extensions.html and https://docs.unity3d.com/Packages/c...ngine_XR_ARSubsystems_XRCameraFrame_nativePtr
     
  10. avilleret

    avilleret

    Joined:
    Oct 21, 2019
    Posts:
    5
    Thanks for the hint regarding direct Lidar access.
    However, how to be sure that the intrinsics parameter we get with `TryGetIntrinsics` are related to the frame we get with `TryGetLatestImage` ?
    Since the intrinsics parameters could change from frame to frame due to autofocus, we need some timestamp to associate intrinsic parameter and the corresponding frame.
     
  11. thibautvdumont

    thibautvdumont

    Joined:
    Oct 6, 2015
    Posts:
    25
    @tdmowrer

    I'd also be interested to know if the intrinsics we get from TryGetIntrinsics are related to the raw and unprocessed cpu image we get with TryGetLatestImage.

    More precisely, the image I get with TryGetLatestImage on my iphone is mirrored, so I have to apply XRCpuImage.Transformation.MirrorY when converting it :
    Code (CSharp):
    1.         var requestParams = new XRCpuImage.ConversionParams
    2.         {
    3.             outputFormat = TextureFormat.RGB24,
    4.             inputRect = new RectInt(0, 0, img.width, img.height),
    5.             outputDimensions = new Vector2Int(img.width, img.height),
    6.             transformation = XRCpuImage.Transformation.MirrorY
    7.         };
    Should I correct the optical center on X accordingly in the provided intrinsic matrix so that Ox = cpu_image_width - Ox ?
     
    Last edited: Jan 8, 2021
  12. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,081
    I think what you're looking for is displayMatrix. ARKit and ARCore use it to display the camera image in correct orientation/crop.
    Here is a link that describes the anatomy of the displayMatrix.
     
    thibautvdumont likes this.
  13. thibautvdumont

    thibautvdumont

    Joined:
    Oct 6, 2015
    Posts:
    25
    Many thanks, I was about to decompose the displayMatrix to get the corrections I should apply on the intrinsic, so this is definitely useful :)
     
  14. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,446