The central class for camera grabbers in MRPT, implementing the "generic sensor" interface.
This class provides the user with a uniform interface to a variety of other classes which manage only one specific camera "driver" (opencv, ffmpeg, bumblebee,...)
Following the "generic sensor" interface, all the parameters must be passed int the form of a configuration file, which may be also formed on the fly (without being a real config file) as in this example:
Images can be retrieved through the normal "doProcess()" interface, or the specific method "getNextFrame()".
Some notes:
Images can be saved in the "external storage" mode. Detached threads are created for this task. See setPathForExternalImages() and setExternalImageFormat(). These methods are called automatically from the app rawlog-grabber.
These is the list of all accepted parameters:
Definition at line 245 of file CCameraSensor.h.
#include <mrpt/hwdrivers/CCameraSensor.h>
Public Types | |
typedef void(* | TPreSaveUserHook) (const mrpt::obs::CObservationPtr &obs, void *user_ptr) |
Functor type. More... | |
enum | TSensorState { ssInitializing = 0, ssWorking, ssError } |
The current state of the sensor. More... | |
typedef std::multimap< mrpt::system::TTimeStamp, mrpt::utils::CSerializablePtr > | TListObservations |
typedef std::pair< mrpt::system::TTimeStamp, mrpt::utils::CSerializablePtr > | TListObsPair |
Public Member Functions | |
CCameraSensor () | |
Constructor. More... | |
virtual | ~CCameraSensor () |
Destructor. More... | |
void | doProcess () |
This method will be invoked at a minimum rate of "process_rate" (Hz) More... | |
mrpt::obs::CObservationPtr | getNextFrame () |
Retrieves the next frame from the video source, raising an exception on any error. More... | |
void | getNextFrame (std::vector< mrpt::utils::CSerializablePtr > &out_obs) |
virtual void | initialize () |
Tries to open the camera, after setting all the parameters with a call to loadConfig. More... | |
void | close () |
Close the camera (if open). More... | |
void | setSoftwareTriggerLevel (bool level) |
Set Software trigger level value (ON or OFF) for cameras with this function available. More... | |
virtual void | setPathForExternalImages (const std::string &directory) |
Set the path where to save off-rawlog image files (this class DOES take into account this path). More... | |
void | enableLaunchOwnThreadForSavingImages (bool enable=true) |
This must be called before initialize() More... | |
void | addPreSaveHook (TPreSaveUserHook user_function, void *user_ptr) |
Provides a "hook" for user-code to be run BEFORE an image is going to be saved to disk if external storage is enabled (e.g. More... | |
virtual const mrpt::hwdrivers::TSensorClassId * | GetRuntimeClass () const =0 |
TSensorState | getState () const |
The current state of the sensor. More... | |
double | getProcessRate () const |
std::string | getSensorLabel () const |
void | setSensorLabel (const std::string &sensorLabel) |
void | enableVerbose (bool enabled=true) |
Enable or disable extra debug info dumped to std::cout during sensor operation. More... | |
bool | isVerboseEnabled () const |
void | loadConfig (const mrpt::utils::CConfigFileBase &configSource, const std::string §ion) |
Loads the generic settings common to any sensor (See CGenericSensor), then call to "loadConfig_sensorSpecific". More... | |
void | getObservations (TListObservations &lstObjects) |
Returns a list of enqueued objects, emptying it (thread-safe). More... | |
void | setExternalImageFormat (const std::string &ext) |
Set the extension ("jpg","gif","png",...) that determines the format of images saved externally The default is "jpg". More... | |
void | setExternalImageJPEGQuality (const unsigned int quality) |
The quality of JPEG compression, when external images is enabled and the format is "jpg". More... | |
unsigned int | getExternalImageJPEGQuality () const |
Static Public Member Functions | |
static void | printf_debug (const char *frmt,...) |
Sends a formated text to "debugOut" if not NULL, or to cout otherwise. More... | |
static void | registerClass (const TSensorClassId *pNewClass) |
Register a class into the internal list of "CGenericSensor" descendents. More... | |
static CGenericSensor * | createSensor (const std::string &className) |
Creates a sensor by a name of the class. More... | |
static CGenericSensorPtr | createSensorPtr (const std::string &className) |
Just like createSensor, but returning a smart pointer to the newly created sensor object. More... | |
Protected Member Functions | |
void | loadConfig_sensorSpecific (const mrpt::utils::CConfigFileBase &configSource, const std::string &iniSection) |
See the class documentation at the top for expected parameters. More... | |
void | appendObservations (const std::vector< mrpt::utils::CSerializablePtr > &obj) |
This method must be called by derived classes to enqueue a new observation in the list to be returned by getObservations. More... | |
void | appendObservation (const mrpt::utils::CSerializablePtr &obj) |
Like appendObservations() but for just one observation. More... | |
Stuff related to working threads to save images to disk | |
unsigned int | m_external_image_saver_count |
Number of working threads. Default:1, set to 2 in quad cores. More... | |
std::vector< mrpt::system::TThreadHandle > | m_threadImagesSaver |
bool | m_threadImagesSaverShouldEnd |
mrpt::synch::CCriticalSection | m_csToSaveList |
The critical section for m_toSaveList. More... | |
std::vector< TListObservations > | m_toSaveList |
The queues of objects to be returned by getObservations, one for each working thread. More... | |
TPreSaveUserHook | m_hook_pre_save |
void * | m_hook_pre_save_param |
void | thread_save_images (unsigned int my_working_thread_index) |
Thread to save images to files. More... | |
|
inherited |
Definition at line 68 of file CGenericSensor.h.
|
inherited |
Definition at line 69 of file CGenericSensor.h.
typedef void(* mrpt::hwdrivers::CCameraSensor::TPreSaveUserHook) (const mrpt::obs::CObservationPtr &obs, void *user_ptr) |
Functor type.
Definition at line 292 of file CCameraSensor.h.
|
inherited |
The current state of the sensor.
Enumerator | |
---|---|
ssInitializing | |
ssWorking | |
ssError |
Definition at line 74 of file CGenericSensor.h.
mrpt::hwdrivers::CCameraSensor::CCameraSensor | ( | ) |
Constructor.
The camera is not open until "initialize" is called.
|
virtual |
Destructor.
|
inline |
Provides a "hook" for user-code to be run BEFORE an image is going to be saved to disk if external storage is enabled (e.g.
to rectify images, preprocess them, etc.) Notice that this code may be called from detached threads, so it must be thread safe. If used, call this before initialize()
Definition at line 297 of file CCameraSensor.h.
|
inlineprotectedinherited |
Like appendObservations() but for just one observation.
Definition at line 146 of file CGenericSensor.h.
|
protectedinherited |
This method must be called by derived classes to enqueue a new observation in the list to be returned by getObservations.
Passed objects must be created in dynamic memory and a smart pointer passed. Example of creation:
If several observations are passed at once in the vector, they'll be considered as a block regarding the grabbing decimation factor.
void mrpt::hwdrivers::CCameraSensor::close | ( | ) |
Close the camera (if open).
This method is called automatically on destruction.
|
staticinherited |
Creates a sensor by a name of the class.
Typically the user may want to create a smart pointer around the returned pointer, whis is made with:
|
inlinestaticinherited |
Just like createSensor, but returning a smart pointer to the newly created sensor object.
Definition at line 179 of file CGenericSensor.h.
References mrpt::hwdrivers::CGenericSensor.
|
virtual |
This method will be invoked at a minimum rate of "process_rate" (Hz)
This | method must throw an exception with a descriptive message if some critical error is found. |
Implements mrpt::hwdrivers::CGenericSensor.
|
inline |
This must be called before initialize()
Definition at line 289 of file CCameraSensor.h.
|
inlineinherited |
Enable or disable extra debug info dumped to std::cout during sensor operation.
Default: disabled unless the environment variable "MRPT_HWDRIVERS_VERBOSE" is set to "1" during object creation.
Definition at line 92 of file CGenericSensor.h.
|
inlineinherited |
Definition at line 233 of file CGenericSensor.h.
References MRPT_MAKE_ALIGNED_OPERATOR_NEW.
mrpt::obs::CObservationPtr mrpt::hwdrivers::CCameraSensor::getNextFrame | ( | ) |
Retrieves the next frame from the video source, raising an exception on any error.
Note: The returned observations can be of one of these classes (you can use IS_CLASS(obs,CObservationXXX) to determine it):
void mrpt::hwdrivers::CCameraSensor::getNextFrame | ( | std::vector< mrpt::utils::CSerializablePtr > & | out_obs | ) |
|
inherited |
Returns a list of enqueued objects, emptying it (thread-safe).
The objects must be freed by the invoker.
|
inlineinherited |
Definition at line 84 of file CGenericSensor.h.
|
pure virtualinherited |
|
inlineinherited |
Definition at line 86 of file CGenericSensor.h.
|
inlineinherited |
The current state of the sensor.
Definition at line 82 of file CGenericSensor.h.
|
virtual |
Tries to open the camera, after setting all the parameters with a call to loadConfig.
This | method must throw an exception with a descriptive message if some critical error is found. |
Reimplemented from mrpt::hwdrivers::CGenericSensor.
|
inlineinherited |
Definition at line 93 of file CGenericSensor.h.
References mrpt::utils::registerClass().
|
inherited |
Loads the generic settings common to any sensor (See CGenericSensor), then call to "loadConfig_sensorSpecific".
This | method throws an exception with a descriptive message if some critical parameter is missing or has an invalid value. |
|
protectedvirtual |
See the class documentation at the top for expected parameters.
Implements mrpt::hwdrivers::CGenericSensor.
|
staticinherited |
Sends a formated text to "debugOut" if not NULL, or to cout otherwise.
Referenced by mrpt::math::CLevenbergMarquardtTempl< VECTORTYPE, USERPARAM >::execute().
|
staticinherited |
Register a class into the internal list of "CGenericSensor" descendents.
Used internally in the macros DEFINE_GENERIC_SENSOR, etc...
Can be used as "CGenericSensor::registerClass( SENSOR_CLASS_ID(CMySensor) );" if building custom sensors outside mrpt libraries in user code.
Referenced by mrpt::hwdrivers::CGenericSensor::CLASSINIT_GENERIC_SENSOR::CLASSINIT_GENERIC_SENSOR().
|
inlineinherited |
Set the extension ("jpg","gif","png",...) that determines the format of images saved externally The default is "jpg".
Definition at line 225 of file CGenericSensor.h.
|
inlineinherited |
The quality of JPEG compression, when external images is enabled and the format is "jpg".
Definition at line 230 of file CGenericSensor.h.
|
virtual |
Set the path where to save off-rawlog image files (this class DOES take into account this path).
An empty string (the default value at construction) means to save images embedded in the rawlog, instead of on separate files.
std::exception | If the directory doesn't exists and cannot be created. |
Reimplemented from mrpt::hwdrivers::CGenericSensor.
|
inlineinherited |
Definition at line 87 of file CGenericSensor.h.
void mrpt::hwdrivers::CCameraSensor::setSoftwareTriggerLevel | ( | bool | level | ) |
Set Software trigger level value (ON or OFF) for cameras with this function available.
|
private |
Thread to save images to files.
|
protected |
Definition at line 319 of file CCameraSensor.h.
|
protected |
Definition at line 321 of file CCameraSensor.h.
|
protected |
Definition at line 320 of file CCameraSensor.h.
|
private |
Definition at line 394 of file CCameraSensor.h.
|
private |
Definition at line 395 of file CCameraSensor.h.
|
private |
The bumblebee capture object.
Definition at line 383 of file CCameraSensor.h.
|
private |
The OpenCV capture object.
Definition at line 379 of file CCameraSensor.h.
|
private |
The dc1394 capture object.
Definition at line 380 of file CCameraSensor.h.
|
private |
The DUO3D capture object.
Definition at line 391 of file CCameraSensor.h.
|
private |
The FFMPEG capture object.
Definition at line 385 of file CCameraSensor.h.
|
private |
The FlyCapture2 object.
Definition at line 381 of file CCameraSensor.h.
|
private |
Definition at line 382 of file CCameraSensor.h.
|
private |
The FlyCapture2 object for stereo pairs.
Definition at line 382 of file CCameraSensor.h.
|
private |
Read images from directory.
Definition at line 390 of file CCameraSensor.h.
|
private |
Kinect camera object.
Definition at line 388 of file CCameraSensor.h.
|
private |
OpenNI2 object.
Definition at line 389 of file CCameraSensor.h.
|
private |
The input file for rawlogs.
Definition at line 386 of file CCameraSensor.h.
|
private |
The svs capture object.
Definition at line 384 of file CCameraSensor.h.
|
private |
SR 3D camera object.
Definition at line 387 of file CCameraSensor.h.
|
protected |
Definition at line 304 of file CCameraSensor.h.
|
private |
The critical section for m_toSaveList.
Definition at line 406 of file CCameraSensor.h.
|
protected |
Definition at line 307 of file CCameraSensor.h.
|
protected |
Definition at line 308 of file CCameraSensor.h.
|
protected |
Definition at line 309 of file CCameraSensor.h.
|
protected |
Definition at line 312 of file CCameraSensor.h.
|
protected |
Definition at line 313 of file CCameraSensor.h.
|
protected |
Definition at line 314 of file CCameraSensor.h.
|
protected |
Definition at line 367 of file CCameraSensor.h.
|
private |
Number of working threads. Default:1, set to 2 in quad cores.
Definition at line 402 of file CCameraSensor.h.
|
protectedinherited |
The extension ("jpg","gif","png",...) that determines the format of images saved externally.
Definition at line 130 of file CGenericSensor.h.
|
protectedinherited |
For JPEG images, the quality (default=95%).
Definition at line 131 of file CGenericSensor.h.
|
protected |
Whether to launch independent thread.
Definition at line 370 of file CCameraSensor.h.
|
protected |
Definition at line 353 of file CCameraSensor.h.
|
protected |
Definition at line 328 of file CCameraSensor.h.
|
protected |
Definition at line 350 of file CCameraSensor.h.
|
protected |
Definition at line 354 of file CCameraSensor.h.
|
protectedinherited |
If set to N>=2, only 1 out of N observations will be saved to m_objList.
Definition at line 117 of file CGenericSensor.h.
|
protectedinherited |
Used when "m_grab_decimation" is enabled.
Definition at line 122 of file CGenericSensor.h.
|
protected |
Can be "opencv",...
Definition at line 303 of file CCameraSensor.h.
|
private |
Definition at line 410 of file CCameraSensor.h.
|
private |
Definition at line 411 of file CCameraSensor.h.
|
protected |
Definition at line 364 of file CCameraSensor.h.
|
protected |
Definition at line 361 of file CCameraSensor.h.
|
protected |
Definition at line 363 of file CCameraSensor.h.
|
protected |
Definition at line 358 of file CCameraSensor.h.
|
protected |
Definition at line 359 of file CCameraSensor.h.
|
protected |
Definition at line 360 of file CCameraSensor.h.
|
protected |
Definition at line 357 of file CCameraSensor.h.
|
protected |
Save the 3D point cloud (default: true)
Definition at line 344 of file CCameraSensor.h.
|
protected |
Save the 2D intensity image (default: true)
Definition at line 346 of file CCameraSensor.h.
|
protected |
Save the 2D range image (default: true)
Definition at line 345 of file CCameraSensor.h.
|
protected |
Save RGB or IR channels (default:true)
Definition at line 347 of file CCameraSensor.h.
|
protectedinherited |
See CGenericSensor.
Definition at line 116 of file CGenericSensor.h.
|
protectedinherited |
The path where to save off-rawlog images: empty means save images embedded in the rawlog.
Definition at line 129 of file CGenericSensor.h.
|
private |
Definition at line 397 of file CCameraSensor.h.
|
protected |
Definition at line 315 of file CCameraSensor.h.
|
protected |
Definition at line 316 of file CCameraSensor.h.
|
private |
Definition at line 398 of file CCameraSensor.h.
|
private |
Normally we'll use only one window, but for stereo images we'll use two of them.
Definition at line 398 of file CCameraSensor.h.
|
protectedinherited |
See CGenericSensor.
Definition at line 115 of file CGenericSensor.h.
|
protected |
Definition at line 332 of file CCameraSensor.h.
|
protected |
Definition at line 333 of file CCameraSensor.h.
|
protected |
Definition at line 331 of file CCameraSensor.h.
|
protectedinherited |
See CGenericSensor.
Definition at line 118 of file CGenericSensor.h.
|
protected |
Definition at line 297 of file CCameraSensor.h.
|
protected |
Definition at line 337 of file CCameraSensor.h.
|
protected |
true: USB, false: ETH
Definition at line 336 of file CCameraSensor.h.
|
protected |
Save the 3D point cloud (default: true)
Definition at line 338 of file CCameraSensor.h.
|
protected |
Save the estimated confidence 2D image (default: false)
Definition at line 341 of file CCameraSensor.h.
|
protected |
Save the 2D intensity image (default: true)
Definition at line 340 of file CCameraSensor.h.
|
protected |
Save the 2D range image (default: true)
Definition at line 339 of file CCameraSensor.h.
|
protectedinherited |
Definition at line 124 of file CGenericSensor.h.
|
protected |
Definition at line 324 of file CCameraSensor.h.
|
protected |
Definition at line 325 of file CCameraSensor.h.
|
private |
Definition at line 403 of file CCameraSensor.h.
|
private |
Definition at line 405 of file CCameraSensor.h.
|
private |
The queues of objects to be returned by getObservations, one for each working thread.
Definition at line 407 of file CCameraSensor.h.
|
protectedinherited |
Definition at line 125 of file CGenericSensor.h.
Page generated by Doxygen 1.8.12 for MRPT 1.3.2 SVN: at Mon Oct 3 19:22:36 UTC 2016 |