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
| Name | Type | Description |
|---|---|---|
filePath | string | The path to which the image is written |
Returns
void
setFormat
Set the format of the image stream.
setFormat(format: ImageFormat): void
Parameters
| Name | Type | Description |
|---|---|---|
format | ImageFormat | Format of the image |
Returns
void
setRotation
Set the rotation of the image stream.
setRotation(rotation: CameraRotation): void
Parameters
| Name | Type | Description |
|---|---|---|
rotation | CameraRotation | Rotation angle of the image |
Returns
void
createImageBitmap
Create a bitmap image from the stream.
createImageBitmap(isRotate?: boolean, scale?: number): ImageBitmap
Parameters
| Name | Type | Description |
|---|---|---|
isRotate | boolean | (Optional) Whether to rotate the image |
scale | number | (Optional) The scale of the image |
Returns
ImageBitmap- The created bitmap image
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
| Name | Type | Description |
|---|---|---|
buffer | ArrayBuffer | Raw pixel data |
width | number | Image width |
height | number | Image height |
Returns
void