16 #include <mrpt/otherlibs/do_opencv_includes.h> 28 std::map<const mrpt::hwdrivers::TCaptureOptions_DUO3D*,TDUOParams>
duo_params;
36 #define M_DUO_PTR ( reinterpret_cast<DUOInstance*>(m_duo)) 37 #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(
""),
85 if( found == std::string::npos )
94 FileStorage fs( file_name , FileStorage::READ);
120 if( found == std::string::npos )
126 FileStorage fs( file_name , FileStorage::READ);
133 if( aux_mat.size() == Size(3,3) )
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);
147 if( aux_mat.size() == Size(1,3) )
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;
178 if( found == std::string::npos )
188 FileStorage fs( file_name , FileStorage::READ);
192 if( aux_mat.size() == Size(0,0) )
200 if( aux_mat.size() == Size(0,0) )
208 if( aux_mat.size() == Size(0,0) )
216 if( aux_mat.size() == Size(0,0) )
263 static void CALLBACK DUOCallback(
const PDUOFrame pFrameData,
void *pUserData)
267 SetEvent( reinterpret_cast<HANDLE>(
obj->getEvent() ) );
277 m_duo =
new DUOInstance[1];
283 THROW_EXCEPTION(
"MRPT has been compiled with 'MRPT_BUILD_DUO3D'=OFF, so this class cannot be used.");
292 m_duo =
new DUOInstance[1];
297 this->
open( options );
299 THROW_EXCEPTION(
"MRPT has been compiled with 'MRPT_BUILD_DUO3D'=OFF, so this class cannot be used.");
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;
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;
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;
351 vector<int16_t> v_left_x(area), v_right_x(area);
352 vector<uint16_t> v_left_y(area), v_right_y(area);
354 for(
size_t k = 0; k < area; ++k )
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;
382 int binning = DUO_BIN_NONE;
384 binning += DUO_BIN_HORIZONTAL2;
386 binning += DUO_BIN_VERTICAL4;
388 binning += DUO_BIN_VERTICAL2;
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))
402 cout <<
"[CDUO3DCamera::open] DUO3DCamera name: " <<
name <<
" (v" <<
version <<
")" << endl;
415 if(!StartDUO(
M_DUO_VALUE, DUOCallback, reinterpret_cast<void*>(
this)))
416 THROW_EXCEPTION(
"[CDUO3DCamera] Error: Camera could not be started." )
429 bool & there_is_imu )
432 there_is_img =
false;
433 there_is_imu =
false;
448 (
unsigned char*)reinterpret_cast<PDUOFrame>(
m_pframe_data)->leftData);
454 (
unsigned char*)reinterpret_cast<PDUOFrame>(
m_pframe_data)->rightData);
463 if( !reinterpret_cast<PDUOFrame>(
m_pframe_data)->accelerometerPresent )
465 cout <<
"[CDUO3DCamera] Warning: This device does not provide IMU data. No IMU observations will be created." << endl;
471 for(
size_t k = 0; k < 3; ++k)
478 for(
size_t k = 0; k < 3; ++k)
541 if( printOutVersion ) std::cout <<
"DUO3D Camera library version: " <<
version << std::endl;
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.
bool read_bool(const std::string §ion, 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.
std::string m_intrinsic_filename
Intrinsic parameters file provided by DUO3D Calibration App (YML format).
unsigned __int16 uint16_t
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...
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 §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const
void m_set_exposure(float value)
Sets DUO3D camera Exposure setting.
#define THROW_EXCEPTION(msg)
float m_exposure
(Default = 50) Exposure value.
bool m_calibration_from_file
(Default = true) Get calibration information from files provided by DUO3D Calibration App...
bool m_capture_imu
(Default = false) Capture IMU data.
void * m_pframe_data
Pointer, to be reinterpreted as "PDUOFrame".
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Contains classes for various device interfaces.
std::string read_string(const std::string §ion, 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).
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.
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
Structure to hold the parameters of a pinhole stereo camera model.
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 §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
float m_led
(Default = 25) Led intensity (some device models).
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.
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.
int m_img_height
(Default = 480) Height of the captured image.
TCamera rightCamera
Intrinsic and distortion parameters of the left and right cameras.
void setFromCamParams(const mrpt::utils::TStereoCamera ¶ms)
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.
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...
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Options used when creating a camera capture object of type CImageGrabber_FlyCapture2.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
void * m_evFrame
DUO's HANDLE.
GLsizei const GLchar ** string
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
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) ...
void setStereoCameraParams(const mrpt::utils::TStereoCamera &in_params)
Sets leftCamera, rightCamera and rightCameraPose from a TStereoCamera structure.
TCaptureOptions_DUO3D m_options
void * m_duo
Opaque pointer to DUO's DUOInstance.
mrpt::utils::TStereoCamera m_stereo_camera
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 §ion, 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...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void startCapture()
Start the actual data capture of the camera.
uint32_t nrows
Camera resolution.
GLuint const GLchar * name
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...
cv::Mat m_rectify_map_right_x
std::string m_extrinsic_filename
Extrinsic parameters file provided by DUO3D Calibration App (YML format).
GLsizei const GLfloat * value
void m_set_led(float value)
Sets DUO3D camera LED setting.
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...
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
void setDataFrame(void *frame)
frame is a reinterpreted PDUOFrame
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...
bool m_capture_rectified
(Default = true) Rectify images. Rectification map must be provided
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.
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.
virtual ~CDUO3DCamera()
Destructor.