CalibrationDialog.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef RTABMAP_CALIBRATIONDIALOG_H_
29 #define RTABMAP_CALIBRATIONDIALOG_H_
30 
31 #include "rtabmap/gui/RtabmapGuiExp.h" // DLL export/import defines
32 
33 #include <QDialog>
34 #include <QSettings>
35 #include <opencv2/opencv.hpp>
36 
39 
41 
42 class Ui_calibrationDialog;
43 
44 namespace rtabmap {
45 
46 class RTABMAPGUI_EXP CalibrationDialog : public QDialog, public UEventsHandler
47 {
48  Q_OBJECT;
49 
50 public:
51  CalibrationDialog(bool stereo = false, const QString & savingDirectory = ".", bool switchImages = false, QWidget * parent = 0);
52  virtual ~CalibrationDialog();
53 
54  bool isCalibrated() const {return models_[0].isValidForProjection() && (stereo_?models_[1].isValidForProjection():true);}
55  const rtabmap::CameraModel & getLeftCameraModel() const {return models_[0];}
56  const rtabmap::CameraModel & getRightCameraModel() const {return models_[1];}
57  const rtabmap::StereoCameraModel & getStereoCameraModel() const {return stereoModel_;}
58  bool isProcessing() const {return processingData_;}
59  int getStereoPairs() const {return (int)stereoImagePoints_[0].size();}
60 
61  void saveSettings(QSettings & settings, const QString & group = "") const;
62  void loadSettings(QSettings & settings, const QString & group = "");
63  void resetSettings();
64 
65  void setCameraName(const QString & name);
66  void setProgressVisibility(bool visible);
67  void setSwitchedImages(bool switched);
68  void setStereoMode(bool stereo, const QString & leftSuffix = "left", const QString & rightSuffix = "right");
69  void setSavingDirectory(const QString & savingDirectory) {savingDirectory_ = savingDirectory;}
70 
71  StereoCameraModel stereoCalibration(const CameraModel & left, const CameraModel & right, bool ignoreStereoRectification) const;
72 
73 public Q_SLOTS:
74  void setBoardWidth(int width);
75  void setBoardHeight(int height);
76  void setSquareSize(double size);
77  void setMaxScale(int scale);
78 
79  void processImages(const cv::Mat & imageLeft, const cv::Mat & imageRight, const QString & cameraName);
80  void calibrate();
81  void restart();
82  bool save();
83 
84 private Q_SLOTS:
85  void unlock();
86 
87 protected:
88  virtual void closeEvent(QCloseEvent* event);
89  virtual bool handleEvent(UEvent * event);
90 
91 private:
92  float getArea(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize);
93  float getSkew(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize);
94 
95  // x -> [0, 1] (left, right)
96  // y -> [0, 1] (top, bottom)
97  // size -> [0, 1] (small -> big)
98  // skew -> [0, 1] (low, high)
99  void getParams(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize, const cv::Size & imageSize,
100  float & x, float & y, float & size, float & skew);
101 
102 private:
103  // parameters
104  bool stereo_;
105  QString leftSuffix_;
106  QString rightSuffix_;
108 
109  QString cameraName_;
112 
113  std::vector<std::vector<std::vector<cv::Point2f> > > imagePoints_;
114  std::vector<std::vector<std::vector<float> > > imageParams_;
115  std::vector<std::vector<std::vector<cv::Point2f> > > stereoImagePoints_;
116  std::vector<cv::Size > imageSize_;
117  std::vector<rtabmap::CameraModel> models_;
119  std::vector<unsigned short> minIrs_;
120  std::vector<unsigned short> maxIrs_;
121 
122  Ui_calibrationDialog * ui_;
123 };
124 
125 } /* namespace rtabmap */
126 #endif /* CALIBRATIONDIALOG_H_ */
#define RTABMAPGUI_EXP
Definition: RtabmapGuiExp.h:38
Definition: UEvent.h:57
std::vector< std::vector< std::vector< cv::Point2f > > > stereoImagePoints_
GLM_FUNC_DECL detail::tmat4x4< T, P > scale(detail::tmat4x4< T, P > const &m, detail::tvec3< T, P > const &v)
std::vector< unsigned short > minIrs_
std::vector< unsigned short > maxIrs_
const rtabmap::CameraModel & getRightCameraModel() const
void setSavingDirectory(const QString &savingDirectory)
rtabmap::StereoCameraModel stereoModel_
std::vector< std::vector< std::vector< cv::Point2f > > > imagePoints_
std::vector< rtabmap::CameraModel > models_
DiscreteDepthDistortionModel RTABMAP_EXP calibrate(const std::map< int, rtabmap::SensorData > &sequence, const std::map< int, rtabmap::Transform > &trajectory, const pcl::PointCloud< pcl::PointXYZ >::Ptr &map, double coneRadius=0.02, double coneStdevThresh=0.03)
const rtabmap::CameraModel & getLeftCameraModel() const
std::vector< cv::Size > imageSize_
std::vector< std::vector< std::vector< float > > > imageParams_
Ui_calibrationDialog * ui_
const rtabmap::StereoCameraModel & getStereoCameraModel() const


rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:41:30