Main MRPT website > C++ reference for MRPT 1.5.7
CDUO3DCamera.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #include "hwdrivers-precomp.h" // Precompiled headers
11 
12 #include <mrpt/system/os.h>
13 #include <mrpt/system/filesystem.h>
15 
16 #include <mrpt/otherlibs/do_opencv_includes.h>
17 
18 // We must define & store OpenCV-specific data like this in the .cpp, we don't want to force users to need opencv headers:
19 struct TDUOParams
20 {
21 #if MRPT_HAS_OPENCV
26 #endif
27 };
28 std::map<const mrpt::hwdrivers::TCaptureOptions_DUO3D*,TDUOParams> duo_params;
29 
30 // duo3d header files
31 #if MRPT_HAS_DUO3D
32 # include <DUOLib.h>
33 #endif
34 
35 // m_duo: Opaque pointer to DUO3D's "DUOInstance":
36 #define M_DUO_PTR ( reinterpret_cast<DUOInstance*>(m_duo))
37 #define M_DUO_VALUE (*M_DUO_PTR)
38 
39 
40 using namespace std;
41 using namespace mrpt;
42 using namespace mrpt::math;
43 using namespace mrpt::utils;
44 using namespace mrpt::poses;
45 using namespace mrpt::obs;
46 using namespace mrpt::hwdrivers;
47 
48 // opencv header files and namespaces
49 #if MRPT_HAS_OPENCV
50  using namespace cv;
51 #endif
52 
53 TCaptureOptions_DUO3D::TCaptureOptions_DUO3D() :
54  m_img_width(640),
55  m_img_height(480),
56  m_fps(30),
57  m_exposure(50),
58  m_led(25),
59  m_gain(0),
60  m_capture_imu(false),
61  m_capture_rectified(false),
62  m_calibration_from_file(true),
63  m_rectify_map_filename(""),
64  m_intrinsic_filename(""),
65  m_extrinsic_filename(""),
66  m_stereo_camera(TStereoCamera())
67 {
68  duo_params[this]; // Create
69 }
70 
72 {
73  duo_params.erase(this);// Remove entry
74 }
75 
77 {
78 #if MRPT_HAS_OPENCV
79  const string file_name = _file_name.empty() ? m_rectify_map_filename : _file_name;
80 
81  TDUOParams & dp = duo_params[this];
82 
83  string aux = mrpt::system::extractFileName( file_name );
84  const size_t found = aux.find( mrpt::format("_R%dx%d_",this->m_img_width,this->m_img_height) );
85  if( found == std::string::npos )
86  {
90  dp.m_rectify_map_right_y = cv::Mat();
92  }
93  // read file
94  FileStorage fs( file_name , FileStorage::READ);
95  fs["R0X"] >> dp.m_rectify_map_left_x;
96  fs["R0Y"] >> dp.m_rectify_map_left_y;
97  fs["R1X"] >> dp.m_rectify_map_right_x;
98  fs["R1Y"] >> dp.m_rectify_map_right_y;
99 
100  if( dp.m_rectify_map_left_x.size() == Size(0,0) || dp.m_rectify_map_left_y.size() == Size(0,0) ||
101  dp.m_rectify_map_right_x.size() == Size(0,0) || dp.m_rectify_map_right_y.size() == Size(0,0) )
102  return yrr_EMPTY;
103 
104  return yrr_OK;
105 #else
106  THROW_EXCEPTION("This function requires building with OpenCV support")
107 #endif
108 }
109 
111 {
112 #if MRPT_HAS_OPENCV
113  const string file_name = _file_name.empty() ? m_extrinsic_filename : _file_name;
114 
115  // this will look for R and t matrixes
116  cv::Mat aux_mat;
117  bool empty = false;
118  string aux = mrpt::system::extractFileName( file_name );
119  const size_t found = aux.find( mrpt::format("_R%dx%d_",this->m_img_width,this->m_img_height) );
120  if( found == std::string::npos )
121  {
124  }
125  // read file
126  FileStorage fs( file_name , FileStorage::READ);
127  CMatrixDouble33 M;
129  CMatrixDouble44 M2;
130 
131  // rotation matrix
132  fs["R"] >> aux_mat;
133  if( aux_mat.size() == Size(3,3) )
134  {
135  for(size_t k1 = 0; k1 < 3; ++k1)
136  for(size_t k2 = 0; k2 < 3; ++k2)
137  M(k1,k2) = aux_mat.at<double>(k1,k2);
138  }
139  else
140  {
141  empty = true;
143  }
144 
145  // translation
146  fs["T"] >> aux_mat;
147  if( aux_mat.size() == Size(1,3) )
148  {
149  t(0,0) = aux_mat.at<double>(0,0)/1000.0;
150  t(0,1) = aux_mat.at<double>(1,0)/1000.0;
151  t(0,2) = aux_mat.at<double>(2,0)/1000.0;
152  }
153  else
154  {
155  empty = true;
157  }
158 
159  if( empty ) return yrr_EMPTY;
160 
162  return yrr_OK;
163 #else
164  THROW_EXCEPTION("This function requires building with OpenCV support")
165 #endif
166 }
167 
169 {
170 #if MRPT_HAS_OPENCV
171  const string file_name = _file_name.empty() ? m_intrinsic_filename : _file_name;
172 
173  // this will look for M1, D1, M2 and D2 matrixes
174  cv::Mat aux_mat;
175  bool empty = false;
176  string aux = mrpt::system::extractFileName( file_name );
177  const size_t found = aux.find( mrpt::format("_R%dx%d_",this->m_img_width,this->m_img_height) );
178  if( found == std::string::npos )
179  {
184 
186  }
187  // read file
188  FileStorage fs( file_name , FileStorage::READ);
189 
190  // left camera
191  fs["M1"] >> aux_mat;
192  if( aux_mat.size() == Size(0,0) )
193  {
194  empty = true;
196  }
197  m_stereo_camera.leftCamera.setIntrinsicParamsFromValues( aux_mat.at<double>(0,0), aux_mat.at<double>(1,1), aux_mat.at<double>(0,2), aux_mat.at<double>(1,2) );
198 
199  fs["D1"] >> aux_mat;
200  if( aux_mat.size() == Size(0,0) )
201  {
202  empty = true;
204  }
205  m_stereo_camera.leftCamera.setDistortionParamsFromValues( aux_mat.at<double>(0,0), aux_mat.at<double>(0,1), aux_mat.at<double>(0,2), aux_mat.at<double>(0,3), aux_mat.at<double>(0,4) );
206 
207  fs["M2"] >> aux_mat;
208  if( aux_mat.size() == Size(0,0) )
209  {
210  empty = true;
212  }
213  m_stereo_camera.rightCamera.setIntrinsicParamsFromValues( aux_mat.at<double>(0,0), aux_mat.at<double>(1,1), aux_mat.at<double>(0,2), aux_mat.at<double>(1,2) );
214 
215  fs["D2"] >> aux_mat;
216  if( aux_mat.size() == Size(0,0) )
217  {
218  empty = true;
220  }
221  m_stereo_camera.rightCamera.setDistortionParamsFromValues( aux_mat.at<double>(0,0), aux_mat.at<double>(0,1), aux_mat.at<double>(0,2), aux_mat.at<double>(0,3), aux_mat.at<double>(0,4) );
222 
223  return empty ? yrr_EMPTY : yrr_OK;
224 #else
225  THROW_EXCEPTION("This function requires building with OpenCV support")
226 #endif
227 }
228 
230  const mrpt::utils::CConfigFileBase & configSource,
231  const std::string & iniSection,
232  const std::string & prefix )
233 {
234  m_img_width = configSource.read_int(iniSection,"image_width",m_img_width);
235  m_img_height = configSource.read_int(iniSection,"image_height",m_img_height);
236 
237  m_fps = configSource.read_float(iniSection,"fps",m_fps);
238  m_exposure = configSource.read_float(iniSection,"exposure",m_exposure);
239  m_led = configSource.read_float(iniSection,"led",m_led);
240  m_gain = configSource.read_float(iniSection,"gain",m_gain);
241 
242  m_capture_rectified = configSource.read_bool(iniSection,"capture_rectified",m_capture_rectified);
243  m_capture_imu = configSource.read_bool(iniSection,"capture_imu",m_capture_imu);
244  m_calibration_from_file = configSource.read_bool(iniSection,"calibration_from_file",m_calibration_from_file);
245 
247  {
248  m_intrinsic_filename = configSource.read_string(iniSection,"intrinsic_filename", m_intrinsic_filename);
249  m_extrinsic_filename = configSource.read_string(iniSection,"extrinsic_filename", m_extrinsic_filename);
252  }
253  else
254  m_stereo_camera.loadFromConfigFile( "DUO3D", configSource );
255 
256  if( m_capture_rectified )
257  {
258  m_rectify_map_filename = configSource.read_string(iniSection,"rectify_map_filename", m_rectify_map_filename);
259  } // end-capture-rectified
260 }
261 
262 #if MRPT_HAS_DUO3D
263 static void CALLBACK DUOCallback(const PDUOFrame pFrameData, void *pUserData)
264 {
265  CDUO3DCamera* obj = static_cast<CDUO3DCamera*>(pUserData);
266  obj->setDataFrame( reinterpret_cast<void*>(pFrameData) );
267  SetEvent( reinterpret_cast<HANDLE>( obj->getEvent() ) );
268 }
269 #endif
270 
271 /** Default constructor. */
273  m_options(TCaptureOptions_DUO3D()),
274  m_duo(NULL)
275 {
276 #if MRPT_HAS_DUO3D
277  m_duo = new DUOInstance[1];
278  M_DUO_VALUE = NULL; // m_duo = NULL;
279 
280  m_pframe_data = NULL;
281  m_evFrame = CreateEvent(NULL, FALSE, FALSE, NULL);
282 #else
283  THROW_EXCEPTION("MRPT has been compiled with 'MRPT_BUILD_DUO3D'=OFF, so this class cannot be used.");
284 #endif
285 } // end-constructor
286 
287 /** Custom initialization and start grabbing constructor. */
289  m_duo(NULL)
290 {
291 #if MRPT_HAS_DUO3D
292  m_duo = new DUOInstance[1];
293  M_DUO_VALUE = NULL; // m_duo = NULL;
294 
295  m_pframe_data = NULL;
296  m_evFrame = CreateEvent(NULL, FALSE, FALSE, NULL);
297  this->open( options );
298 #else
299  THROW_EXCEPTION("MRPT has been compiled with 'MRPT_BUILD_DUO3D'=OFF, so this class cannot be used.");
300 #endif
301 } // end-constructor
302 
303 /** Destructor */
305 {
306 #if MRPT_HAS_DUO3D
307  this->close();
308  if (m_duo) { delete[] M_DUO_PTR; m_duo=NULL;}
309 #endif
310 } // end-destructor
311 
312 /** Tries to open the camera with the given options. Raises an exception on error. \sa close() */
313 void CDUO3DCamera::open( const TCaptureOptions_DUO3D & options, const bool startCapture )
314 {
315 #if MRPT_HAS_DUO3D
316  if( M_DUO_VALUE ) this->close();
317  this->m_options = options;
318 
320  {
321  // get intrinsic parameters
324  cout << "[CDUO3DCamera] Warning: Some of the intrinsic params could not be read (size=0). Check file content." << endl;
326  cout << "[CDUO3DCamera] Warning: Intrinsic params filename is not consistent with image size. Are you using the correct calibration?. All params set to zero." << endl;
327 
328  // get extrinsic parameters
331  cout << "[CDUO3DCamera] Warning: Some of the extrinsic params could not be read (size!=3x3). Check file content." << endl;
333  cout << "[CDUO3DCamera] Warning: Extrinsic params filename is not consistent with image size. Are you using the correct calibration?. All params set to zero." << endl;
334 
335  if( this->m_options.m_capture_rectified )
336  {
337  if( !this->m_options.m_rectify_map_filename.empty() )
338  {
339  // read "rectify_map"
340  res = this->m_options.m_rectify_map_from_yml();
342  cout << "[CDUO3DCamera] Warning: Rectification map could not be read (size==0). Check file content." << endl;
344  cout << "[CDUO3DCamera] Warning: Rectification map filename is not consistent with image size. Are you using the correct calibration?. Rectification map set to zero." << endl;
345 
347 
348  //const size_t area = this->m_options.dp.m_rectify_map_left_x.size().area();
349  TDUOParams & dp = duo_params[&(this->m_options)];
350  const size_t area = dp.m_rectify_map_left_x.size().area();
351  vector<int16_t> v_left_x(area), v_right_x(area);
352  vector<uint16_t> v_left_y(area), v_right_y(area);
353 
354  for( size_t k = 0; k < area; ++k )
355  {
356  v_left_x[k] = dp.m_rectify_map_left_x.at<int16_t>(k);
357  v_left_y[k] = dp.m_rectify_map_left_y.at<uint16_t>(k);
358  v_right_x[k] = dp.m_rectify_map_right_x.at<int16_t>(k);
359  v_right_y[k] = dp.m_rectify_map_right_y.at<uint16_t>(k);
360 
361  //v_left_x[k] = this->m_options.dp.m_rectify_map_left_x.at<int16_t>(k);
362  //v_left_y[k] = this->m_options.dp.m_rectify_map_left_y.at<uint16_t>(k);
363  //v_right_x[k] = this->m_options.dp.m_rectify_map_right_x.at<int16_t>(k);
364  //v_right_y[k] = this->m_options.dp.m_rectify_map_right_y.at<uint16_t>(k);
365  }
367  //m_rectify_map.setRectifyMaps( v_left_x, v_left_y, v_right_x, v_right_y );
368  }
369  else
370  {
371  cout << "[CDUO3DCamera] Warning: Calibration information is set to be read from a file, but the file was not specified. Unrectified images will be grabbed." << endl;
372  }
373  } // end-if
374  } // end-if
375  else if( this->m_options.m_capture_rectified )
376  {
378  }
379 
380  // Find optimal binning parameters for given (width, height)
381  // This maximizes sensor imaging area for given resolution
382  int binning = DUO_BIN_NONE;
383  if(this->m_options.m_img_width <= 752/2)
384  binning += DUO_BIN_HORIZONTAL2;
385  if(this->m_options.m_img_height <= 480/4)
386  binning += DUO_BIN_VERTICAL4;
387  else if(this->m_options.m_img_height <= 480/2)
388  binning += DUO_BIN_VERTICAL2;
389 
390  // Check if we support given resolution (width, height, binning, fps)
391  DUOResolutionInfo ri;
392  if(!EnumerateResolutions(&ri, 1, this->m_options.m_img_width, this->m_options.m_img_height, binning, this->m_options.m_fps))
393  THROW_EXCEPTION( "[CDUO3DCamera] Error: Resolution not supported." )
394 
395  if(!OpenDUO(& M_DUO_VALUE )) // was: m_duo
396  THROW_EXCEPTION( "[CDUO3DCamera] Error: Camera could not be opened." )
397 
398  // Get and print some DUO parameter values
399  char name[260], version[260];
400  GetDUODeviceName(M_DUO_VALUE,name);
401  GetDUOFirmwareVersion(M_DUO_VALUE,version);
402  cout << "[CDUO3DCamera::open] DUO3DCamera name: " << name << " (v" << version << ")" << endl;
403 
404  // Set selected resolution
405  SetDUOResolutionInfo(M_DUO_VALUE,ri);
406 
407  // Set selected camera settings
408  SetDUOExposure(M_DUO_VALUE,m_options.m_exposure);
409  SetDUOGain(M_DUO_VALUE,m_options.m_gain);
410  SetDUOLedPWM(M_DUO_VALUE,m_options.m_led);
411 
412  // Start capture
413  if( startCapture )
414  {
415  if(!StartDUO(M_DUO_VALUE, DUOCallback, reinterpret_cast<void*>(this)))
416  THROW_EXCEPTION( "[CDUO3DCamera] Error: Camera could not be started." )
417  }
418 
419 #endif
420 } // end-open
421 
422 /*-------------------------------------------------------------
423  getObservations
424 -------------------------------------------------------------*/
426  CObservationStereoImages & outObservation_img,
427  CObservationIMU & outObservation_imu,
428  bool & there_is_img,
429  bool & there_is_imu )
430 {
431 #if MRPT_HAS_DUO3D
432  there_is_img = false;
433  there_is_imu = false;
434 
436  if(!m_pframe_data) return;
437 
438  // -----------------------------------------------
439  // Extract the observation:
440  // -----------------------------------------------
441  outObservation_img.timestamp = outObservation_imu.timestamp = mrpt::system::now();
442 
443  outObservation_img.setStereoCameraParams(m_options.m_stereo_camera);
444  outObservation_img.imageLeft.loadFromMemoryBuffer(
447  false,
448  (unsigned char*)reinterpret_cast<PDUOFrame>(m_pframe_data)->leftData);
449 
450  outObservation_img.imageRight.loadFromMemoryBuffer(
453  false,
454  (unsigned char*)reinterpret_cast<PDUOFrame>(m_pframe_data)->rightData);
455 
456  if( this->m_options.m_capture_rectified )
457  m_rectify_map.rectify( outObservation_img );
458 
459  there_is_img = true;
460 
461  if( this->m_options.m_capture_imu )
462  {
463  if( !reinterpret_cast<PDUOFrame>(m_pframe_data)->accelerometerPresent )
464  {
465  cout << "[CDUO3DCamera] Warning: This device does not provide IMU data. No IMU observations will be created." << endl;
466  this->m_options.m_capture_imu = false;
467  }
468  else
469  {
470  // Accelerometer data
471  for(size_t k = 0; k < 3; ++k)
472  {
473  outObservation_imu.rawMeasurements[k] = reinterpret_cast<PDUOFrame>(m_pframe_data)->accelData[k];
474  outObservation_imu.dataIsPresent[k] = true;
475  }
476 
477  // Gyroscopes data
478  for(size_t k = 0; k < 3; ++k)
479  {
480  outObservation_imu.rawMeasurements[k+3] = reinterpret_cast<PDUOFrame>(m_pframe_data)->gyroData[k];
481  outObservation_imu.dataIsPresent[k+3] = true;
482  }
483  there_is_imu = true;
484  }// end else
485  } // end-imu-info
486 #endif
487 }
488 
489 /** Closes DUO camera */
491 {
492 #if MRPT_HAS_DUO3D
493  if( !M_DUO_VALUE ) return;
494  StopDUO( M_DUO_VALUE );
495  CloseDUO( M_DUO_VALUE );
496  M_DUO_VALUE = NULL;
497 #endif
498 } // end-close
499 
500 // Waits until the new DUO frame is ready and returns it
502 {
503 #if MRPT_HAS_DUO3D
504  if( M_DUO_VALUE == NULL ) return 0;
505  if(WaitForSingleObject( m_evFrame, 1000 ) == WAIT_OBJECT_0) return m_pframe_data;
506  else return NULL;
507 #else
508  return NULL; // return something to silent compiler warnings.
509 #endif
510 }
511 
513 {
514 #if MRPT_HAS_DUO3D
515  if( M_DUO_VALUE == NULL ) return;
516  SetDUOExposure( M_DUO_VALUE, value );
517 #endif
518 }
519 
521 {
522 #if MRPT_HAS_DUO3D
523  if( M_DUO_VALUE == NULL ) return;
524  SetDUOGain( M_DUO_VALUE, value );
525 #endif
526 }
527 
529 {
530 #if MRPT_HAS_DUO3D
531  if( M_DUO_VALUE == NULL ) return;
532  SetDUOLedPWM( M_DUO_VALUE, value );
533 #endif
534 }
535 
536 /** Queries the DUO3D Camera firmware version */
537 bool CDUO3DCamera::queryVersion(std::string version, bool printOutVersion)
538 {
539 #if MRPT_HAS_DUO3D
540  version = std::string(GetLibVersion());
541  if( printOutVersion ) std::cout << "DUO3D Camera library version: " << version << std::endl;
542  return true;
543 #else
544  return false;
545 #endif
546 }
bool queryVersion(std::string version, bool printOutVersion=false)
Queries the DUO3D Camera firmware version.
EIGEN_STRONG_INLINE bool empty() const
float m_fps
(Default = 30) Frames per second <= 30.
Definition: CDUO3DCamera.h:36
bool read_bool(const std::string &section, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
GLdouble GLdouble t
Definition: glext.h:3610
std::string m_intrinsic_filename
Intrinsic parameters file provided by DUO3D Calibration App (YML format).
Definition: CDUO3DCamera.h:52
unsigned __int16 uint16_t
Definition: rptypes.h:46
mrpt::utils::CImage imageLeft
Image from the left camera (this image will be ALWAYS present)
cv::Mat m_rectify_map_left_y
This "software driver" implements the communication protocol for interfacing a DUO3D Stereo Camera...
Definition: CDUO3DCamera.h:125
std::vector< double > rawMeasurements
The accelerometer and/or gyroscope measurements taken by the IMU at the given timestamp.
void * m_get_duo_frame()
Gets a stereo frame from the DUO3D Camera (void* to be reinterpreted as PDUOFrame) ...
float read_float(const std::string &section, const std::string &name, float defaultValue, bool failIfNotFound=false) const
void m_set_exposure(float value)
Sets DUO3D camera Exposure setting.
#define CALLBACK
Definition: glew.h:108
#define THROW_EXCEPTION(msg)
float m_exposure
(Default = 50) Exposure value.
Definition: CDUO3DCamera.h:37
bool m_calibration_from_file
(Default = true) Get calibration information from files provided by DUO3D Calibration App...
Definition: CDUO3DCamera.h:46
bool m_capture_imu
(Default = false) Capture IMU data.
Definition: CDUO3DCamera.h:44
void * m_pframe_data
Pointer, to be reinterpreted as "PDUOFrame".
Definition: CDUO3DCamera.h:137
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:70
Contains classes for various device interfaces.
std::string read_string(const std::string &section, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
std::string m_rectify_map_filename
Rectification map file provided by DUO3D Calibration App (YML format).
Definition: CDUO3DCamera.h:51
STL namespace.
void rectify(const mrpt::utils::CImage &in_left_image, const mrpt::utils::CImage &in_right_image, mrpt::utils::CImage &out_left_image, mrpt::utils::CImage &out_right_image) const
Rectify the input image pair and save the result in a different output images - setFromCamParams() mu...
int m_img_width
(Default = 640) Width of the captured image.
Definition: CDUO3DCamera.h:34
This class stores measurements from an Inertial Measurement Unit (IMU) (attitude estimation, raw gyroscope and accelerometer values), altimeters or magnetometers.
TYMLReadResult m_camera_ext_params_from_yml(const std::string &_file_name=std::string())
GLsizei GLsizei GLuint * obj
Definition: glext.h:3902
Structure to hold the parameters of a pinhole stereo camera model.
Definition: TStereoCamera.h:25
This class allows loading and storing values and vectors of different types from a configuration text...
void m_set_gain(float value)
Sets DUO3D camera Gain setting.
cv::Mat m_rectify_map_right_y
int read_int(const std::string &section, const std::string &name, int defaultValue, bool failIfNotFound=false) const
float m_led
(Default = 25) Led intensity (some device models).
Definition: CDUO3DCamera.h:38
void open(const TCaptureOptions_DUO3D &options, const bool startCapture=true)
Tries to open the camera with the given options, and starts capturing.
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
void loadFromMemoryBuffer(unsigned int width, unsigned int height, bool color, unsigned char *rawpixels, bool swapRedBlue=false)
Reads the image from raw pixels buffer in memory.
Definition: CImage.cpp:387
__int16 int16_t
Definition: rptypes.h:45
#define FALSE
Definition: jmorecfg.h:227
int m_img_height
(Default = 480) Height of the captured image.
Definition: CDUO3DCamera.h:35
TCamera rightCamera
Intrinsic and distortion parameters of the left and right cameras.
Definition: TStereoCamera.h:29
void setFromCamParams(const mrpt::utils::TStereoCamera &params)
Prepares the mapping from the intrinsic, distortion and relative pose parameters of a stereo camera...
TYMLReadResult m_rectify_map_from_yml(const std::string &_file_name=std::string())
Observation class for either a pair of left+right or left+disparity images from a stereo camera...
float m_gain
(Default = 10) Camera gain.
Definition: CDUO3DCamera.h:39
This namespace contains representation of robot actions and observations.
uint32_t ncols
Definition: TCamera.h:53
void getObservations(mrpt::obs::CObservationStereoImages &outObservation_img, mrpt::obs::CObservationIMU &outObservation_imu, bool &there_is_img, bool &there_is_imu)
Specific laser scanner "software drivers" must process here new data from the I/O stream...
int version
Definition: mrpt_jpeglib.h:898
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:41
Options used when creating a camera capture object of type CImageGrabber_FlyCapture2.
Definition: CDUO3DCamera.h:25
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
void * m_evFrame
DUO&#39;s HANDLE.
Definition: CDUO3DCamera.h:138
GLsizei const GLchar ** string
Definition: glext.h:3919
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
mrpt::utils::CImage imageRight
Image from the right camera, only contains a valid image if hasImageRight == true.
mrpt::math::CMatrixDouble33 intrinsicParams
Matrix of intrinsic parameters (containing the focal length and principal point coordinates) ...
Definition: TCamera.h:54
void setStereoCameraParams(const mrpt::utils::TStereoCamera &in_params)
Sets leftCamera, rightCamera and rightCameraPose from a TStereoCamera structure.
TCaptureOptions_DUO3D m_options
Definition: CDUO3DCamera.h:131
#define M_DUO_PTR
void * m_duo
Opaque pointer to DUO&#39;s DUOInstance.
Definition: CDUO3DCamera.h:136
mrpt::utils::TStereoCamera m_stereo_camera
Definition: CDUO3DCamera.h:58
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp. Where available, this should contain the accurate satellite-based time...
void loadFromConfigFile(const std::string &section, const mrpt::utils::CConfigFileBase &cfg)
Load all the params from a config source, in the same format that used in saveToConfigFile().
mrpt::math::CArrayDouble< 5 > dist
[k1 k2 t1 t2 k3] -> k_i: parameters of radial distortion, t_i: parameters of tangential distortion (d...
Definition: TCamera.h:55
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
void startCapture()
Start the actual data capture of the camera.
uint32_t nrows
Camera resolution.
Definition: TCamera.h:53
GLuint const GLchar * name
Definition: glext.h:3891
void setDistortionParamsFromValues(double k1, double k2, double p1, double p2, double k3=0)
Set the vector of distortion params of the camera from the individual values of the distortion coeffi...
Definition: TCamera.h:144
cv::Mat m_rectify_map_right_x
std::string m_extrinsic_filename
Extrinsic parameters file provided by DUO3D Calibration App (YML format).
Definition: CDUO3DCamera.h:53
GLsizei const GLfloat * value
Definition: glext.h:3929
void m_set_led(float value)
Sets DUO3D camera LED setting.
GLuint res
Definition: glext.h:6298
std::string BASE_IMPEXP extractFileName(const std::string &filePath)
Extract just the name (without extension) of a filename from a complete path plus name plus extension...
Definition: filesystem.cpp:61
CDUO3DCamera()
Default Constructor (does not open the camera)
TYMLReadResult m_camera_int_params_from_yml(const std::string &_file_name=std::string())
mrpt::vision::CStereoRectifyMap m_rectify_map
Definition: CDUO3DCamera.h:134
void setDataFrame(void *frame)
frame is a reinterpreted PDUOFrame
Definition: CDUO3DCamera.h:185
void setIntrinsicParamsFromValues(double fx, double fy, double cx, double cy)
Set the matrix of intrinsic params of the camera from the individual values of focal length and princ...
Definition: TCamera.h:102
bool m_capture_rectified
(Default = true) Rectify images. Rectification map must be provided
Definition: CDUO3DCamera.h:45
std::map< const mrpt::hwdrivers::TCaptureOptions_DUO3D *, TDUOParams > duo_params
void close()
Stop capture and closes the opened camera, if any.
vector_bool dataIsPresent
Each entry in this vector is true if the corresponding data index contains valid data (the IMU unit s...
cv::Mat m_rectify_map_left_x
mrpt::poses::CPose3DQuat rightCameraPose
Pose of the right camera with respect to the coordinate origin of the left camera.
Definition: TStereoCamera.h:30
void loadOptionsFrom(const mrpt::utils::CConfigFileBase &configSource, const std::string &sectionName, const std::string &prefix=std::string())
Loads all the options from a config file.
virtual ~CDUO3DCamera()
Destructor.
#define M_DUO_VALUE



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019