camera_android_frame

The Android implementation of the camera plugin.

This package provides low-level camera access for the Android platform, used internally by the camera plugin.


๐Ÿš€ New Feature: Capture Preview Frame (JPEG)

This version introduces a new platform method: capturePreviewFrameJpeg() for retrieving a single JPEG-compressed frame directly from the preview stream, without interrupting camera operation.

โœ… Use Cases

  • Fast frame grabs for lightweight processing
  • Preview snapshot without full shutter/photo delay
  • Efficient ML/AI input for scanning or inference
  • Save current preview frame to file instantly

๐Ÿงช Streaming Preview Frames (YUV)

You can also subscribe to a continuous stream of preview frames in YUV format:

๐Ÿ”น Start / Stop Streaming

await cameraController.startFrameStream((frame) {
  // `frame` is CameraImageData with YUV planes
  process(frame);
});

await cameraController.stopFrameStream();

๐Ÿ“ธ One-time Preview Frame (YUV)

To retrieve a single preview frame in YUV format:

final CameraImageData frame = await cameraController.capturePreviewFrame();
// You can access .planes and .width/.height for further processing

๐Ÿ–ผ One-time Preview Frame (JPEG)

To capture and save a single JPEG preview frame:

final String savedPath = await cameraController.capturePreviewFrameJpeg('/path/to/file.jpg');

๐Ÿ›  How It Works

  • Uses an additional background ImageReader (YUV_420_888)
  • JPEG conversion is done via YuvImage.compressToJpeg
  • Frames are acquired non-blocking to avoid preview freezing
  • Safe for use during video recording or preview-only mode

โ—๏ธNotes

  • capturePreviewFrameJpeg() uses internal ImageReader, does not trigger shutter or autofocus
  • JPEG quality defaults to 90
  • Requires Android API 21+