Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef CALIBRATIONDIALOG_H_
00029 #define CALIBRATIONDIALOG_H_
00030
00031 #include "rtabmap/gui/RtabmapGuiExp.h"
00032
00033 #include <QDialog>
00034 #include <QSettings>
00035 #include <opencv2/opencv.hpp>
00036
00037 #include <rtabmap/core/CameraModel.h>
00038
00039 #include <rtabmap/utilite/UEventsHandler.h>
00040
00041 class Ui_calibrationDialog;
00042
00043 namespace rtabmap {
00044
00045 class RTABMAPGUI_EXP CalibrationDialog : public QDialog, public UEventsHandler
00046 {
00047 Q_OBJECT;
00048
00049 public:
00050 CalibrationDialog(bool stereo = false, const QString & savingDirectory = ".", bool switchImages = false, QWidget * parent = 0);
00051 virtual ~CalibrationDialog();
00052
00053 bool isCalibrated() const {return models_[0].isValid() && (stereo_?models_[1].isValid():true);}
00054 const rtabmap::CameraModel & getLeftCameraModel() const {return models_[0];}
00055 const rtabmap::CameraModel & getRightCameraModel() const {return models_[1];}
00056 const rtabmap::StereoCameraModel & getStereoCameraModel() const {return stereoModel_;}
00057
00058 void saveSettings(QSettings & settings, const QString & group = "") const;
00059 void loadSettings(QSettings & settings, const QString & group = "");
00060
00061 void setSwitchedImages(bool switched);
00062 void setStereoMode(bool stereo);
00063 void setSavingDirectory(const QString & savingDirectory) {savingDirectory_ = savingDirectory;}
00064
00065 public slots:
00066 void setBoardWidth(int width);
00067 void setBoardHeight(int height);
00068 void setSquareSize(double size);
00069
00070 private slots:
00071 void processImages(const cv::Mat & imageLeft, const cv::Mat & imageRight, const QString & cameraName);
00072 void restart();
00073 void calibrate();
00074 bool save();
00075
00076 protected:
00077 virtual void closeEvent(QCloseEvent* event);
00078 virtual void handleEvent(UEvent * event);
00079
00080 private:
00081 float getArea(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize);
00082 float getSkew(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize);
00083
00084
00085
00086
00087
00088 void getParams(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize, const cv::Size & imageSize,
00089 float & x, float & y, float & size, float & skew);
00090
00091 private:
00092
00093 bool stereo_;
00094 QString savingDirectory_;
00095
00096 QString cameraName_;
00097 bool processingData_;
00098 bool savedCalibration_;
00099
00100 std::vector<std::vector<std::vector<cv::Point2f> > > imagePoints_;
00101 std::vector<std::vector<std::vector<float> > > imageParams_;
00102 std::vector<std::vector<std::vector<cv::Point2f> > > stereoImagePoints_;
00103 std::vector<cv::Size > imageSize_;
00104 std::vector<rtabmap::CameraModel> models_;
00105 rtabmap::StereoCameraModel stereoModel_;
00106 std::vector<unsigned short> minIrs_;
00107 std::vector<unsigned short> maxIrs_;
00108
00109 Ui_calibrationDialog * ui_;
00110 };
00111
00112 }
00113 #endif