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 #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
00060 void saveSettings(QSettings & settings, const QString & group = "") const;
00061 void loadSettings(QSettings & settings, const QString & group = "");
00062 void resetSettings();
00063
00064 void setSwitchedImages(bool switched);
00065 void setStereoMode(bool stereo);
00066 void setSavingDirectory(const QString & savingDirectory) {savingDirectory_ = savingDirectory;}
00067
00068 public slots:
00069 void setBoardWidth(int width);
00070 void setBoardHeight(int height);
00071 void setSquareSize(double size);
00072 void setMaxScale(int scale);
00073
00074 private slots:
00075 void processImages(const cv::Mat & imageLeft, const cv::Mat & imageRight, const QString & cameraName);
00076 void restart();
00077 void calibrate();
00078 bool save();
00079 void unlock();
00080
00081 protected:
00082 virtual void closeEvent(QCloseEvent* event);
00083 virtual void handleEvent(UEvent * event);
00084
00085 private:
00086 float getArea(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize);
00087 float getSkew(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize);
00088
00089
00090
00091
00092
00093 void getParams(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize, const cv::Size & imageSize,
00094 float & x, float & y, float & size, float & skew);
00095
00096 private:
00097
00098 bool stereo_;
00099 QString savingDirectory_;
00100
00101 QString cameraName_;
00102 bool processingData_;
00103 bool savedCalibration_;
00104
00105 std::vector<std::vector<std::vector<cv::Point2f> > > imagePoints_;
00106 std::vector<std::vector<std::vector<float> > > imageParams_;
00107 std::vector<std::vector<std::vector<cv::Point2f> > > stereoImagePoints_;
00108 std::vector<cv::Size > imageSize_;
00109 std::vector<rtabmap::CameraModel> models_;
00110 rtabmap::StereoCameraModel stereoModel_;
00111 std::vector<unsigned short> minIrs_;
00112 std::vector<unsigned short> maxIrs_;
00113
00114 Ui_calibrationDialog * ui_;
00115 };
00116
00117 }
00118 #endif