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-2018, 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 #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_img_width(640),
57  m_img_height(480),
58  m_fps(30),
59  m_exposure(50),
60  m_led(25),
61  m_gain(0),
62  m_capture_imu(false),
63  m_capture_rectified(false),
64  m_calibration_from_file(true),
65  m_rectify_map_filename(""),
66  m_intrinsic_filename(""),
67  m_extrinsic_filename(""),
68  m_stereo_camera(TStereoCamera())
69 {
70  duo_params[this]; // Create
71 }
72 
74 {
75  duo_params.erase(this); // Remove entry
76 }
77 
80 {
81 #if MRPT_HAS_OPENCV
82  const string file_name =
83  _file_name.empty() ? m_rectify_map_filename : _file_name;
84 
85  TDUOParams& dp = duo_params[this];
86 
87  string aux = mrpt::system::extractFileName(file_name);
88  const size_t found = aux.find(
89  mrpt::format("_R%dx%d_", this->m_img_width, this->m_img_height));
90  if (found == std::string::npos)
91  {
93  dp.m_rectify_map_right_x = dp.m_rectify_map_right_y = cv::Mat();
95  }
96  // read file
97  FileStorage fs(file_name, FileStorage::READ);
98  fs["R0X"] >> dp.m_rectify_map_left_x;
99  fs["R0Y"] >> dp.m_rectify_map_left_y;
100  fs["R1X"] >> dp.m_rectify_map_right_x;
101  fs["R1Y"] >> dp.m_rectify_map_right_y;
102 
103  if (dp.m_rectify_map_left_x.size() == Size(0, 0) ||
104  dp.m_rectify_map_left_y.size() == Size(0, 0) ||
105  dp.m_rectify_map_right_x.size() == Size(0, 0) ||
106  dp.m_rectify_map_right_y.size() == Size(0, 0))
107  return yrr_EMPTY;
108 
109  return yrr_OK;
110 #else
111  THROW_EXCEPTION("This function requires building with OpenCV support");
112 #endif
113 }
114 
117  const string& _file_name)
118 {
119 #if MRPT_HAS_OPENCV
120  const string file_name =
121  _file_name.empty() ? m_extrinsic_filename : _file_name;
122 
123  // this will look for R and t matrixes
124  cv::Mat aux_mat;
125  bool empty = false;
126  string aux = mrpt::system::extractFileName(file_name);
127  const size_t found = aux.find(
128  mrpt::format("_R%dx%d_", this->m_img_width, this->m_img_height));
129  if (found == std::string::npos)
130  {
131  m_stereo_camera.rightCameraPose = TPose3DQuat(0, 0, 0, 1.0, 0, 0, 0);
133  }
134  // read file
135  FileStorage fs(file_name, FileStorage::READ);
136  CMatrixDouble33 M;
138  CMatrixDouble44 M2;
139 
140  // rotation matrix
141  fs["R"] >> aux_mat;
142  if (aux_mat.size() == Size(3, 3))
143  {
144  for (size_t k1 = 0; k1 < 3; ++k1)
145  for (size_t k2 = 0; k2 < 3; ++k2)
146  M(k1, k2) = aux_mat.at<double>(k1, k2);
147  }
148  else
149  {
150  empty = true;
151  m_stereo_camera.rightCameraPose = TPose3DQuat(0, 0, 0, 1, 0, 0, 0);
152  }
153 
154  // translation
155  fs["T"] >> aux_mat;
156  if (aux_mat.size() == Size(1, 3))
157  {
158  t(0, 0) = aux_mat.at<double>(0, 0) / 1000.0;
159  t(0, 1) = aux_mat.at<double>(1, 0) / 1000.0;
160  t(0, 2) = aux_mat.at<double>(2, 0) / 1000.0;
161  }
162  else
163  {
164  empty = true;
165  m_stereo_camera.rightCameraPose = TPose3DQuat(0, 0, 0, 1, 0, 0, 0);
166  }
167 
168  if (empty) return yrr_EMPTY;
169 
171  return yrr_OK;
172 #else
173  THROW_EXCEPTION("This function requires building with OpenCV support");
174 #endif
175 }
176 
179  const string& _file_name)
180 {
181 #if MRPT_HAS_OPENCV
182  const string file_name =
183  _file_name.empty() ? m_intrinsic_filename : _file_name;
184 
185  // this will look for M1, D1, M2 and D2 matrixes
186  cv::Mat aux_mat;
187  bool empty = false;
188  string aux = mrpt::system::extractFileName(file_name);
189  const size_t found = aux.find(
190  mrpt::format("_R%dx%d_", this->m_img_width, this->m_img_height));
191  if (found == std::string::npos)
192  {
197 
199  }
200  // read file
201  FileStorage fs(file_name, FileStorage::READ);
202 
203  // left camera
204  fs["M1"] >> aux_mat;
205  if (aux_mat.size() == Size(0, 0))
206  {
207  empty = true;
209  }
211  aux_mat.at<double>(0, 0), aux_mat.at<double>(1, 1),
212  aux_mat.at<double>(0, 2), aux_mat.at<double>(1, 2));
213 
214  fs["D1"] >> aux_mat;
215  if (aux_mat.size() == Size(0, 0))
216  {
217  empty = true;
219  }
221  aux_mat.at<double>(0, 0), aux_mat.at<double>(0, 1),
222  aux_mat.at<double>(0, 2), aux_mat.at<double>(0, 3),
223  aux_mat.at<double>(0, 4));
224 
225  fs["M2"] >> aux_mat;
226  if (aux_mat.size() == Size(0, 0))
227  {
228  empty = true;
230  }
232  aux_mat.at<double>(0, 0), aux_mat.at<double>(1, 1),
233  aux_mat.at<double>(0, 2), aux_mat.at<double>(1, 2));
234 
235  fs["D2"] >> aux_mat;
236  if (aux_mat.size() == Size(0, 0))
237  {
238  empty = true;
240  }
242  aux_mat.at<double>(0, 0), aux_mat.at<double>(0, 1),
243  aux_mat.at<double>(0, 2), aux_mat.at<double>(0, 3),
244  aux_mat.at<double>(0, 4));
245 
246  return empty ? yrr_EMPTY : yrr_OK;
247 #else
248  THROW_EXCEPTION("This function requires building with OpenCV support");
249 #endif
250 }
251 
253  const mrpt::config::CConfigFileBase& configSource,
254  const std::string& iniSection, const std::string& prefix)
255 {
256  m_img_width = configSource.read_int(iniSection, "image_width", m_img_width);
257  m_img_height =
258  configSource.read_int(iniSection, "image_height", m_img_height);
259 
260  m_fps = configSource.read_float(iniSection, "fps", m_fps);
261  m_exposure = configSource.read_float(iniSection, "exposure", m_exposure);
262  m_led = configSource.read_float(iniSection, "led", m_led);
263  m_gain = configSource.read_float(iniSection, "gain", m_gain);
264 
265  m_capture_rectified = configSource.read_bool(
266  iniSection, "capture_rectified", m_capture_rectified);
267  m_capture_imu =
268  configSource.read_bool(iniSection, "capture_imu", m_capture_imu);
269  m_calibration_from_file = configSource.read_bool(
270  iniSection, "calibration_from_file", m_calibration_from_file);
271 
273  {
274  m_intrinsic_filename = configSource.read_string(
275  iniSection, "intrinsic_filename", m_intrinsic_filename);
276  m_extrinsic_filename = configSource.read_string(
277  iniSection, "extrinsic_filename", m_extrinsic_filename);
279  m_img_width;
281  m_img_height;
282  }
283  else
284  m_stereo_camera.loadFromConfigFile("DUO3D", configSource);
285 
287  {
288  m_rectify_map_filename = configSource.read_string(
289  iniSection, "rectify_map_filename", m_rectify_map_filename);
290  } // end-capture-rectified
291 }
292 
293 #if MRPT_HAS_DUO3D
294 static void CALLBACK DUOCallback(const PDUOFrame pFrameData, void* pUserData)
295 {
296  CDUO3DCamera* obj = static_cast<CDUO3DCamera*>(pUserData);
297  obj->setDataFrame(reinterpret_cast<void*>(pFrameData));
298  SetEvent(reinterpret_cast<HANDLE>(obj->getEvent()));
299 }
300 #endif
301 
302 /** Default constructor. */
304  : m_options(TCaptureOptions_DUO3D()), m_duo(nullptr)
305 {
306 #if MRPT_HAS_DUO3D
307  m_duo = new DUOInstance[1];
308  M_DUO_VALUE = nullptr; // m_duo = nullptr;
309 
310  m_pframe_data = nullptr;
311  m_evFrame = CreateEvent(nullptr, FALSE, FALSE, nullptr);
312 #else
314  "MRPT has been compiled with 'MRPT_BUILD_DUO3D'=OFF, so this class "
315  "cannot be used.");
316 #endif
317 } // end-constructor
318 
319 /** Custom initialization and start grabbing constructor. */
321  : m_duo(nullptr)
322 {
323 #if MRPT_HAS_DUO3D
324  m_duo = new DUOInstance[1];
325  M_DUO_VALUE = nullptr; // m_duo = nullptr;
326 
327  m_pframe_data = nullptr;
328  m_evFrame = CreateEvent(nullptr, FALSE, FALSE, nullptr);
329  this->open(options);
330 #else
332  "MRPT has been compiled with 'MRPT_BUILD_DUO3D'=OFF, so this class "
333  "cannot be used.");
334 #endif
335 } // end-constructor
336 
337 /** Destructor */
339 {
340 #if MRPT_HAS_DUO3D
341  this->close();
342  if (m_duo)
343  {
344  delete[] M_DUO_PTR;
345  m_duo = nullptr;
346  }
347 #endif
348 } // end-destructor
349 
350 /** Tries to open the camera with the given options. Raises an exception on
351  * error. \sa close() */
353  const TCaptureOptions_DUO3D& options, const bool startCapture)
354 {
355 #if MRPT_HAS_DUO3D
356  if (M_DUO_VALUE) this->close();
357  this->m_options = options;
358 
360  {
361  // get intrinsic parameters
365  cout << "[CDUO3DCamera] Warning: Some of the intrinsic params "
366  "could not be read (size=0). Check file content."
367  << endl;
369  cout << "[CDUO3DCamera] Warning: Intrinsic params filename is not "
370  "consistent with image size. Are you using the correct "
371  "calibration?. All params set to zero."
372  << endl;
373 
374  // get extrinsic parameters
377  cout << "[CDUO3DCamera] Warning: Some of the extrinsic params "
378  "could not be read (size!=3x3). Check file content."
379  << endl;
381  cout << "[CDUO3DCamera] Warning: Extrinsic params filename is not "
382  "consistent with image size. Are you using the correct "
383  "calibration?. All params set to zero."
384  << endl;
385 
386  if (this->m_options.m_capture_rectified)
387  {
388  if (!this->m_options.m_rectify_map_filename.empty())
389  {
390  // read "rectify_map"
391  res = this->m_options.m_rectify_map_from_yml();
393  cout << "[CDUO3DCamera] Warning: Rectification map could "
394  "not be read (size==0). Check file content."
395  << endl;
397  cout << "[CDUO3DCamera] Warning: Rectification map "
398  "filename is not consistent with image size. Are "
399  "you using the correct calibration?. Rectification "
400  "map set to zero."
401  << endl;
402 
405 
406  // const size_t area =
407  // this->m_options.dp.m_rectify_map_left_x.size().area();
408  TDUOParams& dp = duo_params[&(this->m_options)];
409  const size_t area = dp.m_rectify_map_left_x.size().area();
410  vector<int16_t> v_left_x(area), v_right_x(area);
411  vector<uint16_t> v_left_y(area), v_right_y(area);
412 
413  for (size_t k = 0; k < area; ++k)
414  {
415  v_left_x[k] = dp.m_rectify_map_left_x.at<int16_t>(k);
416  v_left_y[k] = dp.m_rectify_map_left_y.at<uint16_t>(k);
417  v_right_x[k] = dp.m_rectify_map_right_x.at<int16_t>(k);
418  v_right_y[k] = dp.m_rectify_map_right_y.at<uint16_t>(k);
419 
420  // v_left_x[k] =
421  // this->m_options.dp.m_rectify_map_left_x.at<int16_t>(k);
422  // v_left_y[k] =
423  // this->m_options.dp.m_rectify_map_left_y.at<uint16_t>(k);
424  // v_right_x[k] =
425  // this->m_options.dp.m_rectify_map_right_x.at<int16_t>(k);
426  // v_right_y[k] =
427  // this->m_options.dp.m_rectify_map_right_y.at<uint16_t>(k);
428  }
430  // m_rectify_map.setRectifyMaps( v_left_x, v_left_y, v_right_x,
431  // v_right_y );
432  }
433  else
434  {
435  cout << "[CDUO3DCamera] Warning: Calibration information is "
436  "set to be read from a file, but the file was not "
437  "specified. Unrectified images will be grabbed."
438  << endl;
439  }
440  } // end-if
441  } // end-if
442  else if (this->m_options.m_capture_rectified)
443  {
445  }
446 
447  // Find optimal binning parameters for given (width, height)
448  // This maximizes sensor imaging area for given resolution
449  int binning = DUO_BIN_NONE;
450  if (this->m_options.m_img_width <= 752 / 2) binning += DUO_BIN_HORIZONTAL2;
451  if (this->m_options.m_img_height <= 480 / 4)
452  binning += DUO_BIN_VERTICAL4;
453  else if (this->m_options.m_img_height <= 480 / 2)
454  binning += DUO_BIN_VERTICAL2;
455 
456  // Check if we support given resolution (width, height, binning, fps)
457  DUOResolutionInfo ri;
458  if (!EnumerateResolutions(
459  &ri, 1, this->m_options.m_img_width, this->m_options.m_img_height,
460  binning, this->m_options.m_fps))
461  THROW_EXCEPTION("[CDUO3DCamera] Error: Resolution not supported.");
462 
463  if (!OpenDUO(&M_DUO_VALUE)) // was: m_duo
464  THROW_EXCEPTION("[CDUO3DCamera] Error: Camera could not be opened.");
465 
466  // Get and print some DUO parameter values
467  char name[260], version[260];
468  GetDUODeviceName(M_DUO_VALUE, name);
469  GetDUOFirmwareVersion(M_DUO_VALUE, version);
470  cout << "[CDUO3DCamera::open] DUO3DCamera name: " << name << " (v"
471  << version << ")" << endl;
472 
473  // Set selected resolution
474  SetDUOResolutionInfo(M_DUO_VALUE, ri);
475 
476  // Set selected camera settings
477  SetDUOExposure(M_DUO_VALUE, m_options.m_exposure);
478  SetDUOGain(M_DUO_VALUE, m_options.m_gain);
479  SetDUOLedPWM(M_DUO_VALUE, m_options.m_led);
480 
481  // Start capture
482  if (startCapture)
483  {
484  if (!StartDUO(M_DUO_VALUE, DUOCallback, reinterpret_cast<void*>(this)))
486  "[CDUO3DCamera] Error: Camera could not be started.")
487  }
488 
489 #endif
490 } // end-open
491 
492 /*-------------------------------------------------------------
493  getObservations
494 -------------------------------------------------------------*/
496  CObservationStereoImages& outObservation_img,
497  CObservationIMU& outObservation_imu, bool& there_is_img, bool& there_is_imu)
498 {
499 #if MRPT_HAS_DUO3D
500  there_is_img = false;
501  there_is_imu = false;
502 
504  if (!m_pframe_data) return;
505 
506  // -----------------------------------------------
507  // Extract the observation:
508  // -----------------------------------------------
509  outObservation_img.timestamp = outObservation_imu.timestamp =
511 
512  outObservation_img.setStereoCameraParams(m_options.m_stereo_camera);
513  outObservation_img.imageLeft.loadFromMemoryBuffer(
515  (unsigned char*)reinterpret_cast<PDUOFrame>(m_pframe_data)->leftData);
516 
517  outObservation_img.imageRight.loadFromMemoryBuffer(
519  (unsigned char*)reinterpret_cast<PDUOFrame>(m_pframe_data)->rightData);
520 
521  if (this->m_options.m_capture_rectified)
522  m_rectify_map.rectify(outObservation_img);
523 
524  there_is_img = true;
525 
526  if (this->m_options.m_capture_imu)
527  {
528  if (!reinterpret_cast<PDUOFrame>(m_pframe_data)->accelerometerPresent)
529  {
530  cout << "[CDUO3DCamera] Warning: This device does not provide IMU "
531  "data. No IMU observations will be created."
532  << endl;
533  this->m_options.m_capture_imu = false;
534  }
535  else
536  {
537  // Accelerometer data
538  for (size_t k = 0; k < 3; ++k)
539  {
540  outObservation_imu.rawMeasurements[k] =
541  reinterpret_cast<PDUOFrame>(m_pframe_data)->accelData[k];
542  outObservation_imu.dataIsPresent[k] = true;
543  }
544 
545  // Gyroscopes data
546  for (size_t k = 0; k < 3; ++k)
547  {
548  outObservation_imu.rawMeasurements[k + 3] =
549  reinterpret_cast<PDUOFrame>(m_pframe_data)->gyroData[k];
550  outObservation_imu.dataIsPresent[k + 3] = true;
551  }
552  there_is_imu = true;
553  } // end else
554  } // end-imu-info
555 #endif
556 }
557 
558 /** Closes DUO camera */
560 {
561 #if MRPT_HAS_DUO3D
562  if (!M_DUO_VALUE) return;
563  StopDUO(M_DUO_VALUE);
564  CloseDUO(M_DUO_VALUE);
565  M_DUO_VALUE = nullptr;
566 #endif
567 } // end-close
568 
569 // Waits until the new DUO frame is ready and returns it
571 {
572 #if MRPT_HAS_DUO3D
573  if (M_DUO_VALUE == nullptr) return 0;
574  if (WaitForSingleObject(m_evFrame, 1000) == WAIT_OBJECT_0)
575  return m_pframe_data;
576  else
577  return nullptr;
578 #else
579  return nullptr; // return something to silent compiler warnings.
580 #endif
581 }
582 
584 {
585 #if MRPT_HAS_DUO3D
586  if (M_DUO_VALUE == nullptr) return;
587  SetDUOExposure(M_DUO_VALUE, value);
588 #endif
589 }
590 
592 {
593 #if MRPT_HAS_DUO3D
594  if (M_DUO_VALUE == nullptr) return;
595  SetDUOGain(M_DUO_VALUE, value);
596 #endif
597 }
598 
600 {
601 #if MRPT_HAS_DUO3D
602  if (M_DUO_VALUE == nullptr) return;
603  SetDUOLedPWM(M_DUO_VALUE, value);
604 #endif
605 }
606 
607 /** Queries the DUO3D Camera firmware version */
608 bool CDUO3DCamera::queryVersion(std::string version, bool printOutVersion)
609 {
610 #if MRPT_HAS_DUO3D
611  version = std::string(GetLibVersion());
612  if (printOutVersion)
613  std::cout << "DUO3D Camera library version: " << version << std::endl;
614  return true;
615 #else
616  return false;
617 #endif
618 }
uint32_t nrows
Definition: TCamera.h:39
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:40
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:68
std::vector< bool > dataIsPresent
Each entry in this vector is true if the corresponding data index contains valid data (the IMU unit s...
unsigned __int16 uint16_t
Definition: rptypes.h:44
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:154
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:41
void * m_get_duo_frame()
Gets a stereo frame from the DUO3D Camera (void* to be reinterpreted as PDUOFrame) ...
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:148
void m_set_exposure(float value)
Sets DUO3D camera Exposure setting.
#define CALLBACK
Definition: glew.h:111
float m_exposure
(Default = 50) Exposure value.
Definition: CDUO3DCamera.h:42
bool m_calibration_from_file
(Default = true) Get calibration information from files provided by DUO3D Calibration App...
Definition: CDUO3DCamera.h:58
bool m_capture_imu
(Default = false) Capture IMU data.
Definition: CDUO3DCamera.h:52
void * m_pframe_data
Pointer, to be reinterpreted as "PDUOFrame".
Definition: CDUO3DCamera.h:167
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:87
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:65
STL namespace.
int m_img_width
(Default = 640) Width of the captured image.
Definition: CDUO3DCamera.h:36
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:76
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
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:42
float m_led
(Default = 25) Led intensity (some device models).
Definition: CDUO3DCamera.h:44
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.
__int16 int16_t
Definition: rptypes.h:43
int m_img_height
(Default = 480) Height of the captured image.
Definition: CDUO3DCamera.h:38
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:46
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:46
Options used when creating a camera capture object of type CImageGrabber_FlyCapture2.
Definition: CDUO3DCamera.h:21
void * m_evFrame
DUO&#39;s HANDLE.
Definition: CDUO3DCamera.h:169
GLsizei const GLchar ** string
Definition: glext.h:4101
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Lightweight 3D pose (three spatial coordinates, plus a quaternion ).
void setStereoCameraParams(const mrpt::img::TStereoCamera &in_params)
Sets leftCamera, rightCamera and rightCameraPose from a TStereoCamera structure.
std::array< double, 5 > dist
[k1 k2 t1 t2 k3] -> k_i: parameters of radial distortion, t_i: parameters of tangential distortion (d...
Definition: TCamera.h:45
TCaptureOptions_DUO3D m_options
Definition: CDUO3DCamera.h:159
#define M_DUO_PTR
void * m_duo
Opaque pointer to DUO&#39;s DUOInstance.
Definition: CDUO3DCamera.h:165
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:86
bool read_bool(const std::string &section, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
#define FALSE
Definition: xmlParser.h:231
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
GLuint const GLchar * name
Definition: glext.h:4054
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:71
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
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:103
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:162
uint32_t ncols
Camera resolution.
Definition: TCamera.h:39
void setDataFrame(void *frame)
frame is a reinterpreted PDUOFrame
Definition: CDUO3DCamera.h:224
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:55
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:385
virtual ~CDUO3DCamera()
Destructor.
#define M_DUO_VALUE



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020