Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
CameraConfig descrive le proprietà dell'elemento
sensore sottostante della fotocamera, tra cui:
ID fotocamera
Se disponibile, indica se verrà utilizzato un sensore di profondità
La direzione in cui è rivolta la fotocamera:
davanti (selfie)
rivolto all'indietro (mondo)
Intervallo f/s (frame al secondo)
Dimensioni immagine CPU
Dimensione texture GPU
Se presente, indica se verrà utilizzata la fotocamera stereo del dispositivo
Quando crei una nuova sessione ARCore, ARCore utilizza
setCameraConfig per impostare la configurazione della videocamera
che corrisponde meglio all'elenco delle configurazioni disponibili restituite
getSupportedCameraConfigs(CameraConfigFilter).
La tua app può utilizzare CameraConfigFilter
per restringere le configurazioni della videocamera disponibili per un determinato dispositivo in fase di runtime
filtrando in base alle esigenze della tua app.
I casi d'uso comuni per l'applicazione di filtri includono:
Limitare la frequenza fotogrammi di acquisizione della fotocamera a 30 f/s. Sui dispositivi che supportano
60 f/s, ARCore darà la priorità alle configurazioni della fotocamera che supportano
frequenza fotogrammi. Per filtrare tutte le configurazioni della fotocamera che supportano 60 f/s:
applicare un filtro con setTargetFps
utilizzando TargetFps.TARGET_FPS_30.
Impedisci ad ARCore di utilizzare il sensore di profondità. Sui dispositivi con
sensore di profondità supportato, ARCore dà priorità alle configurazioni della fotocamera che utilizzano la profondità
sensore. Per filtrare tutte le configurazioni della fotocamera che utilizzano il sensore di profondità, applica la
setDepthSensorUsage
filtro utilizzando DepthSensorUsage.DO_NOT_USE.
Selezione di una risoluzione di texture GPU alternativa. Attivato
dispositivi supportati, ARCore potrebbe fornire
risoluzioni di texture GPU aggiuntive. Selezione di una texture GPU a risoluzione più bassa
può contribuire a migliorare le prestazioni dell'app riducendo il carico della GPU e riducendo la memoria
requisiti di larghezza di banda, anche se non è garantito il miglioramento delle prestazioni
per tutti i casi.
Utilizzare i filtri di configurazione della videocamera
Segui questi passaggi per consentire all'app di filtrare le configurazioni delle videocamere.
Puoi anche impostare la modalità focus nella configurazione della sessione. Lo stato attivo fisso è generalmente migliore per il monitoraggio (ed è l'impostazione predefinita di ARCore sulla maggior parte dei dispositivi).
La messa a fuoco automatica è necessaria per le registrazioni, le foto, le riprese video e quando gli oggetti vicini devono essere a fuoco.
[null,null,["Ultimo aggiornamento 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eCameraConfig\u003c/code\u003e describes the properties of the underlying camera sensor used by ARCore, such as camera ID, depth sensor usage, facing direction, FPS range, and dimensions.\u003c/p\u003e\n"],["\u003cp\u003eARCore automatically selects the best camera configuration but allows developers to filter these configurations based on specific needs like limiting frame rate or disabling depth sensor usage.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use \u003ccode\u003eCameraConfigFilter\u003c/code\u003e to narrow down the available camera configurations by filtering based on criteria like target FPS and depth sensor usage.\u003c/p\u003e\n"],["\u003cp\u003eWhile ARCore prioritizes higher frame rates and depth sensor usage by default, developers can modify these preferences using the provided filtering mechanisms.\u003c/p\u003e\n"],["\u003cp\u003eFocus mode can also be adjusted in the session configuration, with fixed focus generally preferred for tracking and auto focus required for recording or focusing on nearby objects.\u003c/p\u003e\n"]]],[],null,["# Configuring the camera\n\n| **Key Point:** To configure additional custom GPU textures, use the (Java) [shared camera](/ar/develop/java/camera-sharing) feature.\n\n[`CameraConfig`](/ar/reference/java/com/google/ar/core/CameraConfig) describes the properties of the\nunderlying camera sensor, including:\n\n- The camera ID\n- If available, whether a depth sensor will be used\n- The direction the camera is facing:\n - front-facing (selfie)\n - rear-facing (world)\n- FPS (frames per second) range\n- CPU image dimensions\n- GPU texture dimension\n- If present, whether the device's [stereo multi-camera](https://source.android.com/devices/camera/multi-camera) will be used\n\nWhen creating a new ARCore session, ARCore uses\n[`setCameraConfig`](/ar/reference/java/com/google/ar/core/Session#setCameraConfig(com.google.ar.core.CameraConfig)) to set the camera config\nthat best matches the list of available configs returned by\n[`getSupportedCameraConfigs(CameraConfigFilter)`](/ar/reference/java/com/google/ar/core/Session#getSupportedCameraConfigs(com.google.ar.core.CameraConfigFilter)).\nYour app can use [`CameraConfigFilter`](/ar/reference/java/com/google/ar/core/CameraConfigFilter)\nto narrow down the available camera configs for a given device at runtime by\nfiltering based on your app's needs.\n\nCommon use cases for filtering include:\n\n- **Limiting camera capture frame rate to 30 fps** . On devices that support\n 60 fps, ARCore will prioritize camera configs that support that\n frame rate. To filter out all camera configs that support 60 fps,\n apply a filter with [`setTargetFps`](/ar/reference/java/com/google/ar/core/CameraConfigFilter#setTargetFps(java.util.EnumSet\u003ccom.google.ar.core.CameraConfig.TargetFps\u003e))\n using `TargetFps.TARGET_FPS_30`.\n\n\n ### Java\n\n ```java\n // Return only camera configs that target 30 FPS camera capture frame rate.\n filter.setTargetFps(EnumSet.of(CameraConfig.TargetFps.TARGET_FPS_30));\n ```\n\n ### Kotlin\n\n ```kotlin\n // Return only camera configs that target 30 FPS camera capture frame rate.\n filter.targetFps = EnumSet.of(CameraConfig.TargetFps.TARGET_FPS_30)\n ```\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n- **Prevent ARCore from using the depth sensor** . On devices that have a\n supported depth sensor, ARCore prioritizes camera configs that use the depth\n sensor. To filter out all camera configs that use the depth sensor, apply the\n [`setDepthSensorUsage`](/ar/reference/java/com/google/ar/core/CameraConfigFilter#setDepthSensorUsage(java.util.EnumSet\u003ccom.google.ar.core.CameraConfig.DepthSensorUsage\u003e))\n filter using `DepthSensorUsage.DO_NOT_USE`.\n\n\n ### Java\n\n ```java\n // Return only camera configs that will not use the depth sensor.\n filter.setDepthSensorUsage(EnumSet.of(CameraConfig.DepthSensorUsage.DO_NOT_USE));\n ```\n\n ### Kotlin\n\n ```kotlin\n // Return only camera configs that will not use the depth sensor.\n filter.depthSensorUsage = EnumSet.of(CameraConfig.DepthSensorUsage.DO_NOT_USE)\n ```\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n- **Selecting an alternate GPU texture resolution** . On\n [supported devices](/ar/discover/supported-devices), ARCore may provide\n additional GPU texture resolutions. Selecting a lower resolution GPU texture\n may help improve app performance by reducing GPU load and lowering memory\n bandwidth requirements, although is not guaranteed to improve performance in\n all cases.\n\nUsing camera config filters\n---------------------------\n\nFollow these steps to enable your app to filter camera configs. \n\n### Java\n\n```java\n// Create a camera config filter for the session.\nCameraConfigFilter filter = new CameraConfigFilter(session);\n\n// Return only camera configs that target 30 fps camera capture frame rate.\nfilter.setTargetFps(EnumSet.of(CameraConfig.TargetFps.TARGET_FPS_30));\n\n// Return only camera configs that will not use the depth sensor.\nfilter.setDepthSensorUsage(EnumSet.of(CameraConfig.DepthSensorUsage.DO_NOT_USE));\n\n// Get list of configs that match filter settings.\n// In this case, this list is guaranteed to contain at least one element,\n// because both TargetFps.TARGET_FPS_30 and DepthSensorUsage.DO_NOT_USE\n// are supported on all ARCore supported devices.\nList\u003cCameraConfig\u003e cameraConfigList = session.getSupportedCameraConfigs(filter);\n\n// Use element 0 from the list of returned camera configs. This is because\n// it contains the camera config that best matches the specified filter\n// settings.\nsession.setCameraConfig(cameraConfigList.get(0));\n```\n\n### Kotlin\n\n```kotlin\n// Create a camera config filter for the session.\nval filter = CameraConfigFilter(session)\n\n// Return only camera configs that target 30 fps camera capture frame rate.\nfilter.targetFps = EnumSet.of(CameraConfig.TargetFps.TARGET_FPS_30)\n\n// Return only camera configs that will not use the depth sensor.\nfilter.depthSensorUsage = EnumSet.of(CameraConfig.DepthSensorUsage.DO_NOT_USE)\n\n// Get list of configs that match filter settings.\n// In this case, this list is guaranteed to contain at least one element,\n// because both TargetFps.TARGET_FPS_30 and DepthSensorUsage.DO_NOT_USE\n// are supported on all ARCore supported devices.\nval cameraConfigList = session.getSupportedCameraConfigs(filter)\n\n// Use element 0 from the list of returned camera configs. This is because\n// it contains the camera config that best matches the specified filter\n// settings.\nsession.cameraConfig = cameraConfigList[0]\n```\n\nFocus mode\n----------\n\nYou can also set the focus mode in the session configuration. Fixed focus is generally better for tracking (and is the ARCore default on most devices).\nAuto focus is required for recording, photography, videography, and when nearby objects need to be in focus.\n\nSee [`Config.FocusMode`](/ar/reference/java/com/google/ar/core/Config.FocusMode)\nfor details."]]