Skip to content
Oleg Toplionkin edited this page Oct 19, 2026 · 4 revisions

yuv_camera wiki

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.

Choose a route

First result

You want a camera preview on screen, then a captured picture.

  1. Getting started: set up the platform, add the packages and show the preview.
  2. Preview and capture: own the camera controller and capture the frame the user sees.

Typical scenario

Your screen processes camera frames (face detection, filters, measurements) and draws results over the preview.

  1. Getting started: a working preview.
  2. 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.
  3. Geometry and overlays: put boxes over the preview in the right place.
  4. Preview and capture: capture the processed screen.
  5. Shape crop: cut a rectangle, square, oval or circle out of the captured picture.
  6. Sharing the camera: give several screens one camera that opens when the first needs it and closes after the last.
  7. Platforms and troubleshooting: permissions, desktop and Web setup, verified platforms and fixes.

All guides

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.

Public types

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

Related

  • 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: camera and camera_desktop.

Clone this wiki locally