Repository navigation
Home
yuv_camera shows a live camera preview in Flutter, hands each camera frame to your code as a YuvImage, and captures
the frame that is actually on screen. It is built on the camera plugin and on
yuv_ffi, and has no native plugin, platform channel or FFI layer of its own. These
guides give step-by-step recipes, explain the behavior behind them and list the errors you are most likely to meet. The
README is the quick start, the
API reference lists every parameter, and the
CHANGELOG records what changed in each version.
Documented version: 0.1.1. This wiki describes yuv_camera 0.1.1, which
requires yuv_ffi: ^0.5.2. Every recipe here was built against these two versions.
Image formats, operations and display of images without a camera are covered by the
yuv_ffi wiki. Read it for what a YuvImage can do once you hold one.
You want a camera preview on screen, then a captured picture.
- Getting started: set up the platform, add the packages and show the preview.
- Preview and capture: own the camera controller and capture the frame the user sees.
Your screen processes camera frames (face detection, filters, measurements) and draws results over the preview.
- Getting started: a working preview.
-
Frame processing: receive frames in
onFrame, use the raw and upright images, avoid mutating a delivered frame, connect ML Kit, or change what is drawn. - Geometry and overlays: put boxes over the preview in the right place.
- Preview and capture: capture the processed screen.
- Shape crop: cut a rectangle, square, oval or circle out of the captured picture.
- Sharing the camera: give several screens one camera that opens when the first needs it and closes after the last.
- Platforms and troubleshooting: permissions, desktop and Web setup, verified platforms and fixes.
| Guide | Use it to |
|---|---|
| Getting started | Install, set up permissions and show a preview. |
| Preview and capture | Own and dispose the camera controller, switch cameras, and capture the drawn frame. |
| Sharing the camera | Open the camera once for several screens with YuvCameraOrchestrator and YuvCameraLeaseBuilder. |
| Shape crop | Cut a rectangle, square, oval or circle out of a picture, with a transparent BGRA result. |
| Frame processing | Process frames with onFrame, read every frame with a frame source, wire ML Kit and transform the preview. |
| Geometry and overlays | Map detector boxes to the preview; understand camera orientation per platform. |
| Platforms and troubleshooting | Set up permissions, desktop provider and Web; see what is verified; fix common failures. |
Everything is exported from package:yuv_camera/yuv_camera.dart.
| Type | Purpose | Guide |
|---|---|---|
YuvCameraView |
A preview widget that also delivers throttled frames to onFrame, builds overlays and serves capture. |
Getting started, Preview and capture |
YuvCameraViewController |
A handle for one view: capture() and the current geometry. |
Preview and capture |
YuvCameraFrame |
One immutable camera delivery with the raw image, the upright() image and the orientation. |
Frame processing |
YuvCameraFrameSource |
A stream of every frame without a preview widget; throttling is yours. | Frame processing |
YuvTransformView |
A preview that runs a synchronous function on each accepted frame and draws its result. | Frame processing |
YuvCameraOrchestrator |
Owns the single camera of the app, opens it for the first lease and closes it after the last. | Sharing the camera |
YuvCameraLease |
A claim on the open camera: its controller and release(). |
Sharing the camera |
YuvCameraState |
closed, opening, open or closing: the state the orchestrator reports. |
Sharing the camera |
YuvCameraLeaseBuilder |
A widget that leases the camera while it is mounted and the app is visible. | Sharing the camera |
YuvCropTarget |
Where a crop is: pixels, fraction or square, independent of the image. |
Shape crop |
YuvCropShape |
What stays visible in the cropped rectangle: rectangle or ellipse. |
Shape crop |
YuvShapedImage |
The result of a shape crop: the cut-out image, region, insideCount and toBgraBytes() with transparency outside the shape. |
Shape crop |
YuvShapeCrop |
The extension on YuvImage that provides croppedToShape(...). |
Shape crop |
- Example app: a home screen with shape crop, open-and-close, ML Kit face-detection and device-check screens.
- yuv_ffi wiki: formats, operations, display and geometry of images.
- Plugin documentation:
cameraandcamera_desktop.