240 #include <yarp/os/all.h>
241 #include <yarp/dev/all.h>
242 #include <yarp/sig/all.h>
243 #include <yarp/math/Math.h>
245 #include <iCub/ctrl/math.h>
246 #include <iCub/iKin/iKinFwd.h>
247 #include <iCub/stereoVision/stereoCamera.h>
255 #include "StereoMatcher.h"
258 #include <iCub/stereoVision/utils.h>
265 using namespace yarp::os;
266 using namespace yarp::dev;
267 using namespace yarp::sig;
268 using namespace yarp::math;
269 using namespace iCub::ctrl;
270 using namespace iCub::iKin;
272 using namespace cv::ximgproc;
274 class DispModule:
public yarp::os::RFModule
277 Mat outputDm, outputDepth;
278 Mat leftMat, rightMat;
287 yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> > leftImgPort;
288 yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> > rightImgPort;
292 BufferedPort<ImageOf<PixelFloat> > outDepth;
293 BufferedPort<ImageOf<PixelMono> > outDisp;
303 bool runRecalibration;
309 Params stereo_parameters, original_parameters;
312 std::mutex mutexRecalibration;
314 std::mutex mutexDisp;
316 ResourceFinder localCalibration;
319 PolyDriver headCtrl,gazeCtrl;
322 yarp::sig::Vector eyes0,eyes;
329 cv::Mat old_d, old_de;
335 SGM_PARAMS cuda_params, params_right;
338 StereoMatcherNew * matcher;
350 bool loadIntrinsics(yarp::os::ResourceFinder &rf, Mat &KL, Mat &KR, Mat &DistL, Mat &DistR);
362 bool loadConfigurationFile(yarp::os::ResourceFinder& rf, Mat& Ro, Mat& To, yarp::sig::Vector& eyes);
382 Mat buildRotTras(
const Mat& R,
const Mat& T);
384 Matrix getCameraHGazeCtrl(
int camera);
392 void convert(Matrix& matrix, Mat& mat);
400 void convert(Mat& mat, Matrix& matrix);
411 bool loadExtrinsics(yarp::os::ResourceFinder& rf, Mat& Ro, Mat& To, yarp::sig::Vector& eyes);
422 bool updateExtrinsics(Mat& Rot, Mat& Tr, yarp::sig::Vector& eyes,
const string& groupname);
433 bool updateConfigurationFile(Mat& Rot, Mat& Tr, yarp::sig::Vector& eyes,
const string& groupname);
439 void updateViaGazeCtrl(
const bool update);
446 void updateViaKinematics(
const yarp::sig::Vector& deyes);
452 void initializeStereoParams();
462 Mat depthFromDisparity(Mat disp, Mat Q, Mat R);
468 void handleGuiUpdate();
484 bool configure(ResourceFinder &rf);
488 bool interruptModule();
489 bool respond(
const Bottle& command, Bottle& reply);
499 void setDispParameters(
bool _useBestDisp,
int _uniquenessRatio,
int _speckleWindowSize,
500 int _speckleRange,
int _numberOfDisparities,
int _SADWindowSize,
501 int _minDisparity,
int _preFilterCap,
int _disp12MaxDiff);
511 Point3f get3DPoints(
int u,
int v,
const string &drive=
"LEFT");
522 Point2f projectPoint(
const string &camera,
double x,
double y,
double z);
531 void printParameters();
540 cv::Mat refineDisparity(cv::Mat old_disp, cv::Mat new_disp,
int th);
The base class defining stereo camera.