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.

What frame number is relative to the image provided by TryGetLatestImage

Discussion in 'AR' started by AnthonyReddan, Feb 22, 2019.

  1. AnthonyReddan


    Feb 27, 2018
    I want to cache some data relative to each camera frame image (obtained with TryGetLatestImage from the XRCameraSubsystem extensions) for later processing. i.e. I want to know the state of a set of data for any given camera image that I process.

    Is it enough to cache my data in a ARSubsystemManager.cameraFrameReceived callback and then use that data when I call TryGetLatestImage? i.e. am I guaranteed that the result provided by TryGetLatestImage was provided at the same time cameraFrameReceived was invoked?

    I just want a way to map that image to the game data of the same frame. Currently I do nothing special and just grab the current frame data when I call TryGetLatestImage but I'm testing on a Pixel 2 and wondering if that will work on all devices or under poor performance conditions.
  2. tdmowrer


    Unity Technologies

    Apr 21, 2017
    If you call TryGetLatestImage from the cameraFrameReceived callback, it will be the image rendered that frame. There is also a timestamp associated with each CameraImage. See

    Note that a CameraImage is a native resource of which there are a limited quantity (I don't know how many; it varies by platform and possibly device). In practice, if you fail to dispose of about 10 of them then ARCore starts complaining about resource exhaustion and the background image stops updating, so don't hold onto them for too long.