Search Unity

AR Foundation - Camera Zoom

Discussion in 'Handheld AR' started by johnymetalheadx, Aug 8, 2019.

  1. johnymetalheadx

    johnymetalheadx

    Joined:
    Feb 20, 2016
    Posts:
    6
    Hi,

    I'm working on a research project in my university to build a simulation for microsurgery.

    Is there a way to have camera zoomed in to max on my mobile device already when the unity application starts?

    We just want to simulate the environment of microsurgery: when a surgeon looks through microscope, he sees a really high scaled view of the surgical cavity.

    Thanks in advance :)
     
  2. edee1337

    edee1337

    Joined:
    Apr 10, 2013
    Posts:
    14
    The simplest (and just about only) way to do zoom in ARFoundation would be to render the Camera output to a RenderTexture, set that RenderTexure to a RawImage in your UI, and then scaling that RawImage to 2x, 3x, whichever zoom level you wish to achieve. There is no API support for zoom (as you would in a normal camera app) or to access the tele lens if your device has one. Hope this helps!
     
  3. johnymetalheadx

    johnymetalheadx

    Joined:
    Feb 20, 2016
    Posts:
    6
    I have tried doing that and it worked but the zoomed in view is very blurry. Any work around for that?
     
  4. edee1337

    edee1337

    Joined:
    Apr 10, 2013
    Posts:
    14
    Try switching the AR Camera Options focus mode between Fixed and Auto to see which works best for your use case.

    Beyond that, the only other thing you can do is increase your RenderTexture resolution to match your camera output resolution (if you haven't already). For example, on older iPhones the camera output resolution is 1920 x 1080. On something like the iPhone X, I think it might be 2436 x 1125 or a little lower. You'll probably want to carefully monitor performance and memory at these higher resolutions.
     
  5. johnymetalheadx

    johnymetalheadx

    Joined:
    Feb 20, 2016
    Posts:
    6
    Worked perfectly when I matched the resolution of RenderTexture with the camera output resolution. Thanks man!
     
    edee1337 likes this.