16 #include <mrpt/otherlibs/do_opencv_includes.h>
29 std::map<const mrpt::hwdrivers::TCaptureOptions_DUO3D*, TDUOParams>
duo_params;
37 #define M_DUO_PTR (reinterpret_cast<DUOInstance*>(m_duo))
38 #define M_DUO_VALUE (*M_DUO_PTR)
53 TCaptureOptions_DUO3D::TCaptureOptions_DUO3D()
61 m_capture_rectified(false),
62 m_calibration_from_file(true),
63 m_rectify_map_filename(
""),
64 m_intrinsic_filename(
""),
65 m_extrinsic_filename(
""),
80 const string file_name =
86 const size_t found = aux.find(
88 if (found == std::string::npos)
95 FileStorage fs(file_name, FileStorage::READ);
115 const string& _file_name)
118 const string file_name =
125 const size_t found = aux.find(
127 if (found == std::string::npos)
133 FileStorage fs(file_name, FileStorage::READ);
140 if (aux_mat.size() == Size(3, 3))
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);
154 if (aux_mat.size() == Size(1, 3))
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;
177 const string& _file_name)
180 const string file_name =
187 const size_t found = aux.find(
189 if (found == std::string::npos)
199 FileStorage fs(file_name, FileStorage::READ);
203 if (aux_mat.size() == Size(0, 0))
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));
213 if (aux_mat.size() == Size(0, 0))
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));
224 if (aux_mat.size() == Size(0, 0))
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));
234 if (aux_mat.size() == Size(0, 0))
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));
292 static void CALLBACK DUOCallback(
const PDUOFrame pFrameData,
void* pUserData)
296 SetEvent(
reinterpret_cast<HANDLE
>(
obj->getEvent()));
305 m_duo =
new DUOInstance[1];
312 "MRPT has been compiled with 'MRPT_BUILD_DUO3D'=OFF, so this class "
322 m_duo =
new DUOInstance[1];
330 "MRPT has been compiled with 'MRPT_BUILD_DUO3D'=OFF, so this class "
363 cout <<
"[CDUO3DCamera] Warning: Some of the intrinsic params "
364 "could not be read (size=0). Check file content."
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."
375 cout <<
"[CDUO3DCamera] Warning: Some of the extrinsic params "
376 "could not be read (size!=3x3). Check file content."
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."
391 cout <<
"[CDUO3DCamera] Warning: Rectification map could "
392 "not be read (size==0). Check file content."
395 cout <<
"[CDUO3DCamera] Warning: Rectification map "
396 "filename is not consistent with image size. Are "
397 "you using the correct calibration?. Rectification "
408 vector<int16_t> v_left_x(area), v_right_x(area);
409 vector<uint16_t> v_left_y(area), v_right_y(area);
411 for (
size_t k = 0; k < area; ++k)
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."
447 int binning = DUO_BIN_NONE;
450 binning += DUO_BIN_VERTICAL4;
452 binning += DUO_BIN_VERTICAL2;
455 DUOResolutionInfo ri;
456 if (!EnumerateResolutions(
458 binning, this->m_options.m_fps))
465 char name[260], version[260];
468 cout <<
"[CDUO3DCamera::open] DUO3DCamera name: " <<
name <<
" (v"
469 << version <<
")" << endl;
482 if (!StartDUO(
M_DUO_VALUE, DUOCallback,
reinterpret_cast<void*
>(
this)))
484 "[CDUO3DCamera] Error: Camera could not be started.")
495 CObservationIMU& outObservation_imu,
bool& there_is_img,
bool& there_is_imu)
498 there_is_img =
false;
499 there_is_imu =
false;
513 (
unsigned char*)
reinterpret_cast<PDUOFrame
>(
m_pframe_data)->leftData);
517 (
unsigned char*)
reinterpret_cast<PDUOFrame
>(
m_pframe_data)->rightData);
526 if (!
reinterpret_cast<PDUOFrame
>(
m_pframe_data)->accelerometerPresent)
528 cout <<
"[CDUO3DCamera] Warning: This device does not provide IMU "
529 "data. No IMU observations will be created."
536 for (
size_t k = 0; k < 3; ++k)
544 for (
size_t k = 0; k < 3; ++k)
572 if (WaitForSingleObject(
m_evFrame, 1000) == WAIT_OBJECT_0)
611 std::cout <<
"DUO3D Camera library version: " << version << std::endl;
std::map< const mrpt::hwdrivers::TCaptureOptions_DUO3D *, TDUOParams > duo_params
This "software driver" implements the communication protocol for interfacing a DUO3D Stereo Camera.
mrpt::vision::CStereoRectifyMap m_rectify_map
void m_set_gain(float value)
Sets DUO3D camera Gain setting
virtual ~CDUO3DCamera()
Destructor
bool queryVersion(std::string version, bool printOutVersion=false)
Queries the DUO3D Camera firmware version.
void startCapture()
Start the actual data capture of the camera.
void * m_get_duo_frame()
Gets a stereo frame from the DUO3D Camera (void* to be reinterpreted as PDUOFrame)
CDUO3DCamera()
Default Constructor (does not open the camera)
void * m_pframe_data
Pointer, to be reinterpreted as "PDUOFrame".
void m_set_led(float value)
Sets DUO3D camera LED setting
void open(const TCaptureOptions_DUO3D &options, const bool startCapture=true)
Tries to open the camera with the given options, and starts capturing.
void * m_duo
Opaque pointer to DUO's DUOInstance.
void setDataFrame(void *frame)
frame is a reinterpreted PDUOFrame
void m_set_exposure(float value)
Sets DUO3D camera Exposure setting.
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 close()
Stop capture and closes the opened camera, if any.
void * m_evFrame
DUO's HANDLE.
TCaptureOptions_DUO3D m_options
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
This class stores measurements from an Inertial Measurement Unit (IMU) (attitude estimation,...
std::vector< double > rawMeasurements
The accelerometer and/or gyroscope measurements taken by the IMU at the given timestamp.
vector_bool dataIsPresent
Each entry in this vector is true if the corresponding data index contains valid data (the IMU unit s...
Observation class for either a pair of left+right or left+disparity images from a stereo camera.
mrpt::utils::CImage imageRight
Image from the right camera, only contains a valid image if hasImageRight == true.
void setStereoCameraParams(const mrpt::utils::TStereoCamera &in_params)
Sets leftCamera, rightCamera and rightCameraPose from a TStereoCamera structure.
mrpt::utils::CImage imageLeft
Image from the left camera (this image will be ALWAYS present)
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,...
This class allows loading and storing values and vectors of different types from a configuration text...
bool read_bool(const std::string §ion, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
std::string read_string(const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
float read_float(const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const
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.
mrpt::math::CArrayDouble< 5 > dist
[k1 k2 t1 t2 k3] -> k_i: parameters of radial distortion, t_i: parameters of tangential distortion (d...
uint32_t ncols
Camera resolution.
mrpt::math::CMatrixDouble33 intrinsicParams
Matrix of intrinsic parameters (containing the focal length and principal point coordinates)
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...
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...
Structure to hold the parameters of a pinhole stereo camera model.
mrpt::poses::CPose3DQuat rightCameraPose
Pose of the right camera with respect to the coordinate origin of the left camera.
void loadFromConfigFile(const std::string §ion, const mrpt::utils::CConfigFileBase &cfg)
Load all the params from a config source, in the same format that used in saveToConfigFile().
TCamera leftCamera
Intrinsic and distortion parameters of the left and right cameras.
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...
void setFromCamParams(const mrpt::utils::TStereoCamera ¶ms)
Prepares the mapping from the intrinsic, distortion and relative pose parameters of a stereo camera.
EIGEN_STRONG_INLINE bool empty() const
GLsizei GLsizei GLuint * obj
GLuint const GLchar * name
GLsizei const GLfloat * value
GLsizei const GLchar ** string
std::string extractFileName(const std::string &filePath)
Extract just the name (without extension) of a filename from a complete path plus name plus extension...
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
#define THROW_EXCEPTION(msg)
Contains classes for various device interfaces.
This base provides a set of functions for maths stuff.
This namespace contains representation of robot actions and observations.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
unsigned __int16 uint16_t
cv::Mat m_rectify_map_right_y
cv::Mat m_rectify_map_right_x
cv::Mat m_rectify_map_left_x
cv::Mat m_rectify_map_left_y
Options used when creating a camera capture object of type CImageGrabber_FlyCapture2.
mrpt::utils::TStereoCamera m_stereo_camera
int m_img_width
(Default = 640) Width of the captured image.
TYMLReadResult m_rectify_map_from_yml(const std::string &_file_name=std::string())
float m_gain
(Default = 10) Camera gain.
bool m_capture_imu
(Default = false) Capture IMU data.
float m_led
(Default = 25) Led intensity (some device models).
float m_fps
(Default = 30) Frames per second <= 30.
@ yrr_NAME_NON_CONSISTENT
bool m_capture_rectified
(Default = true) Rectify images.
bool m_calibration_from_file
(Default = true) Get calibration information from files provided by DUO3D Calibration App.
TYMLReadResult m_camera_int_params_from_yml(const std::string &_file_name=std::string())
int m_img_height
(Default = 480) Height of the captured image.
std::string m_rectify_map_filename
Rectification map file provided by DUO3D Calibration App (YML format).
std::string m_intrinsic_filename
Intrinsic parameters file provided by DUO3D Calibration App (YML format).
void loadOptionsFrom(const mrpt::utils::CConfigFileBase &configSource, const std::string §ionName, const std::string &prefix=std::string())
Loads all the options from a config file.
float m_exposure
(Default = 50) Exposure value.
std::string m_extrinsic_filename
Extrinsic parameters file provided by DUO3D Calibration App (YML format).
TYMLReadResult m_camera_ext_params_from_yml(const std::string &_file_name=std::string())