CalibrationDialog.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2010-2014, 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 
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         // x -> [0, 1] (left, right)
00085         // y -> [0, 1] (top, bottom)
00086         // size -> [0, 1] (small -> big)
00087         // skew -> [0, 1] (low, high)
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         // parameters
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 } /* namespace rtabmap */
00113 #endif /* CALIBRATIONDIALOG_H_ */


rtabmap
Author(s): Mathieu Labbe
autogenerated on Fri Aug 28 2015 12:51:31