MRPT  1.9.9
CDUO3DCamera.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "hwdrivers-precomp.h" // Precompiled headers
11 
13 #include <mrpt/system/filesystem.h>
14 #include <mrpt/system/os.h>
15 
16 #include <mrpt/3rdparty/do_opencv_includes.h>
17 
18 #include <map>
19 
20 // We must define & store OpenCV-specific data like this in the .cpp, we don't
21 // want to force users to need opencv headers:
22 struct TDUOParams
23 {
24 #if MRPT_HAS_OPENCV
29 #endif
30 };
31 std::map<const mrpt::hwdrivers::TCaptureOptions_DUO3D*, TDUOParams> duo_params;
32 
33 // duo3d header files
34 #if MRPT_HAS_DUO3D
35 #include <DUOLib.h>
36 #endif
37 
38 // m_duo: Opaque pointer to DUO3D's "DUOInstance":
39 #define M_DUO_PTR (reinterpret_cast<DUOInstance*>(m_duo))
40 #define M_DUO_VALUE (*M_DUO_PTR)
41 
42 using namespace std;
43 using namespace mrpt;
44 using namespace mrpt::math;
45 using namespace mrpt::poses;
46 using namespace mrpt::img;
47 using namespace mrpt::obs;
48 using namespace mrpt::hwdrivers;
49 
50 // opencv header files and namespaces
51 #if MRPT_HAS_OPENCV
52 using namespace cv;
53 #endif
54 
55 TCaptureOptions_DUO3D::TCaptureOptions_DUO3D()
56  : m_rectify_map_filename(""),
57  m_intrinsic_filename(""),
58  m_extrinsic_filename(""),
59  m_stereo_camera(TStereoCamera())
60 {
61  duo_params[this]; // Create
62 }
63 
65 {
66  duo_params.erase(this); // Remove entry
67 }
68 
71 {
72 #if MRPT_HAS_OPENCV
73  const string file_name =
74  _file_name.empty() ? m_rectify_map_filename : _file_name;
75 
76  TDUOParams& dp = duo_params[this];
77 
78  string aux = mrpt::system::extractFileName(file_name);
79  const size_t found = aux.find(
80  mrpt::format("_R%dx%d_", this->m_img_width, this->m_img_height));
81  if (found == std::string::npos)
82  {
84  dp.m_rectify_map_right_x = dp.m_rectify_map_right_y = cv::Mat();
86  }
87  // read file
88  FileStorage fs(file_name, FileStorage::READ);
89  fs["R0X"] >> dp.m_rectify_map_left_x;
90  fs["R0Y"] >> dp.m_rectify_map_left_y;
91  fs["R1X"] >> dp.m_rectify_map_right_x;
92  fs["R1Y"] >> dp.m_rectify_map_right_y;
93 
94  if (dp.m_rectify_map_left_x.size() == Size(0, 0) ||
95  dp.m_rectify_map_left_y.size() == Size(0, 0) ||
96  dp.m_rectify_map_right_x.size() == Size(0, 0) ||
97  dp.m_rectify_map_right_y.size() == Size(0, 0))
98  return yrr_EMPTY;
99 
100  return yrr_OK;
101 #else
102  THROW_EXCEPTION("This function requires building with OpenCV support");
103 #endif
104 }
105 
108  const string& _file_name)
109 {
110 #if MRPT_HAS_OPENCV
111  const string file_name =
112  _file_name.empty() ? m_extrinsic_filename : _file_name;
113 
114  // this will look for R and t matrixes
115  cv::Mat aux_mat;
116  bool empty = false;
117  string aux = mrpt::system::extractFileName(file_name);
118  const size_t found = aux.find(
119  mrpt::format("_R%dx%d_", this->m_img_width, this->m_img_height));
120  if (found == std::string::npos)
121  {
122  m_stereo_camera.rightCameraPose = TPose3DQuat(0, 0, 0, 1.0, 0, 0, 0);
124  }
125  // read file
126  FileStorage fs(file_name, FileStorage::READ);
127  CMatrixDouble33 M;
128  CMatrixDouble13 t;
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;
142  m_stereo_camera.rightCameraPose = TPose3DQuat(0, 0, 0, 1, 0, 0, 0);
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;
156  m_stereo_camera.rightCameraPose = TPose3DQuat(0, 0, 0, 1, 0, 0, 0);
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 
170  const string& _file_name)
171 {
172 #if MRPT_HAS_OPENCV
173  const string file_name =
174  _file_name.empty() ? m_intrinsic_filename : _file_name;
175 
176  // this will look for M1, D1, M2 and D2 matrixes
177  cv::Mat aux_mat;
178  bool empty = false;
179  string aux = mrpt::system::extractFileName(file_name);
180  const size_t found = aux.find(
181  mrpt::format("_R%dx%d_", this->m_img_width, this->m_img_height));
182  if (found == std::string::npos)
183  {
188 
190  }
191  // read file
192  FileStorage fs(file_name, FileStorage::READ);
193 
194  // left camera
195  fs["M1"] >> aux_mat;
196  if (aux_mat.size() == Size(0, 0))
197  {
198  empty = true;
200  }
202  aux_mat.at<double>(0, 0), aux_mat.at<double>(1, 1),
203  aux_mat.at<double>(0, 2), aux_mat.at<double>(1, 2));
204 
205  fs["D1"] >> aux_mat;
206  if (aux_mat.size() == Size(0, 0))
207  {
208  empty = true;
210  }
212  aux_mat.at<double>(0, 0), aux_mat.at<double>(0, 1),
213  aux_mat.at<double>(0, 2), aux_mat.at<double>(0, 3),
214  aux_mat.at<double>(0, 4));
215 
216  fs["M2"] >> aux_mat;
217  if (aux_mat.size() == Size(0, 0))
218  {
219  empty = true;
221  }
223  aux_mat.at<double>(0, 0), aux_mat.at<double>(1, 1),
224  aux_mat.at<double>(0, 2), aux_mat.at<double>(1, 2));
225 
226  fs["D2"] >> aux_mat;
227  if (aux_mat.size() == Size(0, 0))
228  {
229  empty = true;
231  }
233  aux_mat.at<double>(0, 0), aux_mat.at<double>(0, 1),
234  aux_mat.at<double>(0, 2), aux_mat.at<double>(0, 3),
235  aux_mat.at<double>(0, 4));
236 
237  return empty ? yrr_EMPTY : yrr_OK;
238 #else
239  THROW_EXCEPTION("This function requires building with OpenCV support");
240 #endif
241 }
242 
244  const mrpt::config::CConfigFileBase& configSource,
245  const std::string& iniSection, const std::string& prefix)
246 {
247  m_img_width = configSource.read_int(iniSection, "image_width", m_img_width);
248  m_img_height =
249  configSource.read_int(iniSection, "image_height", m_img_height);
250 
251  m_fps = configSource.read_float(iniSection, "fps", m_fps);
252  m_exposure = configSource.read_float(iniSection, "exposure", m_exposure);
253  m_led = configSource.read_float(iniSection, "led", m_led);
254  m_gain = configSource.read_float(iniSection, "gain", m_gain);
255 
256  m_capture_rectified = configSource.read_bool(
257  iniSection, "capture_rectified", m_capture_rectified);
258  m_capture_imu =
259  configSource.read_bool(iniSection, "capture_imu", m_capture_imu);
260  m_calibration_from_file = configSource.read_bool(
261  iniSection, "calibration_from_file", m_calibration_from_file);
262 
264  {
265  m_intrinsic_filename = configSource.read_string(
266  iniSection, "intrinsic_filename", m_intrinsic_filename);
267  m_extrinsic_filename = configSource.read_string(
268  iniSection, "extrinsic_filename", m_extrinsic_filename);
270  m_img_width;
272  m_img_height;
273  }
274  else
275  m_stereo_camera.loadFromConfigFile("DUO3D", configSource);
276 
278  {
279  m_rectify_map_filename = configSource.read_string(
280  iniSection, "rectify_map_filename", m_rectify_map_filename);
281  } // end-capture-rectified
282 }
283 
284 #if MRPT_HAS_DUO3D
285 static void CALLBACK DUOCallback(const PDUOFrame pFrameData, void* pUserData)
286 {
287  CDUO3DCamera* obj = static_cast<CDUO3DCamera*>(pUserData);
288  obj->setDataFrame(reinterpret_cast<void*>(pFrameData));
289  SetEvent(reinterpret_cast<HANDLE>(obj->getEvent()));
290 }
291 #endif
292 
293 /** Default constructor. */
295 {
296 #if MRPT_HAS_DUO3D
297  m_duo = new DUOInstance[1];
298  M_DUO_VALUE = nullptr; // m_duo = nullptr;
299 
300  m_pframe_data = nullptr;
301  m_evFrame = CreateEvent(nullptr, FALSE, FALSE, nullptr);
302 #else
304  "MRPT has been compiled with 'MRPT_BUILD_DUO3D'=OFF, so this class "
305  "cannot be used.");
306 #endif
307 } // end-constructor
308 
309 /** Custom initialization and start grabbing constructor. */
311  : m_duo(nullptr)
312 {
313 #if MRPT_HAS_DUO3D
314  m_duo = new DUOInstance[1];
315  M_DUO_VALUE = nullptr; // m_duo = nullptr;
316 
317  m_pframe_data = nullptr;
318  m_evFrame = CreateEvent(nullptr, FALSE, FALSE, nullptr);
319  this->open(options);
320 #else
322  "MRPT has been compiled with 'MRPT_BUILD_DUO3D'=OFF, so this class "
323  "cannot be used.");
324 #endif
325 } // end-constructor
326 
327 /** Destructor */
329 {
330 #if MRPT_HAS_DUO3D
331  this->close();
332  if (m_duo)
333  {
334  delete[] M_DUO_PTR;
335  m_duo = nullptr;
336  }
337 #endif
338 } // end-destructor
339 
340 /** Tries to open the camera with the given options. Raises an exception on
341  * error. \sa close() */
343  const TCaptureOptions_DUO3D& options, const bool startCapture)
344 {
345 #if MRPT_HAS_DUO3D
346  if (M_DUO_VALUE) this->close();
347  this->m_options = options;
348 
350  {
351  // get intrinsic parameters
355  cout << "[CDUO3DCamera] Warning: Some of the intrinsic params "
356  "could not be read (size=0). Check file content."
357  << endl;
359  cout << "[CDUO3DCamera] Warning: Intrinsic params filename is not "
360  "consistent with image size. Are you using the correct "
361  "calibration?. All params set to zero."
362  << endl;
363 
364  // get extrinsic parameters
367  cout << "[CDUO3DCamera] Warning: Some of the extrinsic params "
368  "could not be read (size!=3x3). Check file content."
369  << endl;
371  cout << "[CDUO3DCamera] Warning: Extrinsic params filename is not "
372  "consistent with image size. Are you using the correct "
373  "calibration?. All params set to zero."
374  << endl;
375 
376  if (this->m_options.m_capture_rectified)
377  {
378  if (!this->m_options.m_rectify_map_filename.empty())
379  {
380  // read "rectify_map"
381  res = this->m_options.m_rectify_map_from_yml();
383  cout << "[CDUO3DCamera] Warning: Rectification map could "
384  "not be read (size==0). Check file content."
385  << endl;
387  cout << "[CDUO3DCamera] Warning: Rectification map "
388  "filename is not consistent with image size. Are "
389  "you using the correct calibration?. Rectification "
390  "map set to zero."
391  << endl;
392 
395 
396  // const size_t area =
397  // this->m_options.dp.m_rectify_map_left_x.size().area();
398  TDUOParams& dp = duo_params[&(this->m_options)];
399  const size_t area = dp.m_rectify_map_left_x.size().area();
400  vector<int16_t> v_left_x(area), v_right_x(area);
401  vector<uint16_t> v_left_y(area), v_right_y(area);
402 
403  for (size_t k = 0; k < area; ++k)
404  {
405  v_left_x[k] = dp.m_rectify_map_left_x.at<int16_t>(k);
406  v_left_y[k] = dp.m_rectify_map_left_y.at<uint16_t>(k);
407  v_right_x[k] = dp.m_rectify_map_right_x.at<int16_t>(k);
408  v_right_y[k] = dp.m_rectify_map_right_y.at<uint16_t>(k);
409 
410  // v_left_x[k] =
411  // this->m_options.dp.m_rectify_map_left_x.at<int16_t>(k);
412  // v_left_y[k] =
413  // this->m_options.dp.m_rectify_map_left_y.at<uint16_t>(k);
414  // v_right_x[k] =
415  // this->m_options.dp.m_rectify_map_right_x.at<int16_t>(k);
416  // v_right_y[k] =
417  // this->m_options.dp.m_rectify_map_right_y.at<uint16_t>(k);
418  }
420  // m_rectify_map.setRectifyMaps( v_left_x, v_left_y, v_right_x,
421  // v_right_y );
422  }
423  else
424  {
425  cout << "[CDUO3DCamera] Warning: Calibration information is "
426  "set to be read from a file, but the file was not "
427  "specified. Unrectified images will be grabbed."
428  << endl;
429  }
430  } // end-if
431  } // end-if
432  else if (this->m_options.m_capture_rectified)
433  {
435  }
436 
437  // Find optimal binning parameters for given (width, height)
438  // This maximizes sensor imaging area for given resolution
439  int binning = DUO_BIN_NONE;
440  if (this->m_options.m_img_width <= 752 / 2) binning += DUO_BIN_HORIZONTAL2;
441  if (this->m_options.m_img_height <= 480 / 4)
442  binning += DUO_BIN_VERTICAL4;
443  else if (this->m_options.m_img_height <= 480 / 2)
444  binning += DUO_BIN_VERTICAL2;
445 
446  // Check if we support given resolution (width, height, binning, fps)
447  DUOResolutionInfo ri;
448  if (!EnumerateResolutions(
449  &ri, 1, this->m_options.m_img_width, this->m_options.m_img_height,
450  binning, this->m_options.m_fps))
451  THROW_EXCEPTION("[CDUO3DCamera] Error: Resolution not supported.");
452 
453  if (!OpenDUO(&M_DUO_VALUE)) // was: m_duo
454  THROW_EXCEPTION("[CDUO3DCamera] Error: Camera could not be opened.");
455 
456  // Get and print some DUO parameter values
457  char name[260], version[260];
458  GetDUODeviceName(M_DUO_VALUE, name);
459  GetDUOFirmwareVersion(M_DUO_VALUE, version);
460  cout << "[CDUO3DCamera::open] DUO3DCamera name: " << name << " (v"
461  << version << ")" << endl;
462 
463  // Set selected resolution
464  SetDUOResolutionInfo(M_DUO_VALUE, ri);
465 
466  // Set selected camera settings
467  SetDUOExposure(M_DUO_VALUE, m_options.m_exposure);
468  SetDUOGain(M_DUO_VALUE, m_options.m_gain);
469  SetDUOLedPWM(M_DUO_VALUE, m_options.m_led);
470 
471  // Start capture
472  if (startCapture)
473  {
474  if (!StartDUO(M_DUO_VALUE, DUOCallback, reinterpret_cast<void*>(this)))
476  "[CDUO3DCamera] Error: Camera could not be started.")
477  }
478 
479 #endif
480 } // end-open
481 
482 /*-------------------------------------------------------------
483  getObservations
484 -------------------------------------------------------------*/
486  CObservationStereoImages& outObservation_img,
487  CObservationIMU& outObservation_imu, bool& there_is_img, bool& there_is_imu)
488 {
489 #if MRPT_HAS_DUO3D
490  there_is_img = false;
491  there_is_imu = false;
492 
494  if (!m_pframe_data) return;
495 
496  // -----------------------------------------------
497  // Extract the observation:
498  // -----------------------------------------------
499  outObservation_img.timestamp = outObservation_imu.timestamp =
501 
502  outObservation_img.setStereoCameraParams(m_options.m_stereo_camera);
503  outObservation_img.imageLeft.loadFromMemoryBuffer(
505  (unsigned char*)reinterpret_cast<PDUOFrame>(m_pframe_data)->leftData);
506 
507  outObservation_img.imageRight.loadFromMemoryBuffer(
509  (unsigned char*)reinterpret_cast<PDUOFrame>(m_pframe_data)->rightData);
510 
511  if (this->m_options.m_capture_rectified)
512  m_rectify_map.rectify(outObservation_img);
513 
514  there_is_img = true;
515 
516  if (this->m_options.m_capture_imu)
517  {
518  if (!reinterpret_cast<PDUOFrame>(m_pframe_data)->accelerometerPresent)
519  {
520  cout << "[CDUO3DCamera] Warning: This device does not provide IMU "
521  "data. No IMU observations will be created."
522  << endl;
523  this->m_options.m_capture_imu = false;
524  }
525  else
526  {
527  // Accelerometer data
528  for (size_t k = 0; k < 3; ++k)
529  {
530  outObservation_imu.rawMeasurements[k] =
531  reinterpret_cast<PDUOFrame>(m_pframe_data)->accelData[k];
532  outObservation_imu.dataIsPresent[k] = true;
533  }
534 
535  // Gyroscopes data
536  for (size_t k = 0; k < 3; ++k)
537  {
538  outObservation_imu.rawMeasurements[k + 3] =
539  reinterpret_cast<PDUOFrame>(m_pframe_data)->gyroData[k];
540  outObservation_imu.dataIsPresent[k + 3] = true;
541  }
542  there_is_imu = true;
543  } // end else
544  } // end-imu-info
545 #endif
546 }
547 
548 /** Closes DUO camera */
550 {
551 #if MRPT_HAS_DUO3D
552  if (!M_DUO_VALUE) return;
553  StopDUO(M_DUO_VALUE);
554  CloseDUO(M_DUO_VALUE);
555  M_DUO_VALUE = nullptr;
556 #endif
557 } // end-close
558 
559 // Waits until the new DUO frame is ready and returns it
561 {
562 #if MRPT_HAS_DUO3D
563  if (M_DUO_VALUE == nullptr) return 0;
564  if (WaitForSingleObject(m_evFrame, 1000) == WAIT_OBJECT_0)
565  return m_pframe_data;
566  else
567  return nullptr;
568 #else
569  return nullptr; // return something to silent compiler warnings.
570 #endif
571 }
572 
574 {
575 #if MRPT_HAS_DUO3D
576  if (M_DUO_VALUE == nullptr) return;
577  SetDUOExposure(M_DUO_VALUE, value);
578 #endif
579 }
580 
581 void CDUO3DCamera::m_set_gain(float value)
582 {
583 #if MRPT_HAS_DUO3D
584  if (M_DUO_VALUE == nullptr) return;
585  SetDUOGain(M_DUO_VALUE, value);
586 #endif
587 }
588 
589 void CDUO3DCamera::m_set_led(float value)
590 {
591 #if MRPT_HAS_DUO3D
592  if (M_DUO_VALUE == nullptr) return;
593  SetDUOLedPWM(M_DUO_VALUE, value);
594 #endif
595 }
596 
597 /** Queries the DUO3D Camera firmware version */
598 bool CDUO3DCamera::queryVersion(std::string version, bool printOutVersion)
599 {
600 #if MRPT_HAS_DUO3D
601  version = std::string(GetLibVersion());
602  if (printOutVersion)
603  std::cout << "DUO3D Camera library version: " << version << std::endl;
604  return true;
605 #else
606  return false;
607 #endif
608 }
uint32_t nrows
Definition: TCamera.h:40
bool queryVersion(std::string version, bool printOutVersion=false)
Queries the DUO3D Camera firmware version.
float m_fps
(Default = 30) Frames per second <= 30.
Definition: CDUO3DCamera.h:39
std::string m_intrinsic_filename
Intrinsic parameters file provided by DUO3D Calibration App (YML format).
Definition: CDUO3DCamera.h:67
std::vector< bool > dataIsPresent
Each entry in this vector is true if the corresponding data index contains valid data (the IMU unit s...
std::string read_string(const std::string &section, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
mrpt::img::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:153
std::vector< double > rawMeasurements
The accelerometer and/or gyroscope measurements taken by the IMU at the given timestamp.
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:67
void * m_get_duo_frame()
Gets a stereo frame from the DUO3D Camera (void* to be reinterpreted as PDUOFrame) ...
std::string std::string format(std::string_view fmt, ARGS &&... args)
Definition: format.h:26
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:160
void m_set_exposure(float value)
Sets DUO3D camera Exposure setting.
float m_exposure
(Default = 50) Exposure value.
Definition: CDUO3DCamera.h:41
void * getEvent()
Returned pointer to be reinterpreted as DUO3D&#39;s "HANDLE".
Definition: CDUO3DCamera.h:221
bool m_calibration_from_file
(Default = true) Get calibration information from files provided by DUO3D Calibration App...
Definition: CDUO3DCamera.h:57
bool m_capture_imu
(Default = false) Capture IMU data.
Definition: CDUO3DCamera.h:51
void * m_pframe_data
Pointer, to be reinterpreted as "PDUOFrame".
Definition: CDUO3DCamera.h:166
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:86
Contains classes for various device interfaces.
mrpt::math::TPose3DQuat asTPose() const
void setFromCamParams(const mrpt::img::TStereoCamera &params)
Prepares the mapping from the intrinsic, distortion and relative pose parameters of a stereo camera...
float read_float(const std::string &section, const std::string &name, float defaultValue, bool failIfNotFound=false) const
std::string m_rectify_map_filename
Rectification map file provided by DUO3D Calibration App (YML format).
Definition: CDUO3DCamera.h:64
STL namespace.
int m_img_width
(Default = 640) Width of the captured image.
Definition: CDUO3DCamera.h:35
This class stores measurements from an Inertial Measurement Unit (IMU) (attitude estimation, raw gyroscope and accelerometer values), altimeters or magnetometers.
mrpt::img::TStereoCamera m_stereo_camera
Definition: CDUO3DCamera.h:75
TYMLReadResult m_camera_ext_params_from_yml(const std::string &_file_name=std::string())
Definition: img/CImage.h:23
std::map< const mrpt::hwdrivers::TCaptureOptions_DUO3D *, TDUOParams > duo_params
int read_int(const std::string &section, const std::string &name, int defaultValue, bool failIfNotFound=false) const
void m_set_gain(float value)
Sets DUO3D camera Gain setting.
cv::Mat m_rectify_map_right_y
mrpt::math::CMatrixDouble33 intrinsicParams
Matrix of intrinsic parameters (containing the focal length and principal point coordinates): ...
Definition: TCamera.h:50
float m_led
(Default = 25) Led intensity (some device models).
Definition: CDUO3DCamera.h:43
void open(const TCaptureOptions_DUO3D &options, const bool startCapture=true)
Tries to open the camera with the given options, and starts capturing.
This class allows loading and storing values and vectors of different types from a configuration text...
This base provides a set of functions for maths stuff.
int m_img_height
(Default = 480) Height of the captured image.
Definition: CDUO3DCamera.h:37
void rectify(const mrpt::img::CImage &in_left_image, const mrpt::img::CImage &in_right_image, mrpt::img::CImage &out_left_image, mrpt::img::CImage &out_right_image) const
Rectify the input image pair and save the result in a different output images - setFromCamParams() mu...
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:45
This namespace contains representation of robot actions and observations.
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...
void loadFromConfigFile(const std::string &section, const mrpt::config::CConfigFileBase &cfg)
Load all the params from a config source, in the same format that used in saveToConfigFile().
void loadOptionsFrom(const mrpt::config::CConfigFileBase &configSource, const std::string &sectionName, const std::string &prefix=std::string())
Loads all the options from a config file.
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:45
Options used when creating a camera capture object of type CImageGrabber_FlyCapture2.
Definition: CDUO3DCamera.h:20
void * m_evFrame
DUO&#39;s HANDLE.
Definition: CDUO3DCamera.h:168
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
std::array< double, 8 > dist
[k1 k2 t1 t2 k3 k4 k5 k6] -> k_i: parameters of radial distortion, t_i: parameters of tangential dist...
Definition: TCamera.h:53
bool empty() const
Definition: ts_hash_map.h:191
Lightweight 3D pose (three spatial coordinates, plus a quaternion ).
Definition: TPose3DQuat.h:19
void setStereoCameraParams(const mrpt::img::TStereoCamera &in_params)
Sets leftCamera, rightCamera and rightCameraPose from a TStereoCamera structure.
TCaptureOptions_DUO3D m_options
Definition: CDUO3DCamera.h:158
#define M_DUO_PTR
void * m_duo
Opaque pointer to DUO&#39;s DUOInstance.
Definition: CDUO3DCamera.h:164
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:60
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
bool read_bool(const std::string &section, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
void startCapture()
Start the actual data capture of the camera.
TCamera leftCamera
Intrinsic and distortion parameters of the left and right cameras.
Definition: TStereoCamera.h:28
mrpt::math::TPose3DQuat rightCameraPose
Pose of the right camera with respect to the coordinate origin of the left camera.
Definition: TStereoCamera.h:31
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:70
void m_set_led(float value)
Sets DUO3D camera LED setting.
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:111
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:62
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:161
uint32_t ncols
Camera resolution.
Definition: TCamera.h:40
void setDataFrame(void *frame)
frame is a reinterpreted PDUOFrame
Definition: CDUO3DCamera.h:223
Structure to hold the parameters of a pinhole stereo camera model.
Definition: TStereoCamera.h:23
bool m_capture_rectified
(Default = true) Rectify images.
Definition: CDUO3DCamera.h:54
void close()
Stop capture and closes the opened camera, if any.
mrpt::img::CImage imageRight
Image from the right camera, only contains a valid image if hasImageRight == true.
cv::Mat m_rectify_map_left_x
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:365
virtual ~CDUO3DCamera()
Destructor.
#define M_DUO_VALUE



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020