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 setFisheyeImages(bool enabled);
69  void setStereoMode(bool stereo, const QString & leftSuffix = "left", const QString & rightSuffix = "right");
70  void setSavingDirectory(const QString & savingDirectory) {savingDirectory_ = savingDirectory;}
71 
72  StereoCameraModel stereoCalibration(const CameraModel & left, const CameraModel & right, bool ignoreStereoRectification) const;
73 
74 public Q_SLOTS:
75  void setBoardWidth(int width);
76  void setBoardHeight(int height);
77  void setSquareSize(double size);
78  void setMaxScale(int scale);
79 
80  void processImages(const cv::Mat & imageLeft, const cv::Mat & imageRight, const QString & cameraName);
81  void calibrate();
82  void restart();
83  bool save();
84 
85 private Q_SLOTS:
86  void unlock();
87 
88 protected:
89  virtual void closeEvent(QCloseEvent* event);
90  virtual bool handleEvent(UEvent * event);
91 
92 private:
93  float getArea(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize);
94  float getSkew(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize);
95 
96  // x -> [0, 1] (left, right)
97  // y -> [0, 1] (top, bottom)
98  // size -> [0, 1] (small -> big)
99  // skew -> [0, 1] (low, high)
100  void getParams(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize, const cv::Size & imageSize,
101  float & x, float & y, float & size, float & skew);
102 
103 private:
104  // parameters
105  bool stereo_;
106  QString leftSuffix_;
107  QString rightSuffix_;
109 
110  QString cameraName_;
113 
114  std::vector<std::vector<std::vector<cv::Point2f> > > imagePoints_;
115  std::vector<std::vector<std::vector<float> > > imageParams_;
116  std::vector<std::vector<std::vector<cv::Point2f> > > stereoImagePoints_;
117  std::vector<cv::Size > imageSize_;
118  std::vector<rtabmap::CameraModel> models_;
120  std::vector<unsigned short> minIrs_;
121  std::vector<unsigned short> maxIrs_;
122 
123  Ui_calibrationDialog * ui_;
124 };
125 
126 } /* namespace rtabmap */
127 #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 Mon Dec 14 2020 03:34:58