Search Unity

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:
    297
    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_Unity

    amydigiov_Unity

    Unity Technologies

    Joined:
    May 24, 2016
    Posts:
    16
    @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.