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  int boardWidth() const;
61  int boardHeight() const;
62  double squareSize() const;
63 
64  void saveSettings(QSettings & settings, const QString & group = "") const;
65  void loadSettings(QSettings & settings, const QString & group = "");
66  void resetSettings();
67 
68  void setCameraName(const QString & name);
69  void setProgressVisibility(bool visible);
70  void setSwitchedImages(bool switched);
71  void setFisheyeImages(bool enabled);
72  void setStereoMode(bool stereo, const QString & leftSuffix = "left", const QString & rightSuffix = "right");
73  void setSavingDirectory(const QString & savingDirectory) {savingDirectory_ = savingDirectory;}
74 
75  StereoCameraModel stereoCalibration(const CameraModel & left, const CameraModel & right, bool ignoreStereoRectification) const;
76 
77 public Q_SLOTS:
78  void setBoardWidth(int width);
79  void setBoardHeight(int height);
80  void setSquareSize(double size);
81  void setExpectedStereoBaseline(double length);
82  void setMaxScale(int scale);
83 
84  void processImages(const cv::Mat & imageLeft, const cv::Mat & imageRight, const QString & cameraName);
85  void calibrate();
86  void restart();
87  bool save();
88 
89 private Q_SLOTS:
90  void unlock();
91 
92 protected:
93  virtual void closeEvent(QCloseEvent* event);
94  virtual bool handleEvent(UEvent * event);
95 
96 private:
97  float getArea(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize);
98  float getSkew(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize);
99 
100  // x -> [0, 1] (left, right)
101  // y -> [0, 1] (top, bottom)
102  // size -> [0, 1] (small -> big)
103  // skew -> [0, 1] (low, high)
104  void getParams(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize, const cv::Size & imageSize,
105  float & x, float & y, float & size, float & skew);
106 
107 private:
108  // parameters
109  bool stereo_;
110  QString leftSuffix_;
111  QString rightSuffix_;
113 
114  QString cameraName_;
117 
118  std::vector<std::vector<std::vector<cv::Point2f> > > imagePoints_;
119  std::vector<std::vector<std::vector<float> > > imageParams_;
120  std::vector<std::vector<std::vector<cv::Point2f> > > stereoImagePoints_;
121  std::vector<cv::Size > imageSize_;
122  std::vector<rtabmap::CameraModel> models_;
124  std::vector<unsigned short> minIrs_;
125  std::vector<unsigned short> maxIrs_;
126 
127  Ui_calibrationDialog * ui_;
128 };
129 
130 } /* namespace rtabmap */
131 #endif /* CALIBRATIONDIALOG_H_ */
#define RTABMAPGUI_EXP
Definition: RtabmapGuiExp.h:38
Definition: UEvent.h:57
x
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_
string name
std::vector< rtabmap::CameraModel > models_
const rtabmap::CameraModel & getLeftCameraModel() const
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::StereoCameraModel & getStereoCameraModel() const
std::vector< cv::Size > imageSize_
std::vector< std::vector< std::vector< float > > > imageParams_
Ui_calibrationDialog * ui_
GLM_FUNC_DECL genType::value_type length(genType const &x)


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:37:27