camera_android_frame 0.10.13 copy "camera_android_frame: ^0.10.13" to clipboard
camera_android_frame: ^0.10.13 copied to clipboard

Android implementation of the camera plugin.

camera_android #

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+