CameraPipe is a low-level, high-performance Camera2 abstraction layer built from the ground up to be idiomatic to Kotlin. It provides a flexible and efficient shim to power high-performance camera applications and serves as the backend for CameraX's camera-camera2 implementation.
CameraPipe is organized around several key abstractions:
CameraPipe.cameras), create capture sessions (CameraPipe.createCameraGraph, CameraPipe.createFrameGraph) and manage global resources.CameraPipe.cameras. Underneath the hood, the camera devices are managed by Camera2DeviceCache (for camera ID list management) and Camera2DeviceManager (for camera prewarming, opening and closing).CameraCaptureSession, except that the user would specify both the camera ID and session configurations at once in CameraGraph.Config when a CameraGraph is created, removing the need for the user to manage the cameras separately. CameraGraph provides APIs for querying streams, setting the Surfaces of streams, setting parameters and most importantly, acquiring an exclusive CameraGraph session (CameraGraph.Session) through CameraGraph.acquireSession to submit capture requests and control 3A. Note that CameraGraph.Session differs from a camera capture session - it is a CameraGraph concept that grants exclusive access to CameraGraph for the single user that acquired the session.CameraGraph to provide capabilities for advanced stream controls. Output images and metadata (capture result) from a FrameGraph are grouped into Frame objects, allowing each frame to contain the output image and the corresponding capture result metadata. FrameGraph's capture APIs (capture, captureWith) can only be used on streams configured with ImageSourceConfig. Using the FrameGraph.captureWith API, the user would receive a FrameBuffer, a ring-buffer of Frame objects that allows for continuous frame processing.CameraStream, OutputStream and InputStream) configured in a CameraGraph. An instance of this class can be accessed via CameraGraph.streams.CameraPipe, notably including application Context, thread configuration and camera backend configuration. If thread configuration is not supplied, CameraPipe will creates its own threads.CameraGraph, including the camera ID, and various session and stream configurations such as the list of streams (CameraStream.Config), session parameters, persistent parameter settings and request listeners.OutputStreams. Defined via CameraStream.Config.CameraStream, including size, format, and other properties. Defined via OutputStream.Config. For a multi-resolution stream (backed by MultiResolutionImageReader), one CameraStream would contain multiple OutputStreams.CaptureRequest.TotalCaptureResult.CameraGraph, including CameraGraph and CameraGraph.Session implementations, stream and surface management utilities, graph state management classes, 3A control and management facilities and robust capture request management.FrameGraph.Images and ImageReaders.CameraPipe serves as the core library for the camera packages. Designing and making changes should be done with utmost care, while considering and verifying all CameraPipe and associated projects.
:camera:camera-camera2-pipe, :camera:camera-camera2-pipe-testing, :camera:integration-tests:camera-testapp-camera2-pipe.:camera:camera-common, :camera:camera-camera2, :camera:integration-tests:camera-testapp-core..kt files using ktfmt before submitting. Use the following command: ./gradlew :ktCheckFile --format --file <file>LIBRARY_GROUP, but CameraPipe does follow the standard AndroidX API guidelines.git mv when moving files to preserve history.When making CameraPipe changes, you must verify the changes by building CameraPipe (camera-camera2-pipe) and running CameraPipe unit tests. When the changes are ready for review, make sure to also run CameraX Camera2 (camera-camera2) unit tests to verify API and functional compatibility before uploading the changes.
When ./gradlew is mentioned, it refers to the script located under frameworks/support (@../../).
./gradlew --info \ :camera:camera-camera2-pipe:compileReleaseSources :camera:camera-camera2-pipe-testing:compileReleaseSources
./gradlew --info --strict \ :camera:camera-camera2-pipe:testReleaseUnitTest \ :camera:camera-camera2-pipe:compileReleaseUnitTestKotlin \ :camera:camera-camera2-pipe-testing:testReleaseUnitTest \ :camera:camera-camera2-pipe-testing:compileReleaseUnitTestKotlin \ :camera:integration-tests:camera-testapp-camera2-pipe:testDebugUnitTest \ :camera:integration-tests:camera-testapp-camera2-pipe:compileDebugUnitTestKotlin
./gradlew --info --strict \ :camera:camera-camera2:testReleaseUnitTest \ :camera:camera-camera2:compileReleaseUnitTestKotlin
config package.Flow for asynchronous operations. For low-level thread-safe state, prefer AtomicFu or synchronized blocks where appropriate.@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) if it isn't part of the top-level CameraPipe directory.CameraPipe relies on robust tests for performance and correctness in hardware interactions.
assert* or Hamcrest.testing package or :camera:camera-camera2-pipe-testing module over mocking frameworks like Mockito../gradlew :camera:camera-camera2-pipe:test@Config(sdk = [Config.TARGET_SDK]) for standard tests unless specific SDK-level behavior needs verification.CameraPipeSimulator, CameraGraphSimulator and FrameGraphSimulator should be used instead of Robolectric camera when functional testing or end-to-end verification is needed.Use the standard CameraX/AndroidX commit message format. Each section should be separated by a blank line. The commit title should not exceed 50 characters, and body lines should not exceed 72 characters.
<Commit Title> <Detailed description of the change.> Bug: <Bug id> Test: <Test instructions or command>
Bug:.git commit --amend), do not modify or remove the Change-Id: line. Never use -m alone when amending, as it strips the Change-Id and creates a duplicate CL.