Skip to main content

ImageStream

Interface for handling image stream operations. Provides functionality for image stream manipulation and conversion.

interface ImageStream {
writeImageToFile(filePath: string): void;
setFormat(format: ImageFormat): void;
setRotation(rotation: CameraRotation): void;
createImageBitmap(isRotate?: boolean, scale?: number): ImageBitmap;
}

Methods

writeImageToFile

Decode the image from ImageStream and store it to a disk path.

writeImageToFile(filePath: string): void

Parameters

NameTypeDescription
filePathstringThe path to which the image is written

Returns

  • void

setFormat

Set the format of the image stream.

setFormat(format: ImageFormat): void

Parameters

NameTypeDescription
formatImageFormatFormat of the image

Returns

  • void

setRotation

Set the rotation of the image stream.

setRotation(rotation: CameraRotation): void

Parameters

NameTypeDescription
rotationCameraRotationRotation angle of the image

Returns

  • void

createImageBitmap

Create a bitmap image from the stream.

createImageBitmap(isRotate?: boolean, scale?: number): ImageBitmap

Parameters

NameTypeDescription
isRotateboolean(Optional) Whether to rotate the image
scalenumber(Optional) The scale of the image

Returns


setBuffer

Set the raw buffer for the image stream (zero-copy). Use with an empty stream created via createEmptyImageStream() for per-frame video processing to avoid allocating a new stream each frame.

setBuffer(buffer: ArrayBuffer, width: number, height: number): void

Parameters

NameTypeDescription
bufferArrayBufferRaw pixel data
widthnumberImage width
heightnumberImage height

Returns

  • void