CVBpy 15.0
ImageStreamHandler Class Reference

Handler object for multiple synchronous streams. More...

Inherits object.

Public Member Functions

None finish (self)
 Stop the handler. More...
 
None handle_async_stream (self, List[cvb.ImageStream] stream_list)
 Asynchronously called for all registered streams. More...
 
None handle_async_wait_result (self, List[Tuple[cvb.MultiPartImage, int, cvb.NodeMapEnumerator]] wait_result_list)
 Asynchronously called for all acquired images. More...
 
bool handle_error (self, Type[Exception] type, Exception value, Any traceback)
 Asynchronously called for all acquired images. More...
 
None run (self)
 Start the handler. More...
 
None setup (self, cvb.ImageStream streams)
 Setup the stream for acquisition. More...
 
None tear_down (self, cvb.ImageStream stream)
 Tear down the stream after acquisition. More...
 
bool try_finish (self)
 Stop the handler. More...
 

Properties

 is_active = property
 bool: Check if the acquisition thread is running.
 

Detailed Description

Handler object for multiple synchronous streams.

This handler provides a convenient way to acquire deliverables such as images from multiple synchronous streams within a dedicated native thread. All streams for this handler must be synchronous (exactly the same frame rate). If this is not the case you will loose images. Please be aware, that there is no way for the application to verify, that the steams are synchronized. For multiple devices usually an external electrical synchronization mechanism is provided.

Create a stream handler object.

Parameters

stream_list : List[cvb.ImageStream] List with synchronous streams.

Member Function Documentation

◆ finish()

None finish (   self)

Stop the handler.

This will stop the acquisition thread and call tear_down() on the calling thread. This blocks until the acquisition thread has finished, so blocking in a customized handle_async_wait_result() method can lead to deadlocks.

If the acquisition handler is destroyed it automatically finishes.

If an error occurred during acquisition this method will rethrow it.

◆ handle_async_stream()

None handle_async_stream (   self,
List[cvb.ImageStream stream_list 
)

Asynchronously called for all registered streams.

The default implementation just waits for the next image on each stream.

This method is called from a dedicated thread!

Parameters

stream_list : List[cvb.ImageStream] List with synchronous streams (provided at creation).

◆ handle_async_wait_result()

None handle_async_wait_result (   self,
List[Tuple[cvb.MultiPartImage, int, cvb.NodeMapEnumerator]]  wait_result_list 
)

Asynchronously called for all acquired images.

The default implementation does nothing.

This method is called from a dedicated thread!

Parameters

wait_result_list : List[Tuple[cvb.MultiPartImage, int, cvb.NodeMapEnumerator]] List with synchronous acquired WaitResults (see cvb.WaitStatus).

◆ handle_error()

bool handle_error (   self,
Type[Exception]  type,
Exception  value,
Any  traceback 
)

Asynchronously called for all acquired images.

This handler is called for all not explicitly handled standard exception in the acquisition thread. After the handler returned the acquisition thread may finish, but remain in the active state. Be aware that this handler is by default called from the native acquisition thread.

After this handler there will be no automatic call to tear_down(). So you have to call finish() explicitly. If you reimplemented this handler you should return True for all errors you do not want to deliver to the controlling thread. Calling finish() will raise the last delivered error. You may not raise another error but you may call try_finish() to stop the handler.

Parameters

type : Type[Exception] Type of the exception.

value : Exception The value of the exception.

traceback : Any The traceback if available.

Returns

bool True if the error could be handled False (default) if the error should be handled later.

◆ run()

None run (   self)

Start the handler.

This will call setup() on the calling thread, before creating a dedicated native acquisition thread. The acquisition thread will repeatedly call handle_async_wait_result().

◆ setup()

None setup (   self,
cvb.ImageStream  streams 
)

Setup the stream for acquisition.

The default implementation just calls Stream.start().

Parameters

streams : cvb.ImageStream Stream to handle (provided at creation).

◆ tear_down()

None tear_down (   self,
cvb.ImageStream  stream 
)

Tear down the stream after acquisition.

The default implementation just calls Stream.try_abort().

Parameters

stream : cvb.ImageStream Stream to handle (provided at creation).

◆ try_finish()

bool try_finish (   self)

Stop the handler.

This will stop the acquisition thread and call tear_down() on the calling thread. This blocks until the acquisition thread has finished, so blocking in a customized handle_async_wait_result() method can lead to deadlocks.

If the acquisition handler is destroyed it automatically finishes.

Returns

bool True if no error occurred in the acquisition thread, otherwise.