Resource Base
Table of contents

ImageSourceAdapter

The ImageSourceAdapter class is an abstract class representing an adapter for image sources, providing a framework for fetching, buffering, and managing images from various sources. Implementations must provide specific mechanisms for image retrieval and handling.

Name Description
addImageToBuffer() Adds an image to the internal buffer.
clearBuffer() Clears all images from the buffer, resetting the state for new image fetching.
getBufferOverflowProtectionMode() Returns the current mode for handling buffer overflow situations.
getColourChannelUsageType() Retrieves the current usage type for color channels in images.
getImage() Returns a buffered image.
getImageCount() Retrieves the current number of images in the buffer.
getMaxImageCount() Returns the maximum number of images that can be buffered at any time.
hasImage() Checks if an image with the specified ID is present in the buffer.
hasNextImageToFetch() Determines whether there are more images available to fetch.
isBufferEmpty() Determines whether the buffer is currently empty.
setErrorListener() Sets an error listener to receive notifications about errors that occur during image source operations.
setBufferOverflowProtectionMode() Sets the behavior for handling new incoming images when the buffer is full.
setColourChannelUsageType() Sets the usage type for color channels in images.
setMaxImageCount() Sets the maximum number of images the buffer can hold.
setNextImageToReturn() Sets the processing priority of a specific image, affecting the order in which images are returned.
startFetching() Starts the process of fetching images.
stopFetching() Stops the process of fetching images.

addImageToBuffer

Adds an image to the internal buffer.

addImageToBuffer(image: DSImageData): void;

Parameters

image: The image to add to the buffer.

Return value

None.

clearBuffer

Clears all images from the buffer, resetting the state for new image fetching.

clearBuffer(): void;

Parameters

None.

Return value

None.

getBufferOverflowProtectionMode

Returns the current mode for handling buffer overflow situations.

getBufferOverflowProtectionMode(): EnumBufferOverflowProtectionMode;

Parameters

None.

Return value

The current buffer overflow protection mode.

See Also

EnumBufferOverflowProtectionMode

getColourChannelUsageType

Retrieves the current usage type for color channels in images.

getColourChannelUsageType(): EnumColourChannelUsageType;

Parameters

None.

Return value

The current usage type for color channels in images.

See Also

EnumColourChannelUsageType

getImage

Returns a buffered image.

getImage(): Promise<DSImageData>;

Parameters

None.

Return value

A promise that resolves with an instance of DSImageData.

getImageCount

Retrieves the current number of images in the buffer.

getImageCount(): number;

Parameters

None.

Return value

The actual count of buffered images.

getMaxImageCount

Returns the maximum number of images that can be buffered at any time.

getMaxImageCount(): number;

Parameters

None.

Return value

The maximum number of images that can be buffered.

hasImage

Checks if an image with the specified ID is present in the buffer.

hasImage(imageId: number): boolean;

Parameters

imageId: The ID of the image to check.

Return value

True if the image is in the buffer, false otherwise.

hasNextImageToFetch

Determines whether there are more images available to fetch. This is an abstract method that needs to be implemented by the user.

abstract hasNextImageToFetch(): boolean;

Parameters

None.

Return value

True if there are more images left to fetch, false otherwise.

isBufferEmpty

Determines whether the buffer is currently empty.

isBufferEmpty(): boolean;

Parameters

None.

Return value

True if the buffer is empty, false otherwise.

setErrorListener

Sets an error listener to receive notifications about errors that occur during image source operations. Implementing classes should invoke the listener’s onErrorReceived method with relevant error details when error occur.

setErrorListener: (listener: ImageSourceErrorListener) => void;

Parameters

listener: an instance of ImageSourceErrorListener or its derived class to handle error notifications.

Return value

None.

Code Snippet

cameraEnhancer.setErrorListener({
    onErrorReceived: (errorCode, errorMessage) => {
        console.log(errorMessage);
    },
});

See Also

ImageSourceErrorListener

setBufferOverflowProtectionMode

Sets the behavior for handling new incoming images when the buffer is full.

setBufferOverflowProtectionMode(mode: EnumBufferOverflowProtectionMode): void;

Parameters

mode: One of the modes defined in EnumBufferOverflowProtectionMode, specifying how to handle buffer overflow.

Return value

None.

See Also

EnumBufferOverflowProtectionMode

setColourChannelUsageType

Sets the usage type for color channels in images.

setColourChannelUsageType(type: EnumColourChannelUsageType): void;

Parameters

type: one of the types defined in EnumColourChannelUsageType, specifying how color channels should be used.

Return value

None.

See Also

EnumColourChannelUsageType

setMaxImageCount

Sets the maximum number of images the buffer can hold.

setMaxImageCount(count: number): void;

Parameters

count: The maximum number of images that can be buffered.

Return value

None.

setNextImageToReturn

Sets the processing priority of a specific image, affecting the order in which images are returned.

setNextImageToReturn(imageId: number, keepInBuffer?: boolean): void;

Parameters

imageId: The ID of the next image to return.

keepInBuffer: Optional. Whether the image should be kept in the buffer after it is returned.

Return value

None.

startFetching

Starts the process of fetching images.

startFetching(): void;

Parameters

None.

Return value

None.

stopFetching

Stops the process of fetching images.

stopFetching(): void;

Parameters

None.

Return value

None.

This page is compatible for:

Is this page helpful?

YesYes NoNo

In this article:

latest version

Change +