Skip to content

Image Input

An IO class for image input sources, can be synchronous or asynchronous.

Creates a new synchronous ImageIn object instance.

ImageIn(options)

Creates a new asynchronous ImageIn object instance.

ImageIn.Async(options)

options

An object of properties used to construct the class.

imageType - A value indicating the encoding of the image. If the value is a number, the image is uncompressed in a pixel format defined by the Display Class Pattern. If the value is a string, the allowed value is "jpeg". This property is optional and defaults to a host defined value.

width - A number indicating the requested pixel width of the captured image. This property is optional and defaults to a host defined value.

height - A number indicating the requested pixel height of the captured image. This property is optional and defaults to a host defined value.

onReadable (optional) - A callback function invoked when a new frame is available to be read.

Includes properties of the IO Class Pattern. Specific to this class:

A number or string indicating the image encoding. This property is read-only.

A number indicating the image’s pixel width. This property is read-only.

A number indicating the image’s pixel height. This property is read-only.

Either "buffer/disposable" or "buffer".

Returns Byte Buffer data from the IO instance.

read(byteLength)
read(buffer)
read(byteLength, callbackFn)
read(buffer, callbackFn)

byteLength

The number of bytes to read into the returned Byte Buffer.

buffer

A pre-allocated Byte Buffer for the instance to fill.

callbackFn

callbackFn(error, buffer)
callbackFn(error, byteLength)

For asynchronous classes, a function that executes when the data has been read.

When the data format is "buffer/disposable", the read method returns one frame in a Disposable Buffer.

Begins capturing images.

start()

Suspends image capture.

stop(options)

options

An optional object with a single defined property:

flush - A boolean value. If true, any unread frames should be flushed immediately. If false, the unread frames may still be read after calling stop.

Invoked when a new frame is available to be read.

onReadable(byteLength)

byteLength

The size of the frame in bytes.

import ImageIn from "embedded:io/image/in";
const camera = new ImageIn({
width: 640,
height: 480,
imageType: "jpeg",
onReadable(byteLength) {
const frame = this.read(byteLength);
// process image frame
}
});
camera.start();

Image Input - synchronous IO

Image Input - asynchronous IO