CameraFrameOutput

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

Every Frame must be disposed as soon as possible, see Frame's lifetime contract.

val frameOutput = VisionCamera.createFrameOutput(FrameOutputOptions(pixelFormat = TargetVideoPixelFormat.YUV))
frameOutput.setOnFrameCallback { frame ->
frame.use {
// processing...
}
}

See also

Properties

Link copied to clipboard
abstract val currentResolution: Size?

The resolution this output is currently streaming at, or null if it is not connected yet.

Link copied to clipboard
abstract val mediaType: MediaType

The MediaType of this output.

Link copied to clipboard

The orientation of the content produced by this output.

Link copied to clipboard
abstract val thread: NativeThread

The NativeThread the Frame callbacks run on.

Functions

Link copied to clipboard
open override fun close()

Same as dispose, to use a CameraOutput with use { }.

Link copied to clipboard
abstract fun dispose()

Eagerly disposes the native resources this output holds (its threads, analyzers, delegates, sounds...), like VisionCamera's HybridObject.dispose().

Link copied to clipboard
abstract fun setOnFrameCallback(onFrame: (frame: Frame) -> Unit?)

Sets the callback called on thread every time the Camera produces a new Frame, or removes it with null. The callback must dispose the Frame.

Link copied to clipboard
abstract fun setOnFrameDroppedCallback(onFrameDropped: (reason: FrameDroppedReason) -> Unit?)

Sets the callback called when a Frame has been dropped, often because the Frame callback takes longer than a frame interval, or removes it with null.