CalibrationDialog.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of the Universite de Sherbrooke nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00020 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 */
00027 
00028 #ifndef CALIBRATIONDIALOG_H_
00029 #define CALIBRATIONDIALOG_H_
00030 
00031 #include "rtabmap/gui/RtabmapGuiExp.h" // DLL export/import defines
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         // x -> [0, 1] (left, right)
00090         // y -> [0, 1] (top, bottom)
00091         // size -> [0, 1] (small -> big)
00092         // skew -> [0, 1] (low, high)
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         // parameters
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 } /* namespace rtabmap */
00118 #endif /* CALIBRATIONDIALOG_H_ */


rtabmap
Author(s): Mathieu Labbe
autogenerated on Sat Jul 23 2016 11:44:15