CameraConfig
說明瞭
底層相機感應器,包括:
- 相機 ID
- 在適用情況下,是否會使用深度感應器
- 相機鏡頭的方向:
- 前置 (自拍)
- 後置 (世界)
- FPS (每秒影格數) 範圍
- CPU 圖片尺寸
- GPU 紋理尺寸
- 如果有出現,是否使用裝置的立體聲多鏡頭
建立新的 ARCore 工作階段時,ARCore 會使用
setCameraConfig
:進行相機設定
與
getSupportedCameraConfigs(CameraConfigFilter)
。
您的應用程式可以使用 CameraConfigFilter
,
來自訂符合應用程式需求的
常見的篩選用途包括:
將相機拍攝影格速率限制為每秒 30 個影格。使用支援的裝置 60 fps,ARCore 會優先採用支援這類技術的相機設定 畫面更新率如要篩除支援 60 fps 的所有相機設定, 使用
setTargetFps
套用篩選器 使用TargetFps.TARGET_FPS_30
。禁止 ARCore 使用深度感應器。在符合下列條件的裝置上, 支援深度感應器,ARCore 會優先使用採用深度感應器的相機設定 感應器。如要篩除使用深度感應器的所有相機設定,請套用
setDepthSensorUsage
敬上 使用「DepthSensorUsage.DO_NOT_USE
」篩選。// Return only camera configs that will not use the depth sensor.
filter.setDepthSensorUsage(EnumSet.of(CameraConfig.DepthSensorUsage.DO_NOT_USE));// Return only camera configs that will not use the depth sensor.
filter.depthSensorUsage = EnumSet.of(CameraConfig.DepthSensorUsage.DO_NOT_USE)選取替代的 GPU 紋理解析度。啟用 支援的裝置,ARCore 可能會提供 額外的 GPU 紋理解析度選取解析度較低的 GPU 紋理 降低 GPU 負載及降低記憶體容量,有助提升應用程式效能 頻寬需求,但不保證一定能改善
使用攝影機設定篩選器
請按照下列步驟讓應用程式篩選相機設定。
// Create a camera config filter for the session.
CameraConfigFilter filter = new CameraConfigFilter(session);
// Return only camera configs that target 30 fps camera capture frame rate.
filter.setTargetFps(EnumSet.of(CameraConfig.TargetFps.TARGET_FPS_30));
// Return only camera configs that will not use the depth sensor.
filter.setDepthSensorUsage(EnumSet.of(CameraConfig.DepthSensorUsage.DO_NOT_USE));
// Get list of configs that match filter settings.
// In this case, this list is guaranteed to contain at least one element,
// because both TargetFps.TARGET_FPS_30 and DepthSensorUsage.DO_NOT_USE
// are supported on all ARCore supported devices.
List<CameraConfig> cameraConfigList = session.getSupportedCameraConfigs(filter);
// Use element 0 from the list of returned camera configs. This is because
// it contains the camera config that best matches the specified filter
// settings.
session.setCameraConfig(cameraConfigList.get(0));
// Create a camera config filter for the session.
val filter = CameraConfigFilter(session)
// Return only camera configs that target 30 fps camera capture frame rate.
filter.targetFps = EnumSet.of(CameraConfig.TargetFps.TARGET_FPS_30)
// Return only camera configs that will not use the depth sensor.
filter.depthSensorUsage = EnumSet.of(CameraConfig.DepthSensorUsage.DO_NOT_USE)
// Get list of configs that match filter settings.
// In this case, this list is guaranteed to contain at least one element,
// because both TargetFps.TARGET_FPS_30 and DepthSensorUsage.DO_NOT_USE
// are supported on all ARCore supported devices.
val cameraConfigList = session.getSupportedCameraConfigs(filter)
// Use element 0 from the list of returned camera configs. This is because
// it contains the camera config that best matches the specified filter
// settings.
session.cameraConfig = cameraConfigList[0]
專注模式
您也可以在工作階段設定中指定聚焦模式。固定焦點通常較適合用於追蹤 (在大多數裝置上也是 ARCore 預設選項)。 必須啟用自動對焦功能,才能進行拍攝、攝影和錄影,以及與鄰近物體拍攝。
查看「Config.FocusMode
」
。