Frame
A single Camera Frame, backed by a native buffer (an ImageProxy on Android, a CMSampleBuffer on iOS).
Lifetime contract: a Frame is only valid while isValid is true. The Camera pipeline has a small pool of buffers, so every Frame must be disposed as soon as possible, otherwise the pipeline stalls and frames get dropped (FrameDroppedReason.OUT_OF_BUFFERS). Accessing a disposed Frame throws. A Frame must not be shared across coroutines or stored beyond the processing callback.
Frame is AutoCloseable, so it can be used with use { }:
frame.use {
// processing...
}Properties
The number of bytes per row of this Frame's first plane.
The camera intrinsic matrix of this Frame (3x3, column-major, see CameraCalibrationData.cameraIntrinsicMatrix), or null if FrameOutputOptions.enableCameraMatrixDelivery is disabled. iOS only.
Whether this Frame can be accessed as a NativeBuffer.
Whether this Frame can be accessed on the CPU.
Whether this Frame is mirrored.
The orientation of this Frame's content, relative to the output orientation.
The PixelFormat of this Frame.
Functions
Converts a point in the Camera's normalized coordinate system to this Frame's coordinate system.
Converts a point in this Frame's coordinate system to the Camera's normalized coordinate system.
Gets a NativeBuffer to this Frame's native platform buffer, for zero-copy GPU or ML processing. The returned buffer must be NativeBuffer.released before this Frame is disposed.
Gets this Frame's pixel data, for non-planar Frames (e.g. RGB). For planar Frames, use getPlanes instead, as the content of this buffer is then platform specific.
Gets the FramePlanes of this Frame, if it is planar (isPlanar), e.g. one full resolution Y plane and one half resolution UV plane in YUV. Returns an empty list for non-planar Frames.