Skip to main content

Image

The Image class can contain any type of image, with many possible datatypes. It is derived from the VisionElement base class.

Constructors

Empty constructor. Creates an invalid image.

new Image(): Image;

Create a valid image initialized with a uniform initial value.

new Image(width: number, height: number, pixelformat: EPixelFormat, values?: number[]): Image;

Create a valid image initialized with external data.

new Image(width: number, height: number, pixelformat: EPixelFormat, data: ArrayBuffer): Image;

Methods

pixelformat()

Returns the pixel format of the image, as an enum value. See EPixelFormat for possible values.

pixelformat(): EPixelFormat;

width()

Returns the width of the image.

width(): number;

height()

Returns the height of the image.

height(): number;

setFrame()

Sets a new frame on the image, will throw if not valid.

setFrame(frame: Rect2d): void;

getFrame()

Returns a copy of the image frame.

getFrame(): Rect2d;

setFrame()

Sets a new frame on the image, will throw if not valid.

setFrame(frame: Rect2d): void;

resetFrame()

Set frame size equal full image size.

resetFrame(): void;

byteSize()

Returns the size of the image data in bytes.

byteSize(): number;

numPixels()

Returns the number of pixels in the image.

numPixels(): number;

numChannels()

Returns the number of channels in the image.

numChannels(): number;

bytesPerPixel()

Returns the number of bytes per pixel of the current pixel format.

bytesPerPixel(): number;

bitsPerPixel()

Returns the number of bits per pixel of the current pixel format.

bytesPerPixel(): number;

depth()

Returns the depth of the image's pixel format. See EPixelDepth for possible values.

depth(): EPixelDepth;

copyBuffer()

Returns a copy of the raw data as an array buffer that can be cast into a data view depending on the underlying type of the image

copyBuffer(): ArrayBuffer;

isValid()

Returns true if the data contained in the image represents a valid image

isValid(): boolean;

Props

timestamp

The timestamp of the image in nanoseconds. This is useful for images captured by a camera, where this field is set to the time the image was captured.

timestamp: number;

opacity

The opacity of the image, from 0 to 1. This will affect the transparency of the image when displayed.

opacity: number;

color

The color of the image. This is a string in the format #RRGGBB. Where RR, GG, and BB are the red, green, and blue components of the color, respectively. This will affect the color of the image when displayed in some display modes. See display.

color: string;

display

The display mode of the image determines how the image will be displayed. It is a read/write enum value. See EImageDisplay for possible values.

display: EImageDisplay;

normalize

The normalize mode of the image determines how the image will be normalized before it is displayed. The normalization doesn't affect the image data, only the way it is displayed. It is a read/write enum value. See EImageNormalize for possible values.

normalize: EImageNormalize;

normalizeMin

The minimum value for normalization. This is used when the normalize prop is set to Manual.

normalizeMin: number;

normalizeMax

The maximum value for normalization. This is used when the normalize prop is set to Manual.

normalizeMax: number;

pixelformatStr

Auxiliary read-only pixel format as a string, for debugging purposes

pixelformatStr: string;