CameraFrameOutput

interface CameraFrameOutput extends CameraOutput

The CameraFrameOutput allows synchronously streaming Frames from the Camera, aka "Frame Processing".

See

Examples

Creating a CameraFrameOutput via the Hooks API:

const frameOutput = useFrameOutput({
  pixelFormat: 'yuv',
  onFrame(frame) {
    'worklet'
    frame.dispose()
  }
})

Creating a CameraFrameOutput via the Imperative API:

const frameOutput = VisionCamera.createFrameOutput({
  targetResolution: CommonResolutions.HD_16_9,
  pixelFormat: 'yuv',
  enablePreviewSizedOutputBuffers: false,
  allowDeferredStart: true,
  enablePhysicalBufferRotation: false,
  enableCameraMatrixDelivery: false,
  dropFramesWhileBusy: true,
})

Properties

currentResolution?

readonly optional currentResolution?: Size

The resolution that the underlying capture pipeline has resolved this CameraOutput to, in sensor-native (un-rotated) pixels, or undefined if the output has not yet been connected to a CameraSession.

Discussion

The selected Size may differ from the requested Size (e.g. from PhotoOutputOptions.targetResolution), as the CameraSession negotiates resolutions across attached CameraOutputs, connected CameraDevice capabilities, and enabled Constraints.

Discussion

For outputs that are not pixel-based (e.g. metadata-only outputs), this reports the resolution of the upstream video stream feeding the output, or undefined if no video input is attached.

Inherited from

CameraOutput.currentResolution


mediaType

readonly mediaType: MediaType

The media type of the content being streamed by this CameraOutput.

Inherited from

CameraOutput.mediaType


outputOrientation

outputOrientation: CameraOrientation

Gets or sets the output orientation of this CameraOutput.

Individual implementations of CameraOutput may choose different strategies for implementing output orientation, for example:

  • A Photo output might apply orientation via EXIF flags.
  • A Video output might apply orientation via track transform metadata.
  • A Preview output might apply orientation via view transforms.
  • A Frame output might not apply orientation and only pass it as a property via the Frame object, unless explicitly configured to physically rotate buffers.

Inherited from

CameraOutput.outputOrientation


thread

readonly thread: NativeThread

Get the NativeThread that this CameraFrameOutput is running on. This is the thread that setOnFrameCallback(...) callbacks run on.

Methods

setOnFrameCallback(...)

setOnFrameCallback(onFrame: (frame: Frame) => boolean & object | undefined): void

Adds a callback that calls the given onFrame function every time the Camera produces a new Frame.

Throws

If not called on a Worklet/Runtime running on this thread.


setOnFrameDroppedCallback(...)

setOnFrameDroppedCallback(onFrameDropped: 
  | ((reason: FrameDroppedReason) => void)
  | undefined): void

Adds a callback that gets called when a Frame has been dropped. This often happens if your Frame Callback is taking longer than a frame interval.

On this page