camera_avfoundation_frame 0.9.20+10 copy "camera_avfoundation_frame: ^0.9.20+10" to clipboard
camera_avfoundation_frame: ^0.9.20+10 copied to clipboard

iOS implementation of the camera plugin.

camera_avfoundation_frame #

The iOS implementation of the camera plugin.

This package provides low-level camera access for the iOS platform using AVFoundation, and is used internally by the camera plugin.


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

This version adds capturePreviewFrameJpeg(outputPath, { rotationDegrees, quality }) to grab a single JPEG-compressed frame from the preview stream without interrupting the camera.

  • rotationDegrees (optional, int): 0 | 90 | 180 | 270 (pixel rotation, no EXIF).
  • quality (optional, int): 0–100 (default 92).

βœ… Use Cases #

  • Fast preview snapshot capture
  • Save current frame to file instantly
  • Frame grab for ML/inference
  • Lightweight visual logging or scanning

πŸ“Έ One-time Preview Frame (YUV) #

To capture a single frame (non-streaming) in YUV format:

final CameraImageData frame = await cameraController.capturePreviewFrame();
// Access .planes, .width, .height, .format, etc.

πŸ–Ό One-time Preview Frame (JPEG) #

To capture and save a JPEG-compressed preview frame to file:

// Default: rotation 0Β°, quality 92
final String savedPath = await cameraController.capturePreviewFrameJpeg('/path/to/file.jpg');

// With rotation and quality
final String savedPath2 = await cameraController.capturePreviewFrameJpeg(
  '/path/to/rotated.jpg',
  rotationDegrees: 90,
  quality: 85,
);

πŸ›  How It Works #

  • Captures the current CVPixelBuffer via AVCaptureVideoDataOutput
  • Converts NV12/BGRA β†’ CIImage, applies pixel rotation (no EXIF tags)
  • Encodes JPEG via CGImageDestination (quality 0–1, mapped from 0–100)
  • Capture does not interrupt preview or video recording

❗️Notes #

  • capturePreviewFrameJpeg does not trigger autofocus or use shutter animations
  • JPEG does not contain EXIF metadata or EXIF orientation (pixels are rotated)
  • Supported formats: kCVPixelFormatType_420YpCbCr8BiPlanarFullRange (NV12), kCVPixelFormatType_32BGRA
  • iOS 11+