Commit e1518c6b authored by Thiago Santini's avatar Thiago Santini

Improves camera calibration interface

parent 58c23648
...@@ -35,8 +35,11 @@ void CameraCalibration::startCalibration() ...@@ -35,8 +35,11 @@ void CameraCalibration::startCalibration()
sampleCount = 0; sampleCount = 0;
sampleCountQL->setText(QString::number(sampleCount)); sampleCountQL->setText(QString::number(sampleCount));
covered = Rect(); covered = Rect();
if (dbgCB->isChecked()) if (dbgCB->isChecked()) {
namedWindow(DBG_WINDOW_NAME); namedWindow(DBG_WINDOW_NAME);
this->activateWindow();
this->setFocus();
}
} }
void CameraCalibration::finishCalibration() void CameraCalibration::finishCalibration()
...@@ -125,6 +128,8 @@ void CameraCalibration::undistortSample(const Mat &frame) ...@@ -125,6 +128,8 @@ void CameraCalibration::undistortSample(const Mat &frame)
else else
cv::undistort(frame, tmp, newCameraMatrix, distCoeffs); cv::undistort(frame, tmp, newCameraMatrix, distCoeffs);
imshow("Undistorted Image", tmp); imshow("Undistorted Image", tmp);
this->activateWindow();
this->setFocus();
undistortPB->setEnabled(true); undistortPB->setEnabled(true);
} }
...@@ -221,7 +226,7 @@ void CameraCalibration::calibrate() ...@@ -221,7 +226,7 @@ void CameraCalibration::calibrate()
fisheye::estimateNewCameraMatrixForUndistortRectify(cameraMatrix, distCoeffs, imageSize, Matx33d::eye(), newCameraMatrix, 1); fisheye::estimateNewCameraMatrixForUndistortRectify(cameraMatrix, distCoeffs, imageSize, Matx33d::eye(), newCameraMatrix, 1);
} else { } else {
rms = calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, rv, tv); rms = calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, rv, tv);
newCameraMatrix = getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, imageSize, 0, imageSize); newCameraMatrix = getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, imageSize, 1, imageSize);
} }
calibrationSuccessful = true; calibrationSuccessful = true;
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <QFileInfo> #include <QFileInfo>
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
#include <QFutureWatcher> #include <QFutureWatcher>
#include <QKeyEvent>
#include "opencv2/imgproc.hpp" #include "opencv2/imgproc.hpp"
#include "opencv2/calib3d.hpp" #include "opencv2/calib3d.hpp"
...@@ -69,10 +70,10 @@ public: ...@@ -69,10 +70,10 @@ public:
fishEyeCB->setEnabled(false); fishEyeCB->setEnabled(false);
formLayout->addRow( new QLabel("Fish Eye"), fishEyeCB ); formLayout->addRow( new QLabel("Fish Eye"), fishEyeCB );
dbgCB = new QCheckBox(); dbgCB = new QCheckBox();
dbgCB->setChecked(false); dbgCB->setChecked(true);
dbgCB->setWhatsThis("Display results from the pattern detection."); dbgCB->setWhatsThis("Display results from the pattern detection.");
dbgCB->setToolTip(dbgCB->whatsThis()); dbgCB->setToolTip(dbgCB->whatsThis());
formLayout->addRow( new QLabel("Show Debug"), dbgCB ); formLayout->addRow( new QLabel("Show Detection"), dbgCB );
patternCB = new QComboBox(); patternCB = new QComboBox();
patternCB->addItem("Assymetric Circles", ASYMMETRIC_CIRCLES_GRID); patternCB->addItem("Assymetric Circles", ASYMMETRIC_CIRCLES_GRID);
patternCB->addItem("Chessboard", CHESSBOARD); patternCB->addItem("Chessboard", CHESSBOARD);
...@@ -185,9 +186,11 @@ private: ...@@ -185,9 +186,11 @@ private:
} }
void setRms() { setLabelText(rmsQL, "N/A", "black"); } void setRms() { setLabelText(rmsQL, "N/A", "black"); }
void setRms(double val) { void setRms(double val) {
if ( val < 1) if ( val <= 0.75) {
setLabelText(rmsQL, QString::number(val), "green"); setLabelText(rmsQL, QString::number(val), "green");
else { } else if (val <= 1 ) {
setLabelText(rmsQL, QString::number(val), "orange");
} else {
setLabelText(rmsQL, QString::number(val), "red"); setLabelText(rmsQL, QString::number(val), "red");
qInfo() << "RMS Error is above the expected value. It's recommended to recalibrate."; qInfo() << "RMS Error is above the expected value. It's recommended to recalibrate.";
} }
...@@ -210,6 +213,27 @@ private slots: ...@@ -210,6 +213,27 @@ private slots:
void startCalibration(); void startCalibration();
void finishCalibration(); void finishCalibration();
void onCalibrated(); void onCalibrated();
void keyReleaseEvent(QKeyEvent *event) {
// TODO: Document these
if (event->isAutoRepeat())
return;
switch (event->key()) {
case Qt::Key_S:
calibrationTogglePB->click();
break;
case Qt::Key_C:
collectPB->click();
break;
case Qt::Key_U:
undistortPB->click();
break;
case Qt::Key_Escape:
this->close();
break;
default:
break;
}
}
}; };
#endif // CAMERACALIBRATION_H #endif // CAMERACALIBRATION_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment