MRPT logo

mrpt::hwdrivers::CCameraSensor Class Reference

The central class for camera grabbers in MRPT, implementing the "generic sensor" interface. More...

#include <mrpt/hwdrivers/CCameraSensor.h>

Inheritance diagram for mrpt::hwdrivers::CCameraSensor:

mrpt::utils::CDebugOutputCapable mrpt::hwdrivers::CGenericSensor mrpt::utils::CUncopiable

List of all members.

Public Member Functions

 CCameraSensor ()
 Constructor The camera is not open until "initialize" is called.
virtual ~CCameraSensor ()
 Destructor.
void doProcess ()
 This method should be called periodically (at least at 1Hz to capture ALL the real-time data) It is thread safe, i.e.
mrpt::slam::CObservationPtr getNextFrame ()
 Retrieves the next frame from the video source, raising an exception on any error.
void loadConfig (const mrpt::utils::CConfigFileBase &configSource, const std::string &iniSection)
 Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes) See hwdrivers::CCameraSensor for the possible parameters.
virtual void initialize ()
 Tries to open the camera, after setting all the parameters with a call to loadConfig.
void close ()
 Close the camera (if open).
void setPathForExternalImages (const std::string &directory)
 Set the path where to save off-rawlog images: empty (default) means save images embedded in the rawlog.
void setExternalImageFormat (const std::string &ext)
 Set the extension ("jpg","gif","png",.

Protected Attributes

poses::CPose3D m_sensorPose
std::string m_sensorLabel
std::string m_grabber_type
 Can be "opencv",...
bool m_capture_grayscale
int m_cv_camera_index
std::string m_cv_camera_type
mrpt::vision::TCaptureCVOptions m_cv_options
uint64_t m_dc1394_camera_guid
int m_dc1394_camera_unit
mrpt::vision::TCaptureOptions_dc1394 m_dc1394_options
int m_preview_decimation
int m_bumblebee_camera_index
mrpt::vision::TCaptureOptions_bumblebee m_bumblebee_options
int m_bumblebee_monocam
std::string m_ffmpeg_url
std::string m_rawlog_file
std::string m_rawlog_camera_sensor_label
std::string m_path_for_external_images
 The path where to save off-rawlog images: empty means save images embedded in the rawlog.
std::string m_external_images_format
 The extension ("jpg","gif","png",...) that determines the format of images saved externally.

Private Attributes

mrpt::vision::CImageGrabber_OpenCVm_cap_cv
 The OpenCV capture object.
mrpt::vision::CImageGrabber_dc1394m_cap_dc1394
 The dc1394 capture object.
mrpt::vision::CStereoGrabber_Bumblebeem_cap_bumblebee
 The bumblebee capture object.
CFFMPEG_InputStreamm_cap_ffmpeg
 The FFMPEG capture object.
mrpt::utils::CFileGZInputStreamm_cap_rawlog
 The input file for rawlogs.
int m_preview_counter
mrpt::gui::CDisplayWindowm_preview_win


Detailed Description

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:

   CCameraSensor myCam;
   string str = "[CONFIG]\n grabber_type=opencv \n";
   CConfigFileMemory    cfg(str);
   myCam.loadConfig(cfg,"CONFIG");

Images can be retrieves through the normal "doProcess()" interface, or the specific method "getNextFrame()".

These is the list of all the accepted parameters:

  PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
 -------------------------------------------------------
   [supplied_section_name]
    // Select one of the grabber implementations:
    grabber_type       = opencv | dc1394 | bumblebee | ffmpeg | rawlog
    preview_decimation = 0     // N<=0 : No preview; N>0, display 1 out of N captured frames.
    capture_grayscale  = 0     // 1:capture in grayscale, whenever the driver allows it.

    // Options for grabber_type= opencv
    cv_camera_index  = 0       // [opencv] Number of camera to open
    cv_camera_type   = CAMERA_CV_AUTODETECT
    cv_frame_width   = 640     // [opencv] Capture width (not present or set to 0 for default)
    cv_frame_height  = 480     // [opencv] Capture height (not present or set to 0 for default)
    cv_fps           = 15      // [opencv] IEEE1394 cams only: Capture FPS (not present or 0 for default)
    cv_gain          = 0       // [opencv] Camera gain, if available (nor present or set to 0 for default).

    // Options for grabber_type= dc1394
    dc1394_camera_guid   = 0 | 0x11223344    // 0 (or not present): the first camera; A hexadecimal number: The GUID of the camera to open
    dc1394_camera_unit   = 0                            // 0 (or not present): the first camera; 0,1,2,...: The unit number (within the given GUID) of the camera to open (Stereo cameras: 0 or 1)
    dc1394_frame_width  = 640
    dc1394_frame_height = 480
    dc1394_framerate            = 15                                    // eg: 7.5, 15, 30, 60, etc... For posibilities see mrpt::vision::TCaptureOptions_dc1394
    dc1394_mode7         = -1                    // -1: Ignore, i>=0, set to MODE7_i
    dc1394_color_coding = COLOR_CODING_YUV422   // For posibilities see mrpt::vision::TCaptureOptions_dc1394
    dc1394_shutter              = -1    // A value, or -1 (or not present) for not to change this parameter in the camera
    dc1394_gain                 = -1    // A value, or -1 (or not present) for not to change this parameter in the camera
    dc1394_gamma                        = -1    // A value, or -1 (or not present) for not to change this parameter in the camera
    dc1394_brightness   = -1    // A value, or -1 (or not present) for not to change this parameter in the camera
    dc1394_exposure             = -1    // A value, or -1 (or not present) for not to change this parameter in the camera
    dc1394_sharpness            = -1    // A value, or -1 (or not present) for not to change this parameter in the camera
    dc1394_white_balance        = -1    // A value, or -1 (or not present) for not to change this parameter in the camera

    // Options for grabber_type= bumblebee
    bumblebee_camera_index  = 0       // [bumblebee] Number of camera within the firewire bus to open (typically = 0)
    bumblebee_frame_width   = 640     // [bumblebee] Capture width (not present or set to 0 for default)
    bumblebee_frame_height  = 480     // [bumblebee] Capture height (not present or set to 0 for default)
    bumblebee_fps           = 15      // [bumblebee] Capture FPS (not present or 0 for default)
    bumblebee_mono          = 0|1     // [bumblebee] OPTIONAL: If this parameter is present, monocular (0:left, 1:right) images will be grabbed instead of stereo pairs.
    bumblebee_get_rectified = 0|1     // [bumblebee] Determines if the camera should grab rectified or raw images (1 is the default)

    // Options for grabber_type= ffmpeg
    ffmpeg_url             = rtsp://127.0.0.1      // [ffmpeg] The video file or IP camera to open

    // Options for grabber_type= rawlog
    rawlog_file            = mylog.rawlog          // [rawlog] This can be used to simulate the capture of images already grabbed in the past in the form of a MRPT rawlog.
    rawlog_camera_sensor_label  = CAMERA1          // [rawlog] If this field is not present, all images found in the rawlog will be retrieved. Otherwise, only those observations with a matching sensor label.

    // Pose of the sensor on the robot:
    pose_x=0            ; (meters)
    pose_y=0
    pose_z=0
    pose_yaw=0  ; (Angles in degrees)
    pose_pitch=0
    pose_roll=0

Images can be saved in the "external storage" mode. See setPathForExternalImages and setExternalImageFormat. These methods are called automatically from rawlog-grabber.

Note:
The execution rate (in rawlog-grabber) should be greater than the required capture FPS.

In Linux you may need to execute "chmod 666 /dev/video1394/ * " and "chmod 666 /dev/raw1394" for allowing any user R/W access to firewire cameras.

See also:
mrpt::vision::CImageGrabber_OpenCV, mrpt::vision::CImageGrabber_dc1394, CGenericSensor, prepareVideoSourceFromUserSelection

Definition at line 133 of file CCameraSensor.h.


Constructor & Destructor Documentation

mrpt::hwdrivers::CCameraSensor::CCameraSensor (  ) 

Constructor The camera is not open until "initialize" is called.

virtual mrpt::hwdrivers::CCameraSensor::~CCameraSensor (  )  [virtual]

Destructor.


Member Function Documentation

void mrpt::hwdrivers::CCameraSensor::close (  ) 

Close the camera (if open).

This method is called automatically on destruction.

void mrpt::hwdrivers::CCameraSensor::doProcess (  )  [virtual]

This method should be called periodically (at least at 1Hz to capture ALL the real-time data) It is thread safe, i.e.

you can call this from one thread, then to other methods from other threads.rip

Implements mrpt::hwdrivers::CGenericSensor.

mrpt::slam::CObservationPtr mrpt::hwdrivers::CCameraSensor::getNextFrame (  ) 

Retrieves the next frame from the video source, raising an exception on any error.

Note:
The observations can be of the classes CObservationImage or CObservationStereoImages

virtual void mrpt::hwdrivers::CCameraSensor::initialize (  )  [virtual]

Tries to open the camera, after setting all the parameters with a call to loadConfig.

Exceptions:
This method must throw an exception with a descriptive message if some critical error is found.

Reimplemented from mrpt::hwdrivers::CGenericSensor.

void mrpt::hwdrivers::CCameraSensor::loadConfig ( const mrpt::utils::CConfigFileBase configSource,
const std::string &  iniSection 
) [virtual]

Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes) See hwdrivers::CCameraSensor for the possible parameters.

Implements mrpt::hwdrivers::CGenericSensor.

void mrpt::hwdrivers::CCameraSensor::setExternalImageFormat ( const std::string &  ext  )  [inline]

Set the extension ("jpg","gif","png",.

..) that determines the format of images saved externally The default is "jpg".

See also:
setPathForExternalImages

Definition at line 185 of file CCameraSensor.h.

void mrpt::hwdrivers::CCameraSensor::setPathForExternalImages ( const std::string &  directory  ) 

Set the path where to save off-rawlog images: empty (default) means save images embedded in the rawlog.

Exceptions:
std::exception If the directory cannot be created


Member Data Documentation

Definition at line 205 of file CCameraSensor.h.

Definition at line 207 of file CCameraSensor.h.

Definition at line 206 of file CCameraSensor.h.

The bumblebee capture object.

Definition at line 225 of file CCameraSensor.h.

The OpenCV capture object.

Definition at line 219 of file CCameraSensor.h.

The dc1394 capture object.

Definition at line 222 of file CCameraSensor.h.

The FFMPEG capture object.

Definition at line 228 of file CCameraSensor.h.

The input file for rawlogs.

Definition at line 231 of file CCameraSensor.h.

Definition at line 195 of file CCameraSensor.h.

Definition at line 196 of file CCameraSensor.h.

Definition at line 197 of file CCameraSensor.h.

Definition at line 198 of file CCameraSensor.h.

Definition at line 200 of file CCameraSensor.h.

Definition at line 201 of file CCameraSensor.h.

Definition at line 202 of file CCameraSensor.h.

The extension ("jpg","gif","png",...) that determines the format of images saved externally.

See also:
setPathForExternalImages

Definition at line 215 of file CCameraSensor.h.

Definition at line 209 of file CCameraSensor.h.

Can be "opencv",...

Definition at line 194 of file CCameraSensor.h.

The path where to save off-rawlog images: empty means save images embedded in the rawlog.

Definition at line 214 of file CCameraSensor.h.

Definition at line 233 of file CCameraSensor.h.

Definition at line 203 of file CCameraSensor.h.

Definition at line 234 of file CCameraSensor.h.

Definition at line 212 of file CCameraSensor.h.

Definition at line 211 of file CCameraSensor.h.

Definition at line 192 of file CCameraSensor.h.

Definition at line 191 of file CCameraSensor.h.




Page generated by Doxygen 1.5.9 for MRPT 0.7.1 SVN: at Mon Aug 17 22:32:05 EDT 2009