Image Input
An IO class for image input sources, can be synchronous or asynchronous.
Constructor
Section titled “Constructor”ImageIn
Section titled “ImageIn”Creates a new synchronous ImageIn object instance.
ImageIn(options)ImageIn.Async
Section titled “ImageIn.Async”Creates a new asynchronous ImageIn object instance.
ImageIn.Async(options)Parameters
Section titled “Parameters”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 theDisplay 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.
Instance Properties
Section titled “Instance Properties”Includes properties of the IO Class Pattern. Specific to this class:
imageType
Section titled “imageType”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.
height
Section titled “height”A number indicating the image’s pixel height. This property is read-only.
format
Section titled “format”Either "buffer/disposable" or "buffer".
Instance Methods
Section titled “Instance Methods”Returns Byte Buffer data from the IO instance.
read(byteLength)read(buffer)
read(byteLength, callbackFn)read(buffer, callbackFn)Parameters
Section titled “Parameters”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.
Return value
Section titled “Return value”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)Parameters
Section titled “Parameters”options
An optional object with a single defined property:
flush- A boolean value. Iftrue, any unread frames should be flushed immediately. Iffalse, the unread frames may still be read after callingstop.
Callbacks
Section titled “Callbacks”onReadable
Section titled “onReadable”Invoked when a new frame is available to be read.
onReadable(byteLength)Parameters
Section titled “Parameters”byteLength
The size of the frame in bytes.
Examples
Section titled “Examples”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();