Search Unity

Question The front facing camera used for Face Tracking seems zoomed in, any way to pull it back?

Discussion in 'Unity MARS' started by azevedco, Mar 21, 2022.

  1. azevedco

    azevedco

    Joined:
    Mar 2, 2014
    Posts:
    34
    Hey folks,

    We're doing some work with the texture returned back from MARS on mobile and we've noticed that the frame returned back is pretty narrow. Is there any way to adjust the Aspect Ratio of what MARS is capturing so that there's more width to the frame returned?

    Let me know if you need further details.

    Cheers,
    azevedco
     
  2. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    199
    I assume you're using `IUsesCameraTexture`? Does the aspect ratio match the screen? And what platform?

    MARS basically gets this straight from AR Foundation but I think things can get platform dependent.
     
  3. azevedco

    azevedco

    Joined:
    Mar 2, 2014
    Posts:
    34
    Hi CiaranWills,

    Yes, we're using `IUsesCameraTexture` to grab the texture from MARS to work with. Although...taking another look at this script, it is coming back to me regarding some issues we faced with iOS.
    When attempting to pull the texture from our class that extended from interface 'IUsesCameraTexture' on iOS, we never got a texture back, although it worked fine for Android. So we had to fallback to a new approach where we grab the material from ARCameraManager.cameraMaterial and found that gave us a texture to work with on both platforms.

    We then perform a Graphics.Blit to extract the texture. Do you think this is a bad approach? If so, what are your thoughts are the issues we're experiencing while grabbing the texture on iOS with IUsesCameraTexture? I'll share our implementation with the interface below.

    Code (CSharp):
    1. public class MarsCamTexture : Singleton<MarsCamTexture>, IUsesCameraTexture
    2. {
    3.     IProvidesCameraTexture IFunctionalitySubscriber<IProvidesCameraTexture>.provider { get; set; }
    4.  
    5.     public ARCameraManager ARCameraManager { get { return arCamManager; } }
    6.  
    7.     [SerializeField] private ARCameraManager arCamManager = null;
    8.  
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.         if (arCamManager == null)
    13.         {
    14.             arCamManager = MarsRuntimeUtils.GetActiveCamera(true).GetComponent<ARCameraManager>();
    15.         }
    16.     }
    17.  
    18.     /// <summary>
    19.     /// Returns camera texture from MARS
    20.     /// </summary>
    21.     /// <returns></returns>
    22.     public Texture GetCamTexture()
    23.     {
    24.         if (this.HasProvider())
    25.         {
    26.             return this.GetCameraTexture();
    27.         }
    28.  
    29.         return null;
    30.     }
    31.  
    32.     public Material GetArCamMaterial()
    33.     {
    34.         if(arCamManager != null)
    35.         {
    36.             return arCamManager.cameraMaterial;
    37.         }
    38.  
    39.         return null;
    40.     }
    41. }
    Cheers!
     
  4. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    199
    Can you see the log when you run from XCode, and are there any errors in there? There is an issue on iOS with recent ARKit versions that we have a fix coming for.