Resource Base
Table of contents

ImageSourceAdapter

The ImageSourceAdapter class provides an class for fetching and buffering images. It is an abstract class that needs to be implemented by a concrete class to provide actual functionality.

Note: Subclasses inheriting from this class must ensure that the parent class constructor (super().__init__()) is properly called to guarantee correct initialization.

Definition

Module: dynamsoft_core

class ImageSourceAdapter(ABC) 

Methods

Method Description
add_image_to_buffer Adds an image to the buffer of the adapter.
has_next_image_to_fetch Determines whether there are more images left to fetch.
start_fetching Starts fetching images.
stop_fetching Stops fetching images.
get_image Returns a buffered image.
set_max_image_count Sets how many images are allowed to be buffered.
get_max_image_count Returns how many images can be buffered.
set_buffer_overflow_protection_mode Sets a mode that determines the action to take when there is a new incoming image and the buffer is full.
get_buffer_overflow_protection_mode Returns the current buffer overflow protection mode.
has_image Determines whether the image is in the buffer or not.
set_next_image_to_return Sets the next image to return.
get_image_count Returns the actual count of buffered images.
is_buffer_empty Determines whether the buffer is empty.
clear_buffer Clears the image buffer.
set_colour_channel_usage_type Sets the usage type of a color channel in an image.
get_colour_channel_usage_type Gets the usage type of a color channel in an image.
set_error_listener Sets the error listener for the image source.

add_image_to_buffer

Adds an image to the buffer of the adapter.

def add_image_to_buffer(self, image: ImageData) -> None:

Parameters

image The image to be added to the buffer.

See Also

ImageData

has_next_image_to_fetch

Determines whether there are more images left to fetch.

@abstractmethod
def has_next_image_to_fetch(self) -> bool:

Return Value

Returns true if there are more images left to fetch, false otherwise. This function must be implemented in the subclass.

start_fetching

Starts fetching images.

def start_fetching(self) -> None:

stop_fetching

Stops fetching images.

def stop_fetching(self) -> None:

get_image

Returns a buffered image.

def get_image(self) -> ImageData:

Return Value

Returns an image if it exists in the buffer, null otherwise.

See Also

ImageData

set_max_image_count

Sets how many images are allowed to be buffered.

def set_max_image_count(self, count: int) -> None:

Parameters

count The maximum number of images that can be buffered.

get_max_image_count

Returns how many images can be buffered.

def get_max_image_count(self) -> int:

Return Value

Returns the maximum number of images that can be buffered.

set_buffer_overflow_protection_mode

Sets a mode that determines the action to take when there is a new incoming image and the buffer is full.

def set_buffer_overflow_protection_mode(self, mode: int) -> None:

Parameters

mode The buffer overflow protection mode to set.

See Also

EnumBufferOverflowProtectionMode

get_buffer_overflow_protection_mode

Returns the current buffer overflow protection mode.

def get_buffer_overflow_protection_mode(self) -> int:

Return Value

Returns the current buffer overflow protection mode.

See Also

EnumBufferOverflowProtectionMode

has_image

Determines whether the image is in the buffer or not.

def has_image(self, image_id: int) -> bool:

Parameters

image_id The ID of the image to check.

Return Value

Returns true if the image is in the buffer, false otherwise.

set_next_image_to_return

Sets the next image to return.

def set_next_image_to_return(self, image_id: int, keep_in_buffer: bool = True) -> bool:

Parameters

image_id The ID of the next image to return.

keep_in_buffer Whether the image should be retained in the buffer, even if the buffer is full and the image needs to be updated based on the BufferOverflowProtectionMode parameter.

Return Value

Returns true if the image is in the buffer and is set as the next image to return, false otherwise.

get_image_count

Returns the actual count of buffered images.

def get_image_count(self) -> int:

Return Value

Returns the actual count of buffered images.

is_buffer_empty

Determines whether the buffer is empty.

def is_buffer_empty(self) -> bool:

Return Value

Returns true if the buffer is empty, false otherwise.

clear_buffer

Clear the image buffer.

def clear_buffer(self) -> None:

set_colour_channel_usage_type

Sets the usage type of a color channel in images.

def set_colour_channel_usage_type(self, type: int) -> None:

Parameters

type The usage type of a color channel in images to set.

See Also

EnumColourChannelUsageType

get_colour_channel_usage_type

Gets the usage type of a color channel in images.

def get_colour_channel_usage_type(self) -> int:

Return Value

Returns the usage type of a color channel in images.

See Also

EnumColourChannelUsageType

set_error_listener

This function allows you to set an error listener object that will receive notifications when errors occur during image source operations. If an error occurs, the error infomation will be passed to the listener’s on_error_received method.

def set_error_listener(self, listener: ImageSourceErrorListener) -> None:

Parameters

listener Specifies a listening object of the type ImageSourceErrorListener, which will handle error notifications.

See Also

ImageSourceErrorListener

This page is compatible for:

Is this page helpful?

YesYes NoNo

In this article:

latest version

    Change +