Search Unity

AR Foundation - Camera Frame Rate defaulting to 30?

Discussion in 'AR' started by Page2, Jul 20, 2020.

  1. Page2

    Page2

    Joined:
    Oct 10, 2017
    Posts:
    2
    Hey there,

    As title, after testing over two devices (Pixel 4 XL and Galaxy S20+), it appears I don't have control over what frame-rate the camera defaults to, and subsequently what frame-rate my app runs at.

    Things I'm currently using:
    Code (CSharp):
    1. Application.targetFrameRate = 60;
    2. ARSession.matchFrameRate = false;
    ARSession.matchFrameRate appears to not have any effect, as far as I can tell.

    The Pixel (I believe) has a default camera FPS of 60, subsequently my app runs at 60fps on the device. On the S20, however, while the device itself has the ability for the camera to run at higher frame-rates, the default is 30fps, and as a result - my app runs at 30.

    AR Core evidently has a CameraConfig class to help with this - see: https://developers.google.com/ar/develop/unity/camera-configs, but this isn't accessible within AR Foundation, as far as I can tell.

    Is anyone able to give me an idea of what I could to here (if anything) to request a 60FPS from my devices' camera, if it has the ability?

    **EDIT**
    Never mind, this may simply be an ARCore support limitation - as listed here https://developers.google.com/ar/discover/supported-devices, only Pixel devices have 60fps support.
     
    Last edited: Jul 21, 2020
  2. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,142
    AR Foundation has an API for setting camera configuration:
    https://docs.unity3d.com/Packages/c...undation_ARCameraManager_currentConfiguration

    Here is an example of usage:
    Code (CSharp):
    1. if (cameraManager.descriptor.supportsCameraConfigurations) {
    2.     using (var configs = cameraManager.GetConfigurations(Allocator.Temp)) {
    3.         foreach (var config in configs) {
    4.             if (isPreferredConfig(config)) {
    5.                 try {
    6.                     cameraManager.currentConfiguration = config;
    7.                     break;
    8.                 } catch (Exception e) {
    9.                     Debug.LogError("setting cameraManager.currentConfiguration failed with exception: " + e);
    10.                 }
    11.             }
    12.         }
    13.     }
    14. }
    15.  
    16. static bool isPreferredConfig(XRCameraConfiguration config) {
    17.     throw new NotImplementedException("todo: determine if this camera configuration is preferred for your app");
    18. }
     
  3. Page2

    Page2

    Joined:
    Oct 10, 2017
    Posts:
    2
    Thanks for the pointer mate. Unfortunately, it appears my S20 is only reporting 30fps camera configurations - could this have something to do with 60 potentially being classed as a "high speed capture session", and subsequently not reporting? https://developer.android.com/refer...era2/CameraConstrainedHighSpeedCaptureSession ?


    **EDIT**
    Never mind, this may simply be an ARCore support limitation - as listed here https://developers.google.com/ar/discover/supported-devices, only Pixel devices have 60fps support.
     
  4. b9n

    b9n

    Joined:
    Feb 6, 2020
    Posts:
    14
    is there any way to bypass that restriction, clearly S20 can handle 60fps
     
    EthanFischer likes this.