FrameConverter
interface FrameConverter extends HybridObjectThe FrameConverter can convert Frames
and Depth to Images, and back.
Methods
convertDepthToImage(...)
Converts the Depth frame to an Image.
The resulting Image will be a grey-scale RGB image,
where black pixels are far away, and white pixels are close by.
convertDepthToImageAsync(...)
convertFrameToImage(...)
Converts the given Frame to an Image.
This performs a CPU copy.
Throws
If the Frame is invalid (Frame.isValid).
convertFrameToImageAsync(...)
Asynchronously converts this Frame to an
Image.
This performs a CPU copy.
Throws
If the Frame is invalid (Frame.isValid).
convertImageToFrame(...)
convertImageToFrame(
image: Image,
orientation: CameraOrientation,
isMirrored: boolean): FrameConverts the given Image to a Frame,
as if the Camera had streamed it in the given orientation
and isMirrored mode.
This is the inverse of convertFrameToImage(...);
the Image's pixel data is physically rotated and mirrored so that
interpreting the resulting Frame with its
orientation and
isMirrored flags yields the original
upright Image again.
This performs a CPU copy.
The resulting Frame is in a CPU-accessible, camera-like
RGB PixelFormat ('rgb-bgra-8-bit'
on iOS, 'rgb-rgba-8-bit' on Android),
so the conversion is lossless.
Throws
If the Image has already been disposed, or its pixel data cannot be accessed.
Example
const image = await loadImage({ filePath: '...' })
const frame = HybridFrameConverter.convertImageToFrame(image, 'up', false)
console.log(`${frame.width}x${frame.height} ${frame.pixelFormat} Frame`)
// process the Frame, e.g. scan it for barcodes or resize it...
frame.dispose()convertImageToFrameAsync(...)
convertImageToFrameAsync(
image: Image,
orientation: CameraOrientation,
isMirrored: boolean): Promise<Frame>Asynchronously converts the given Image to a
Frame, as if the Camera had streamed it in the
given orientation and isMirrored mode.
This performs a CPU copy.
See
Throws
If the Image has already been disposed, or its pixel data cannot be accessed.