Commit e1518c6b authored by Thiago Santini's avatar Thiago Santini

Improves camera calibration interface

parent 58c23648
......@@ -35,8 +35,11 @@ void CameraCalibration::startCalibration()
sampleCount = 0;
sampleCountQL->setText(QString::number(sampleCount));
covered = Rect();
if (dbgCB->isChecked())
if (dbgCB->isChecked()) {
namedWindow(DBG_WINDOW_NAME);
this->activateWindow();
this->setFocus();
}
}
void CameraCalibration::finishCalibration()
......@@ -125,6 +128,8 @@ void CameraCalibration::undistortSample(const Mat &frame)
else
cv::undistort(frame, tmp, newCameraMatrix, distCoeffs);
imshow("Undistorted Image", tmp);
this->activateWindow();
this->setFocus();
undistortPB->setEnabled(true);
}
......@@ -221,7 +226,7 @@ void CameraCalibration::calibrate()
fisheye::estimateNewCameraMatrixForUndistortRectify(cameraMatrix, distCoeffs, imageSize, Matx33d::eye(), newCameraMatrix, 1);
} else {
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;
}
......
......@@ -18,6 +18,7 @@
#include <QFileInfo>
#include <QtConcurrent/QtConcurrent>
#include <QFutureWatcher>
#include <QKeyEvent>
#include "opencv2/imgproc.hpp"
#include "opencv2/calib3d.hpp"
......@@ -69,10 +70,10 @@ public:
fishEyeCB->setEnabled(false);
formLayout->addRow( new QLabel("Fish Eye"), fishEyeCB );
dbgCB = new QCheckBox();
dbgCB->setChecked(false);
dbgCB->setChecked(true);
dbgCB->setWhatsThis("Display results from the pattern detection.");
dbgCB->setToolTip(dbgCB->whatsThis());
formLayout->addRow( new QLabel("Show Debug"), dbgCB );
formLayout->addRow( new QLabel("Show Detection"), dbgCB );
patternCB = new QComboBox();
patternCB->addItem("Assymetric Circles", ASYMMETRIC_CIRCLES_GRID);
patternCB->addItem("Chessboard", CHESSBOARD);
......@@ -185,9 +186,11 @@ private:
}
void setRms() { setLabelText(rmsQL, "N/A", "black"); }
void setRms(double val) {
if ( val < 1)
if ( val <= 0.75) {
setLabelText(rmsQL, QString::number(val), "green");
else {
} else if (val <= 1 ) {
setLabelText(rmsQL, QString::number(val), "orange");
} else {
setLabelText(rmsQL, QString::number(val), "red");
qInfo() << "RMS Error is above the expected value. It's recommended to recalibrate.";
}
......@@ -210,6 +213,27 @@ private slots:
void startCalibration();
void finishCalibration();
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
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