Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved iOS OcclusionManager env depth is all 0 iPhone 12 Pro

Discussion in 'AR' started by JeromeGodboutAmotus, Sep 9, 2021.

  1. JeromeGodboutAmotus

    JeromeGodboutAmotus

    Joined:
    Apr 24, 2020
    Posts:
    40
    Hi,
    I'm trying to test my depth AR depth applicaiton with the following setup:
    • iPhone 12 Pro
    • Unity 2021.1.17f1
    • ARFoundation 4.1.7 package
    • ARKit 4.1.7
    My code to extract the Occlusion Manager work under Android and the image seem to be extract under iOS, it has a 256x192 size of DepthFloat32 for a total of 196608 bytes per frames which seem to be ok. The problems is that all the value are 0 into the env depth image.

    I use the following (work under Android just fine with ARCore):
    Code (CSharp):
    1.  
    2.             if(OcclusionManager.TryAcquireEnvironmentDepthCpuImage(out XRCpuImage cpuImage))
    3.             {
    4.                 using (cpuImage)
    5.                 {
    6.                     XRCpuImage.ConversionParams conversionParams = new XRCpuImage.ConversionParams(cpuImage, XRCpuImageFormatExtensions.AsTextureFormat(cpuImage.format), XRCpuImage.Transformation.None);
    7.                     using (NativeArray<byte> rawData = new NativeArray<byte>(cpuImage.GetConvertedDataSize(conversionParams), Allocator.Temp))
    8.                     {
    9.                         cpuImage.Convert(conversionParams, rawData);
    10.                         Texture2D texture = new Texture2D(conversionParams.outputDimensions.x, conversionParams.outputDimensions.y, conversionParams.outputFormat, false, false);
    11.                         texture.LoadRawTextureData(rawData);
    12.                         texture.Apply();
    13.                         DepthTexture = texture;
    14.                     }
    15.                 }
    16.             }
    17.  
    Is there a field to add to the Info.plist or an option somewhere to enable the depth value with iPhone 12 Pro? From what I have found it should be supported for 4.1.x ARFoundation package.

    Side note. My OcclusionManager is not on the ARCamera to avoid doing rendering of the occlusion, I only request the depth to place something relative to environment. This work under Android, the texture get the right dimension and type (Android was half float or 16 bits float, iOS is 32 bits float but aside from that nothing different). Just the content of it is just plain 0 ever after a little while. Maybe there is an enabler somewhere?!?
     
  2. JeromeGodboutAmotus

    JeromeGodboutAmotus

    Joined:
    Apr 24, 2020
    Posts:
    40
    I did try to display the value, I do not known why but if I do transform the orientation the texture get filled properly:
    XRCpuImage.Transformation.MirrorY
    instead of
    XRCpuImage.Transformation.None

    I was transforming later on with other transform, but it seem to do something weird I was having only a small band of the depth when I set it to none. I have no clue why, maybe a lot of padding going on here?!? I'm still investigating, but that's a start point for the zero on most of the depth, the display show a little band incomplete of depth.
     
  3. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,816
  4. JeromeGodboutAmotus

    JeromeGodboutAmotus

    Joined:
    Apr 24, 2020
    Posts:
    40
    Yeah I reported the issue and it got fixed into 4.2.1, thank you.