$ show ujizin/Camposer
Camposer is a Kotlin Multiplatform camera library that provides a unified Compose Multiplatform API for camera functionality on Android (via CameraX) and iOS (via AVFoundation). It offers camera preview, photo capture, video recording, flash/torch control, zoom, tap-to-focus, exposure compensation, mirror mode, multi-lens selection, video stabilization, and image analysis (including barcode/QR scanning via the optional code-scanner module). The library is published on Maven Central and includes sample apps demonstrating both Android-only and cross-platform usage. The architecture follows a clean separation of concerns with an internal engine/applier layer: `CameraState` holds reactive state flows for all configurable properties, and platform-specific appliers (`PreviewApplier`, `VideoApplier`, etc.) write changes to the underlying hardware when the state changes. The public API exposes `CameraPreview` composable, `CameraSession` for state/info access, and `CameraController` for capture commands. The codebase is well-structured with expect/actual pattern, version catalogs, ABI validation, and extensive test infrastructure (unit tests, device tests, iOS tests). It is a well-crafted, actively maintained library with high reusability potential.
The LLM identified 3 files worth highlighting for reuse:
Implements a prioritized scoring algorithm to select the best camera format from a list of available formats. Accepts prioritized configurations (resolution, aspect ratio, frame rate, stabilization) and returns the highest-scoring format. This is a self-contained, platform-agnostic utility that can be extracted and reused in any camera application or framework for format selection, demonstrating clean design and non-trivial algorithmic logic.
A Compose Multiplatform composable that draws a focus rectangle (square or circle) on the camera preview at a given tap position. It uses Canvas to render the shape with animated stroke color and width. The component is purely UI, takes only position, size, and color parameters, and can be easily extracted as a generic focus indicator for any camera or tap-to-focus UX. Demonstrates clean custom drawing and separation of visual concerns.
A simple, coroutine-based debouncer utility that delays execution of a lambda until a specified time has elapsed since the last invocation. It is implemented as a class with a single `debounce` method, using `CoroutineScope` and `delay`. This utility is small, self-contained, and can be extracted and used in any Kotlin Multiplatform project requiring debounced event handling (e.g., zoom updates, input throttling). Demonstrates clean, idiomatic coroutine usage.