2.1 KiB
2.1 KiB
Complex camera features often fail due to "Agent Stall" or timeouts when attempted in a single turn. Use these blueprints to break tasks into manageable phases.
Manual controls
Phase one: ViewModel and state
- Define a
ManualSettingsdata class. - Add a
MutableStateFlow<ManualSettings>to yourCameraViewModel. - Implement the Jetpack Compose UI with sliders and switches to update this flow.
Phase two: Controller wiring
- In
CameraController.kt, create a new functionupdateManualSettings(settings: ManualSettings). - Map these settings into the
CameraSystemlayer.
Phase three: CameraX Camera2Interop wiring
- In
CameraSession.kt, use theCamera2Interop.Extenderutility to access Camera2 capture request keys. - Apply the hardware keys:
CaptureRequest.SENSOR_SENSITIVITYto set ISO sensitivity.CaptureRequest.SENSOR_EXPOSURE_TIMEto set exposure time.CaptureRequest.LENS_FOCUS_DISTANCEto set focus distance.
- Critical : If manual exposure is active, set
CaptureRequest.CONTROL_AE_MODEtoCameraMetadata.CONTROL_AE_MODE_OFF. ---
RAW and JPEG capture
Phase one: Output configuration
- Verify device support for RAW capture using
CameraInfo. - Configure
ImageCapture.BuilderwithOUTPUT_FORMAT_RAW_JPEGorOUTPUT_FORMAT_RAW.
Phase two: Implementation
- Provide
ImageCapture.OutputFileOptionsfor the target storage locations. - Invoke
takePicture. CameraX internally managesDngCreatorto wrap RAW data with the requiredCameraCharacteristicsandCaptureResultmetadata.
Apply image effects
Phase one: Effects selection
- Use the
androidx.media3:media3-effectdependency. - Use
RgbFilterorHslAdjustmentfor standard color grading.
Phase two: Application
- Configure
Composition.BuilderorMediaItem.Builderwith the list of effects. - Inject the list of effects into the CameraX
RecorderorPreviewusing thesetEffectsmethod.
Low-light capture
For guidance on Night Mode Extensions and Low Light Boost, low-light.md.