Main MRPT website > C++ reference for MRPT 1.9.9
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
19 // want to force users to need opencv headers:
20 struct TDUOParams
21 {
22 #if MRPT_HAS_OPENCV
27 #endif
28 };
29 std::map<const mrpt::hwdrivers::TCaptureOptions_DUO3D*, TDUOParams> duo_params;
30 
31 // duo3d header files
32 #if MRPT_HAS_DUO3D
33 #include <DUOLib.h>
34 #endif
35 
36 // m_duo: Opaque pointer to DUO3D's "DUOInstance":
37 #define M_DUO_PTR (reinterpret_cast<DUOInstance*>(m_duo))
38 #define M_DUO_VALUE (*M_DUO_PTR)
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 
78 {
79 #if MRPT_HAS_OPENCV
80  const string file_name =
81  _file_name.empty() ? m_rectify_map_filename : _file_name;
82 
83  TDUOParams& dp = duo_params[this];
84 
85  string aux = mrpt::system::extractFileName(file_name);
86  const size_t found = aux.find(
87  mrpt::format("_R%dx%d_", this->m_img_width, this->m_img_height));
88  if (found == std::string::npos)
89  {
91  dp.m_rectify_map_right_x = dp.m_rectify_map_right_y = cv::Mat();
93  }
94  // read file
95  FileStorage fs(file_name, FileStorage::READ);
96  fs["R0X"] >> dp.m_rectify_map_left_x;
97  fs["R0Y"] >> dp.m_rectify_map_left_y;
98  fs["R1X"] >> dp.m_rectify_map_right_x;
99  fs["R1Y"] >> dp.m_rectify_map_right_y;
100 
101  if (dp.m_rectify_map_left_x.size() == Size(0, 0) ||
102  dp.m_rectify_map_left_y.size() == Size(0, 0) ||
103  dp.m_rectify_map_right_x.size() == Size(0, 0) ||
104  dp.m_rectify_map_right_y.size() == Size(0, 0))
105  return yrr_EMPTY;
106 
107  return yrr_OK;
108 #else
109  THROW_EXCEPTION("This function requires building with OpenCV support")
110 #endif
111 }
112 
115  const string& _file_name)
116 {
117 #if MRPT_HAS_OPENCV
118  const string file_name =
119  _file_name.empty() ? m_extrinsic_filename : _file_name;
120 
121  // this will look for R and t matrixes
122  cv::Mat aux_mat;
123  bool empty = false;
124  string aux = mrpt::system::extractFileName(file_name);
125  const size_t found = aux.find(
126  mrpt::format("_R%dx%d_", this->m_img_width, this->m_img_height));
127  if (found == std::string::npos)
128  {
131  }
132  // read file
133  FileStorage fs(file_name, FileStorage::READ);
134  CMatrixDouble33 M;
136  CMatrixDouble44 M2;
137 
138  // rotation matrix
139  fs["R"] >> aux_mat;
140  if (aux_mat.size() == Size(3, 3))
141  {
142  for (size_t k1 = 0; k1 < 3; ++k1)
143  for (size_t k2 = 0; k2 < 3; ++k2)
144  M(k1, k2) = aux_mat.at<double>(k1, k2);
145  }
146  else
147  {
148  empty = true;
150  }
151 
152  // translation
153  fs["T"] >> aux_mat;
154  if (aux_mat.size() == Size(1, 3))
155  {
156  t(0, 0) = aux_mat.at<double>(0, 0) / 1000.0;
157  t(0, 1) = aux_mat.at<double>(1, 0) / 1000.0;
158  t(0, 2) = aux_mat.at<double>(2, 0) / 1000.0;
159  }
160  else
161  {
162  empty = true;
164  }
165 
166  if (empty) return yrr_EMPTY;
167 
169  return yrr_OK;
170 #else
171  THROW_EXCEPTION("This function requires building with OpenCV support")
172 #endif
173 }
174 
177  const string& _file_name)
178 {
179 #if MRPT_HAS_OPENCV
180  const string file_name =
181  _file_name.empty() ? m_intrinsic_filename : _file_name;
182 
183  // this will look for M1, D1, M2 and D2 matrixes
184  cv::Mat aux_mat;
185  bool empty = false;
186  string aux = mrpt::system::extractFileName(file_name);
187  const size_t found = aux.find(
188  mrpt::format("_R%dx%d_", this->m_img_width, this->m_img_height));
189  if (found == std::string::npos)
190  {
195 
197  }
198  // read file
199  FileStorage fs(file_name, FileStorage::READ);
200 
201  // left camera
202  fs["M1"] >> aux_mat;
203  if (aux_mat.size() == Size(0, 0))
204  {
205  empty = true;
207  }
209  aux_mat.at<double>(0, 0), aux_mat.at<double>(1, 1),
210  aux_mat.at<double>(0, 2), aux_mat.at<double>(1, 2));
211 
212  fs["D1"] >> aux_mat;
213  if (aux_mat.size() == Size(0, 0))
214  {
215  empty = true;
217  }
219  aux_mat.at<double>(0, 0), aux_mat.at<double>(0, 1),
220  aux_mat.at<double>(0, 2), aux_mat.at<double>(0, 3),
221  aux_mat.at<double>(0, 4));
222 
223  fs["M2"] >> aux_mat;
224  if (aux_mat.size() == Size(0, 0))
225  {
226  empty = true;
228  }
230  aux_mat.at<double>(0, 0), aux_mat.at<double>(1, 1),
231  aux_mat.at<double>(0, 2), aux_mat.at<double>(1, 2));
232 
233  fs["D2"] >> aux_mat;
234  if (aux_mat.size() == Size(0, 0))
235  {
236  empty = true;
238  }
240  aux_mat.at<double>(0, 0), aux_mat.at<double>(0, 1),
241  aux_mat.at<double>(0, 2), aux_mat.at<double>(0, 3),
242  aux_mat.at<double>(0, 4));
243 
244  return empty ? yrr_EMPTY : yrr_OK;
245 #else
246  THROW_EXCEPTION("This function requires building with OpenCV support")
247 #endif
248 }
249 
251  const mrpt::utils::CConfigFileBase& configSource,
252  const std::string& iniSection, const std::string& prefix)
253 {
254  m_img_width = configSource.read_int(iniSection, "image_width", m_img_width);
255  m_img_height =
256  configSource.read_int(iniSection, "image_height", m_img_height);
257 
258  m_fps = configSource.read_float(iniSection, "fps", m_fps);
259  m_exposure = configSource.read_float(iniSection, "exposure", m_exposure);
260  m_led = configSource.read_float(iniSection, "led", m_led);
261  m_gain = configSource.read_float(iniSection, "gain", m_gain);
262 
263  m_capture_rectified = configSource.read_bool(
264  iniSection, "capture_rectified", m_capture_rectified);
265  m_capture_imu =
266  configSource.read_bool(iniSection, "capture_imu", m_capture_imu);
267  m_calibration_from_file = configSource.read_bool(
268  iniSection, "calibration_from_file", m_calibration_from_file);
269 
271  {
272  m_intrinsic_filename = configSource.read_string(
273  iniSection, "intrinsic_filename", m_intrinsic_filename);
274  m_extrinsic_filename = configSource.read_string(
275  iniSection, "extrinsic_filename", m_extrinsic_filename);
277  m_img_width;
279  m_img_height;
280  }
281  else
282  m_stereo_camera.loadFromConfigFile("DUO3D", configSource);
283 
285  {
286  m_rectify_map_filename = configSource.read_string(
287  iniSection, "rectify_map_filename", m_rectify_map_filename);
288  } // end-capture-rectified
289 }
290 
291 #if MRPT_HAS_DUO3D
292 static void CALLBACK DUOCallback(const PDUOFrame pFrameData, void* pUserData)
293 {
294  CDUO3DCamera* obj = static_cast<CDUO3DCamera*>(pUserData);
295  obj->setDataFrame(reinterpret_cast<void*>(pFrameData));
296  SetEvent(reinterpret_cast<HANDLE>(obj->getEvent()));
297 }
298 #endif
299 
300 /** Default constructor. */
302  : m_options(TCaptureOptions_DUO3D()), m_duo(nullptr)
303 {
304 #if MRPT_HAS_DUO3D
305  m_duo = new DUOInstance[1];
306  M_DUO_VALUE = nullptr; // m_duo = nullptr;
307 
308  m_pframe_data = nullptr;
309  m_evFrame = CreateEvent(nullptr, FALSE, FALSE, nullptr);
310 #else
312  "MRPT has been compiled with 'MRPT_BUILD_DUO3D'=OFF, so this class "
313  "cannot be used.");
314 #endif
315 } // end-constructor
316 
317 /** Custom initialization and start grabbing constructor. */
319  : m_duo(nullptr)
320 {
321 #if MRPT_HAS_DUO3D
322  m_duo = new DUOInstance[1];
323  M_DUO_VALUE = nullptr; // m_duo = nullptr;
324 
325  m_pframe_data = nullptr;
326  m_evFrame = CreateEvent(nullptr, FALSE, FALSE, nullptr);
327  this->open(options);
328 #else
330  "MRPT has been compiled with 'MRPT_BUILD_DUO3D'=OFF, so this class "
331  "cannot be used.");
332 #endif
333 } // end-constructor
334 
335 /** Destructor */
337 {
338 #if MRPT_HAS_DUO3D
339  this->close();
340  if (m_duo)
341  {
342  delete[] M_DUO_PTR;
343  m_duo = nullptr;
344  }
345 #endif
346 } // end-destructor
347 
348 /** Tries to open the camera with the given options. Raises an exception on
349  * error. \sa close() */
351  const TCaptureOptions_DUO3D& options, const bool startCapture)
352 {
353 #if MRPT_HAS_DUO3D
354  if (M_DUO_VALUE) this->close();
355  this->m_options = options;
356 
358  {
359  // get intrinsic parameters
363  cout << "[CDUO3DCamera] Warning: Some of the intrinsic params "
364  "could not be read (size=0). Check file content."
365  << endl;
367  cout << "[CDUO3DCamera] Warning: Intrinsic params filename is not "
368  "consistent with image size. Are you using the correct "
369  "calibration?. All params set to zero."
370  << endl;
371 
372  // get extrinsic parameters
375  cout << "[CDUO3DCamera] Warning: Some of the extrinsic params "
376  "could not be read (size!=3x3). Check file content."
377  << endl;
379  cout << "[CDUO3DCamera] Warning: Extrinsic params filename is not "
380  "consistent with image size. Are you using the correct "
381  "calibration?. All params set to zero."
382  << endl;
383 
384  if (this->m_options.m_capture_rectified)
385  {
386  if (!this->m_options.m_rectify_map_filename.empty())
387  {
388  // read "rectify_map"
389  res = this->m_options.m_rectify_map_from_yml();
391  cout << "[CDUO3DCamera] Warning: Rectification map could "
392  "not be read (size==0). Check file content."
393  << endl;
395  cout << "[CDUO3DCamera] Warning: Rectification map "
396  "filename is not consistent with image size. Are "
397  "you using the correct calibration?. Rectification "
398  "map set to zero."
399  << endl;
400 
403 
404  // const size_t area =
405  // this->m_options.dp.m_rectify_map_left_x.size().area();
406  TDUOParams& dp = duo_params[&(this->m_options)];
407  const size_t area = dp.m_rectify_map_left_x.size().area();
408  vector<int16_t> v_left_x(area), v_right_x(area);
409  vector<uint16_t> v_left_y(area), v_right_y(area);
410 
411  for (size_t k = 0; k < area; ++k)
412  {
413  v_left_x[k] = dp.m_rectify_map_left_x.at<int16_t>(k);
414  v_left_y[k] = dp.m_rectify_map_left_y.at<uint16_t>(k);
415  v_right_x[k] = dp.m_rectify_map_right_x.at<int16_t>(k);
416  v_right_y[k] = dp.m_rectify_map_right_y.at<uint16_t>(k);
417 
418  // v_left_x[k] =
419  // this->m_options.dp.m_rectify_map_left_x.at<int16_t>(k);
420  // v_left_y[k] =
421  // this->m_options.dp.m_rectify_map_left_y.at<uint16_t>(k);
422  // v_right_x[k] =
423  // this->m_options.dp.m_rectify_map_right_x.at<int16_t>(k);
424  // v_right_y[k] =
425  // this->m_options.dp.m_rectify_map_right_y.at<uint16_t>(k);
426  }
428  // m_rectify_map.setRectifyMaps( v_left_x, v_left_y, v_right_x,
429  // v_right_y );
430  }
431  else
432  {
433  cout << "[CDUO3DCamera] Warning: Calibration information is "
434  "set to be read from a file, but the file was not "
435  "specified. Unrectified images will be grabbed."
436  << endl;
437  }
438  } // end-if
439  } // end-if
440  else if (this->m_options.m_capture_rectified)
441  {
443  }
444 
445  // Find optimal binning parameters for given (width, height)
446  // This maximizes sensor imaging area for given resolution
447  int binning = DUO_BIN_NONE;
448  if (this->m_options.m_img_width <= 752 / 2) binning += DUO_BIN_HORIZONTAL2;
449  if (this->m_options.m_img_height <= 480 / 4)
450  binning += DUO_BIN_VERTICAL4;
451  else if (this->m_options.m_img_height <= 480 / 2)
452  binning += DUO_BIN_VERTICAL2;
453 
454  // Check if we support given resolution (width, height, binning, fps)
455  DUOResolutionInfo ri;
456  if (!EnumerateResolutions(
457  &ri, 1, this->m_options.m_img_width, this->m_options.m_img_height,
458  binning, this->m_options.m_fps))
459  THROW_EXCEPTION("[CDUO3DCamera] Error: Resolution not supported.")
460 
461  if (!OpenDUO(&M_DUO_VALUE)) // was: m_duo
462  THROW_EXCEPTION("[CDUO3DCamera] Error: Camera could not be opened.")
463 
464  // Get and print some DUO parameter values
465  char name[260], version[260];
466  GetDUODeviceName(M_DUO_VALUE, name);
467  GetDUOFirmwareVersion(M_DUO_VALUE, version);
468  cout << "[CDUO3DCamera::open] DUO3DCamera name: " << name << " (v"
469  << version << ")" << endl;
470 
471  // Set selected resolution
472  SetDUOResolutionInfo(M_DUO_VALUE, ri);
473 
474  // Set selected camera settings
475  SetDUOExposure(M_DUO_VALUE, m_options.m_exposure);
476  SetDUOGain(M_DUO_VALUE, m_options.m_gain);
477  SetDUOLedPWM(M_DUO_VALUE, m_options.m_led);
478 
479  // Start capture
480  if (startCapture)
481  {
482  if (!StartDUO(M_DUO_VALUE, DUOCallback, reinterpret_cast<void*>(this)))
484  "[CDUO3DCamera] Error: Camera could not be started.")
485  }
486 
487 #endif
488 } // end-open
489 
490 /*-------------------------------------------------------------
491  getObservations
492 -------------------------------------------------------------*/
494  CObservationStereoImages& outObservation_img,
495  CObservationIMU& outObservation_imu, bool& there_is_img, bool& there_is_imu)
496 {
497 #if MRPT_HAS_DUO3D
498  there_is_img = false;
499  there_is_imu = false;
500 
502  if (!m_pframe_data) return;
503 
504  // -----------------------------------------------
505  // Extract the observation:
506  // -----------------------------------------------
507  outObservation_img.timestamp = outObservation_imu.timestamp =
509 
510  outObservation_img.setStereoCameraParams(m_options.m_stereo_camera);
511  outObservation_img.imageLeft.loadFromMemoryBuffer(
513  (unsigned char*)reinterpret_cast<PDUOFrame>(m_pframe_data)->leftData);
514 
515  outObservation_img.imageRight.loadFromMemoryBuffer(
517  (unsigned char*)reinterpret_cast<PDUOFrame>(m_pframe_data)->rightData);
518 
519  if (this->m_options.m_capture_rectified)
520  m_rectify_map.rectify(outObservation_img);
521 
522  there_is_img = true;
523 
524  if (this->m_options.m_capture_imu)
525  {
526  if (!reinterpret_cast<PDUOFrame>(m_pframe_data)->accelerometerPresent)
527  {
528  cout << "[CDUO3DCamera] Warning: This device does not provide IMU "
529  "data. No IMU observations will be created."
530  << endl;
531  this->m_options.m_capture_imu = false;
532  }
533  else
534  {
535  // Accelerometer data
536  for (size_t k = 0; k < 3; ++k)
537  {
538  outObservation_imu.rawMeasurements[k] =
539  reinterpret_cast<PDUOFrame>(m_pframe_data)->accelData[k];
540  outObservation_imu.dataIsPresent[k] = true;
541  }
542 
543  // Gyroscopes data
544  for (size_t k = 0; k < 3; ++k)
545  {
546  outObservation_imu.rawMeasurements[k + 3] =
547  reinterpret_cast<PDUOFrame>(m_pframe_data)->gyroData[k];
548  outObservation_imu.dataIsPresent[k + 3] = true;
549  }
550  there_is_imu = true;
551  } // end else
552  } // end-imu-info
553 #endif
554 }
555 
556 /** Closes DUO camera */
558 {
559 #if MRPT_HAS_DUO3D
560  if (!M_DUO_VALUE) return;
561  StopDUO(M_DUO_VALUE);
562  CloseDUO(M_DUO_VALUE);
563  M_DUO_VALUE = nullptr;
564 #endif
565 } // end-close
566 
567 // Waits until the new DUO frame is ready and returns it
569 {
570 #if MRPT_HAS_DUO3D
571  if (M_DUO_VALUE == nullptr) return 0;
572  if (WaitForSingleObject(m_evFrame, 1000) == WAIT_OBJECT_0)
573  return m_pframe_data;
574  else
575  return nullptr;
576 #else
577  return nullptr; // return something to silent compiler warnings.
578 #endif
579 }
580 
582 {
583 #if MRPT_HAS_DUO3D
584  if (M_DUO_VALUE == nullptr) return;
585  SetDUOExposure(M_DUO_VALUE, value);
586 #endif
587 }
588 
590 {
591 #if MRPT_HAS_DUO3D
592  if (M_DUO_VALUE == nullptr) return;
593  SetDUOGain(M_DUO_VALUE, value);
594 #endif
595 }
596 
598 {
599 #if MRPT_HAS_DUO3D
600  if (M_DUO_VALUE == nullptr) return;
601  SetDUOLedPWM(M_DUO_VALUE, value);
602 #endif
603 }
604 
605 /** Queries the DUO3D Camera firmware version */
606 bool CDUO3DCamera::queryVersion(std::string version, bool printOutVersion)
607 {
608 #if MRPT_HAS_DUO3D
609  version = std::string(GetLibVersion());
610  if (printOutVersion)
611  std::cout << "DUO3D Camera library version: " << version << std::endl;
612  return true;
613 #else
614  return false;
615 #endif
616 }
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:42
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.
GLdouble GLdouble t
Definition: glext.h:3689
std::string m_intrinsic_filename
Intrinsic parameters file provided by DUO3D Calibration App (YML format).
Definition: CDUO3DCamera.h:70
unsigned __int16 uint16_t
Definition: rptypes.h:44
mrpt::utils::CImage imageLeft
Image from the left camera (this image will be ALWAYS present)
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
cv::Mat m_rectify_map_left_y
This "software driver" implements the communication protocol for interfacing a DUO3D Stereo Camera...
Definition: CDUO3DCamera.h:156
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:111
#define THROW_EXCEPTION(msg)
float m_exposure
(Default = 50) Exposure value.
Definition: CDUO3DCamera.h:44
bool m_calibration_from_file
(Default = true) Get calibration information from files provided by DUO3D Calibration App...
Definition: CDUO3DCamera.h:60
bool m_capture_imu
(Default = false) Capture IMU data.
Definition: CDUO3DCamera.h:54
void * m_pframe_data
Pointer, to be reinterpreted as "PDUOFrame".
Definition: CDUO3DCamera.h:169
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:76
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:67
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:38
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:4070
std::map< const mrpt::hwdrivers::TCaptureOptions_DUO3D *, TDUOParams > duo_params
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:46
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:390
__int16 int16_t
Definition: rptypes.h:43
#define FALSE
Definition: jmorecfg.h:216
int m_img_height
(Default = 480) Height of the captured image.
Definition: CDUO3DCamera.h:40
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:48
This namespace contains representation of robot actions and observations.
uint32_t ncols
Camera resolution.
Definition: TCamera.h:54
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...
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:48
Options used when creating a camera capture object of type CImageGrabber_FlyCapture2.
Definition: CDUO3DCamera.h:23
void * m_evFrame
DUO&#39;s HANDLE.
Definition: CDUO3DCamera.h:171
GLsizei const GLchar ** string
Definition: glext.h:4101
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:57
void setStereoCameraParams(const mrpt::utils::TStereoCamera &in_params)
Sets leftCamera, rightCamera and rightCameraPose from a TStereoCamera structure.
TCaptureOptions_DUO3D m_options
Definition: CDUO3DCamera.h:161
#define M_DUO_PTR
void * m_duo
Opaque pointer to DUO&#39;s DUOInstance.
Definition: CDUO3DCamera.h:167
mrpt::utils::TStereoCamera m_stereo_camera
Definition: CDUO3DCamera.h:78
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
Definition: CObservation.h:58
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:60
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
TCamera leftCamera
Intrinsic and distortion parameters of the left and right cameras.
Definition: TStereoCamera.h:30
void startCapture()
Start the actual data capture of the camera.
uint32_t nrows
Definition: TCamera.h:54
GLuint const GLchar * name
Definition: glext.h:4054
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:163
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:73
GLsizei const GLfloat * value
Definition: glext.h:4117
void m_set_led(float value)
Sets DUO3D camera LED setting.
GLuint res
Definition: glext.h:7268
std::string 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:164
void setDataFrame(void *frame)
frame is a reinterpreted PDUOFrame
Definition: CDUO3DCamera.h:226
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:118
bool m_capture_rectified
(Default = true) Rectify images.
Definition: CDUO3DCamera.h:57
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:33
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.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019