#include <acquisition_thread.h>
Inheritance diagram for FvAcquisitionThread:
Public Types | |
AqtCyclic | |
cyclic mode, use if there is at least one cyclic thread for this acquisition thread. | |
AqtContinuous | |
continuous mode, use if there are only continuous threads for this acquisition thread. | |
enum | AqtMode { AqtCyclic, AqtContinuous } |
Acquisition thread mode. More... | |
Public Member Functions | |
FvAcquisitionThread (const char *id, firevision::Camera *camera, fawkes::Logger *logger, fawkes::Clock *clock) | |
Constructor. | |
virtual | ~FvAcquisitionThread () |
Destructor. | |
virtual void | loop () |
Code to execute in the thread. | |
void | set_aqtmode (AqtMode mode) |
Set acquisition thread mode. | |
AqtMode | aqtmode () |
Get acquisition thread mode. | |
firevision::Camera * | camera_instance (firevision::colorspace_t cspace, bool deep_copy) |
Get a camera instance. | |
firevision::Camera * | get_camera () |
Get the Camera of this acquisition thread. | |
void | set_vt_prepfin_hold (bool hold) |
Set prepfin hold status for vision threads. | |
void | set_enabled (bool enabled) |
Enable or disable image retrieval. | |
Public Attributes | |
FvAqtVisionThreads * | vision_threads |
Vision threads assigned to this acquisition thread. | |
fawkes::Thread * | raw_subscriber_thread |
Vision thread registered for raw camera access on this camera. | |
Protected Member Functions | |
virtual void | run () |
Stub to see name in backtrace for easier debugging. |
This thread is used by the base application to acquire images from a camera and call dependant threads when new images are available so that these threads can start processing the images.
Definition at line 46 of file acquisition_thread.h.
Acquisition thread mode.
AqtCyclic | cyclic mode, use if there is at least one cyclic thread for this acquisition thread. |
AqtContinuous | continuous mode, use if there are only continuous threads for this acquisition thread. |
Definition at line 50 of file acquisition_thread.h.
FvAcquisitionThread::FvAcquisitionThread | ( | const char * | id, | |
firevision::Camera * | camera, | |||
fawkes::Logger * | logger, | |||
fawkes::Clock * | clock | |||
) |
Constructor.
logger | logger | |
id | id to be used for the shared memory segment and to announce changes to the base thread | |
camera | camera to manage | |
clock | clock to use for timeout measurement (system time) |
Definition at line 62 of file acquisition_thread.cpp.
References AqtContinuous, firevision::Camera::colorspace(), firevision::colorspace_to_string(), fawkes::Logger::log_debug(), fawkes::Thread::name(), firevision::Camera::pixel_height(), firevision::Camera::pixel_width(), raw_subscriber_thread, and vision_threads.
FvAcquisitionThread::~FvAcquisitionThread | ( | ) | [virtual] |
Destructor.
Definition at line 95 of file acquisition_thread.cpp.
References firevision::Camera::close(), and vision_threads.
FvAcquisitionThread::AqtMode FvAcquisitionThread::aqtmode | ( | ) |
Get acquisition thread mode.
Definition at line 218 of file acquisition_thread.cpp.
Camera * FvAcquisitionThread::camera_instance | ( | firevision::colorspace_t | cspace, | |
bool | deep_copy | |||
) |
Get a camera instance.
This will return a camera instance suitable for accessing the image buffer. Note, that this is not the camera provided to the constructor, but rather a SharedMemoryCamera instance accessing a shared memory buffer where the image is copied to (or a conversion result is posted to). The returned instance has to bee freed using delete when done with it.
You can decide whether you want to get access to the raw camera image that has not been modified in any way or to the YUV422_PLANAR image buffer (a conversion is done if needed). Use the raw parameter to decide whether to get the raw image (true) or the YUV422_PLANAR image (false).
When a thread is added it is internally put into a waiting queue. Since at the time when it is added the thread is not yet started, and its initialization may even fail. For this reason the acquisition thread registers itself to receive status notifications of the thread. If the thread signals successful startup it is moved to the running queue and from then on woken up when new image material can be processed. If the thread fails for whatever reason it is dropped.
The acquisition thread has a timeout. If no thread is in the running or waiting queue for this number of seconds, the base thread is signalled to shut down this acquisition thread (which the base thread may do or deny). This is done so that if a plugin is just unloaded shortly and then quickly loaded again the overhead of closing the camera and then opening it again is avoided.
cspace | the desired colorspace the image should be converted to. See general notes in VisionMaster::register_for_camera(). | |
deep_copy | given to the shared memory camera. |
Definition at line 139 of file acquisition_thread.cpp.
References firevision::CS_UNKNOWN, and raw_subscriber_thread.
Referenced by FvBaseThread::register_for_camera().
Camera * FvAcquisitionThread::get_camera | ( | ) |
Get the Camera of this acquisition thread.
This is just used for the camera controls, if you want to access the camera, use camera_instance()
Definition at line 176 of file acquisition_thread.cpp.
void FvAcquisitionThread::loop | ( | ) | [virtual] |
Code to execute in the thread.
Implement this method to hold the code you want to be executed continously. If you do not implement this method, the default is that the thread will exit. This is useful if you choose to only implement once().
Reimplemented from fawkes::Thread.
Definition at line 242 of file acquisition_thread.cpp.
References AqtCyclic, firevision::Camera::buffer(), firevision::Camera::capture(), firevision::Camera::capture_time(), firevision::convert(), firevision::CS_UNKNOWN, firevision::Camera::dispose_buffer(), fawkes::Logger::log_error(), fawkes::Thread::name(), fawkes::Thread::set_cancel_state(), vision_threads, and FvAqtVisionThreads::wakeup_and_wait_cyclic_threads().
virtual void FvAcquisitionThread::run | ( | ) | [inline, protected, virtual] |
Stub to see name in backtrace for easier debugging.
Reimplemented from fawkes::Thread.
Definition at line 81 of file acquisition_thread.h.
void FvAcquisitionThread::set_aqtmode | ( | AqtMode | mode | ) |
Set acquisition thread mode.
Note that this may only be called on a stopped thread or an exception will be thrown by Thread::set_opmode()!
mode | new acquisition thread mode |
Definition at line 188 of file acquisition_thread.cpp.
References AqtContinuous, AqtCyclic, and fawkes::Thread::set_opmode().
void FvAcquisitionThread::set_enabled | ( | bool | enabled | ) |
Enable or disable image retrieval.
When the acquisition thread is enabled image data will be converted or copied to the shared memory buffer, otherwise only the capture/dispose cycle is executed.
enabled | true to enable acquisition thread, false to disable |
Definition at line 208 of file acquisition_thread.cpp.
void FvAcquisitionThread::set_vt_prepfin_hold | ( | bool | hold | ) |
Set prepfin hold status for vision threads.
hold | prepfin hold status |
Definition at line 229 of file acquisition_thread.cpp.
References fawkes::Logger::log_warn(), fawkes::Thread::name(), FvAqtVisionThreads::set_prepfin_hold(), and vision_threads.
Vision thread registered for raw camera access on this camera.
Definition at line 78 of file acquisition_thread.h.
Referenced by camera_instance(), and FvAcquisitionThread().
Vision threads assigned to this acquisition thread.
To be used only by the base thread.
Definition at line 75 of file acquisition_thread.h.
Referenced by FvAcquisitionThread(), loop(), FvBaseThread::register_for_camera(), set_vt_prepfin_hold(), and ~FvAcquisitionThread().