Fawkes API  Fawkes Development Version
firevision::VisionMaster Class Referenceabstract

Vision Master. More...

#include <>>

Inheritance diagram for firevision::VisionMaster:

Public Member Functions

virtual ~VisionMaster ()
 Virtual empty destructor. More...
 
virtual Cameraregister_for_camera (const char *camera_string, fawkes::Thread *thread, colorspace_t cspace=YUV422_PLANAR)=0
 Register thread for camera. More...
 
virtual Cameraregister_for_raw_camera (const char *camera_string, fawkes::Thread *thread)=0
 Register thread for camera. More...
 
virtual void unregister_thread (fawkes::Thread *thread)=0
 Unregister a thread. More...
 
virtual CameraControlacquire_camctrl (const char *cam_string)=0
 Retrieve a CameraControl for the specified camera string. More...
 
virtual void release_camctrl (CameraControl *cc)=0
 Release a camera control. More...
 
template<class CC >
CC * acquire_camctrl (const char *camera_string)
 Retrieve a typed camera control instance. More...
 
template<class CC >
CC * acquire_camctrl (const char *camera_string, CC *&cc)
 Retrieve a typed camera control instance. More...
 
template<class CC >
CC * register_for_raw_camera (const char *camera_string, fawkes::Thread *thread)
 Get typed raw camera. More...
 

Protected Member Functions

virtual CameraControlacquire_camctrl (const char *cam_string, const std::type_info &typeinf)=0
 Retrieve a CameraControl for the specified camera string and type info. More...
 

Detailed Description

Vision Master.

The vision master shall be the entry point for vision plugins. It shall allow for requesting cameras that are opened in a central place such that the very same camera can be used in multiple plugins.

It shall also be responsible for the central timing of all vision threads.

Author
Tim Niemueller

Definition at line 46 of file vision_master.h.

Constructor & Destructor Documentation

◆ ~VisionMaster()

firevision::VisionMaster::~VisionMaster ( )
virtual

Virtual empty destructor.

Definition at line 132 of file vision_master.cpp.

Member Function Documentation

◆ acquire_camctrl() [1/4]

CameraControl * firevision::VisionMaster::acquire_camctrl ( const char *  cam_string)
pure virtual

Retrieve a CameraControl for the specified camera string.

This control (if available) can be used to control certain aspects of the Camera. The cam_string argument either is the string that has been used to register for a particular camera, or it is a string denoting a camera control by itself. In the former case the vision master will look if the camera has been registered, and then checks if the camera provides a camera control. If so the control is returned. Note that it might implement multiple different camera controls. If you want a specific camera control use one of the template methods to get a correctly typed and verified control. If no camera that matches the cam_string is found, the vision master will try to instantiate a new camera control using the cam_string as argument to the CameraControlFactory.

Parameters
cam_stringCamera argument string, see method description for details
Returns
a pointer to the requested CameraControl.
Exceptions
Exceptionno camera was found matching the cam_string and the factory could not instantiate a camera control with the given string.

Implemented in FvBaseThread.

◆ acquire_camctrl() [2/4]

template<class CC >
CC * firevision::VisionMaster::acquire_camctrl ( const char *  camera_string)

Retrieve a typed camera control instance.

Like the non-template method this class will try to instantiate the camera control based on the camera string (see there for details on the two possible contents of the string). The camera control will be verified to be of the desired type.

Parameters
camera_stringcamera string of camera for the control or the argument string for a new instance. See documentation of non-template method.
Returns
typed camera control instance
Exceptions
TypeMismatchExceptionthrown if requested camera control does not match the requested type.

Definition at line 146 of file vision_master.h.

◆ acquire_camctrl() [3/4]

template<class CC >
CC * firevision::VisionMaster::acquire_camctrl ( const char *  camera_string,
CC *&  cc 
)

Retrieve a typed camera control instance.

Like the non-template method this class will try to instantiate the camera control based on the camera string (see there for details on the two possible contents of the string). The camera control will be verified to be of the desired type. Unlike the other template method you do not need to explicitly state the type of the requested type as it is inferred based on the cc argument. You can write something like this:

CameraControlImage *cci = vision_master->acquire_camctrl("camstring...", cci);

instead of

CameraControlImage *cci = vision_master->acquire_camctrl<CameraControlImage>("camstring...");
Parameters
camera_stringcamera string of camera for the control or the argument string for a new instance. See documentation of non-template method.
ccreference to pointer of camera control of the intended type, used to automatically infer the template method. On successful return points to the camera control instance
Returns
typed camera control instance (same as cc)
Exceptions
TypeMismatchExceptionthrown if requested camera control does not match the requested type.

