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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Question Grab the camera image/texture

Discussion in 'Unity MARS' started by Jon-at-Kaio, Jun 30, 2020.

  1. Jon-at-Kaio

    Jon-at-Kaio

    Joined:
    Oct 17, 2007
    Posts:
    185
    I'm hoping this will be a relatively quick ask, I was able to capture the image feed from the camera using TryGetLatestImage when using the 'old' ARFoundation approach, so am just looking for the equivalent in via the MARS Api, no too worried if it works in the simulation in editor or not, I just need to be able to capture a texture from the camera once I detect a wall/plane.
     
  2. jmunozarUTech

    jmunozarUTech

    Unity Technologies

    Joined:
    Jun 1, 2020
    Posts:
    295
    Hello @Jon-at-Kaio MARS leverages camera feed through AR Foundation so you should be good to go using the AR Foundation approach.
     
  3. Jon-at-Kaio

    Jon-at-Kaio

    Joined:
    Oct 17, 2007
    Posts:
    185
    how do i get access to ARCameraManager via MARS ?
     
  4. amydigiov

    amydigiov

    Unity Technologies

    Joined:
    May 24, 2016
    Posts:
    15
    @Jon-at-Kaio if you have a MonoBehaviour that implements IUsesCameraTexture you can call
    this.GetCameraTexture()
    ("this" is necessary because GetCameraTexture is an extension method for IUsesCameraTexture).

    At runtime on device this will return the camera texture provided by AR Foundation. In simulation in the editor it will return the texture of the video in "Recorded" mode or the webcam in "Live" mode. In other simulation modes it returns null.
     
    tteneder and jmunozarUTech like this.
  5. Jon-at-Kaio

    Jon-at-Kaio

    Joined:
    Oct 17, 2007
    Posts:
    185
    Awesome thank you.