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 RTABMAP_CALIBRATIONDIALOG_H_
00029 #define RTABMAP_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 #include <rtabmap/core/StereoCameraModel.h>
00039
00040 #include <rtabmap/utilite/UEventsHandler.h>
00041
00042 class Ui_calibrationDialog;
00043
00044 namespace rtabmap {
00045
00046 class RTABMAPGUI_EXP CalibrationDialog : public QDialog, public UEventsHandler
00047 {
00048 Q_OBJECT;
00049
00050 public:
00051 CalibrationDialog(bool stereo = false, const QString & savingDirectory = ".", bool switchImages = false, QWidget * parent = 0);
00052 virtual ~CalibrationDialog();
00053
00054 bool isCalibrated() const {return models_[0].isValidForProjection() && (stereo_?models_[1].isValidForProjection():true);}
00055 const rtabmap::CameraModel & getLeftCameraModel() const {return models_[0];}
00056 const rtabmap::CameraModel & getRightCameraModel() const {return models_[1];}
00057 const rtabmap::StereoCameraModel & getStereoCameraModel() const {return stereoModel_;}
00058 bool isProcessing() const {return processingData_;}
00059 int getStereoPairs() const {return (int)stereoImagePoints_[0].size();}
00060
00061 void saveSettings(QSettings & settings, const QString & group = "") const;
00062 void loadSettings(QSettings & settings, const QString & group = "");
00063 void resetSettings();
00064
00065 void setCameraName(const QString & name);
00066 void setProgressVisibility(bool visible);
00067 void setSwitchedImages(bool switched);
00068 void setStereoMode(bool stereo, const QString & leftSuffix = "left", const QString & rightSuffix = "right");
00069 void setSavingDirectory(const QString & savingDirectory) {savingDirectory_ = savingDirectory;}
00070
00071 StereoCameraModel stereoCalibration(const CameraModel & left, const CameraModel & right, bool ignoreStereoRectification) const;
00072
00073 public Q_SLOTS:
00074 void setBoardWidth(int width);
00075 void setBoardHeight(int height);
00076 void setSquareSize(double size);
00077 void setMaxScale(int scale);
00078
00079 void processImages(const cv::Mat & imageLeft, const cv::Mat & imageRight, const QString & cameraName);
00080 void calibrate();
00081 void restart();
00082 bool save();
00083
00084 private Q_SLOTS:
00085 void unlock();
00086
00087 protected:
00088 virtual void closeEvent(QCloseEvent* event);
00089 virtual bool handleEvent(UEvent * event);
00090
00091 private:
00092 float getArea(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize);
00093 float getSkew(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize);
00094
00095
00096
00097
00098
00099 void getParams(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize, const cv::Size & imageSize,
00100 float & x, float & y, float & size, float & skew);
00101
00102 private:
00103
00104 bool stereo_;
00105 QString leftSuffix_;
00106 QString rightSuffix_;
00107 QString savingDirectory_;
00108
00109 QString cameraName_;
00110 bool processingData_;
00111 bool savedCalibration_;
00112
00113 std::vector<std::vector<std::vector<cv::Point2f> > > imagePoints_;
00114 std::vector<std::vector<std::vector<float> > > imageParams_;
00115 std::vector<std::vector<std::vector<cv::Point2f> > > stereoImagePoints_;
00116 std::vector<cv::Size > imageSize_;
00117 std::vector<rtabmap::CameraModel> models_;
00118 rtabmap::StereoCameraModel stereoModel_;
00119 std::vector<unsigned short> minIrs_;
00120 std::vector<unsigned short> maxIrs_;
00121
00122 Ui_calibrationDialog * ui_;
00123 };
00124
00125 }
00126 #endif