Definition at line 128 of file vision_master.h.

◆ acquire_camctrl() [4/4]

CameraControl * firevision::VisionMaster::acquire_camctrl ( const char *  cam_string,
const std::type_info &  typeinf 
)
protectedpure virtual

Retrieve a CameraControl for the specified camera string and type info.

This utility method is used by the template methods to instantiate the cameras with a specified intended type.

Parameters
cam_stringCamera argument string, see method description for details
typeinftype info for intended camera control type
Returns
a pointer to the requested CameraControl.
Exceptions
Exceptionno camera was found matching the cam_string and the factory could not instantiate a camera control with the given string.

Implemented in FvBaseThread.

◆ register_for_camera()

Camera * firevision::VisionMaster::register_for_camera ( const char *  camera_string,
fawkes::Thread thread,
colorspace_t  cspace = YUV422_PLANAR 
)
pure virtual

Register thread for camera.

This will register a relation between the given thread and the camera identified by the camera string. If the requested camera has not been opened before this is done and the camera is started. If that fails for whatever reason an exception is thrown. In that case the thread is not registered with the vision master. If the camera is available the thread is registered with the vision master. From then on it is woken up whenever new image data is available and it will wait for the thread to finished computation on that very image. It is a critical error that can not be recovered if the thread fails for whatever reason. If there is a critical error condition in the vision thread it must not stop execution but just the computation.

Parameters
camera_stringcamera that can be used by CameraFactory to open a camera.
threadthread to register for this camera
cspacethe colorspace in which the images should be provided for the camera. Note that using images in different formats at the same time can cause a severe performance penalty. The default is to produce YUV422_PLANAR images, which is used in the FireVision framework as main image format.
Returns
a pointer to the requested camera. Note that this may not be of the C++ type that you may expect for the requested camera, but it may have layers of indirection. For example when opening a USB camera you could get a shared memory camera to share the camera (image) with multiple threads. Note that using CS_UNKNOWN shall have the similar result as using register_for_raw_camera().

Implemented in FvBaseThread.

Referenced by FvRetrieverThread::init().

◆ register_for_raw_camera() [1/2]

Camera * firevision::VisionMaster::register_for_raw_camera ( const char *  camera_string,
fawkes::Thread thread 
)
pure virtual

Register thread for camera.

This will register a relation between the given thread and the camera identified by the camera string similar to register_for_camera(). However, unlike register_for_camera() this method will provide access to the raw camera implementation, without possibly proxies. Once you gathered the camera, you can dynamically cast it to the expected camera type (or use the template method instead. Raw access to a camera is only granted for a single thread. Note that you may not call capture() or dispose() on the camera, this will still be done by the vision master, as the camera may be used by other threads that registered for the camera with register_for_camera().

Parameters
camera_stringcamera that can be used by CameraFactory to open a camera.
threadthread to register for this camera
Returns
raw camera instance, which can by dynamically casted to the expected type.

Implemented in FvBaseThread.

Referenced by FvSrSavePipelineThread::init().

◆ register_for_raw_camera() [2/2]

template<class CC >
CC * firevision::VisionMaster::register_for_raw_camera ( const char *  camera_string,
fawkes::Thread thread 
)

Get typed raw camera.

Like the non-template variant this method can be used to get access to the raw camera implementation, without going through a proxy. See the other method for risks and implication of using the raw device.

Parameters
camera_stringcamera that can be used by CameraFactory to open a camera.
threadthread to register for this camera
Returns
typed raw camera

Definition at line 162 of file vision_master.h.

◆ release_camctrl()

void firevision::VisionMaster::release_camctrl ( CameraControl cc)
pure virtual

Release a camera control.

This has to be called when you are done with the camera control. This will release the control and it is no longer valid. The vision master might collect the memory that has been used for the control.

Parameters
cccamera control instance to release

Implemented in FvBaseThread.

◆ unregister_thread()

void firevision::VisionMaster::unregister_thread ( fawkes::Thread thread)
pure virtual

Unregister a thread.

The thread is unregistered and it is removed from the internal structures. The thread is no longer called for new image material that can be processed.

If the unregistered thread was the last thread accessing the camera, it shall be held open for a specified time, such that if the thread is just being restarted the camera does not have to be re-opened. The time to wait is defined by the implementation.

Parameters
threadthread to unregister

Implemented in FvBaseThread.

Referenced by FvSrSavePipelineThread::finalize(), and FvRetrieverThread::finalize().


The documentation for this class was generated from the following files: