Commit 9a49047c authored by Thiago Santini's avatar Thiago Santini

Field image processor now uses the camera calibration class

parent 862ae24b
...@@ -47,6 +47,7 @@ void CameraCalibration::startCalibration() ...@@ -47,6 +47,7 @@ void CameraCalibration::startCalibration()
void CameraCalibration::finishCalibration() void CameraCalibration::finishCalibration()
{ {
calibrated = false;
QFuture<void> future = QtConcurrent::run(this, &CameraCalibration::calibrate); QFuture<void> future = QtConcurrent::run(this, &CameraCalibration::calibrate);
watcher.setFuture(future); watcher.setFuture(future);
} }
...@@ -54,12 +55,12 @@ void CameraCalibration::finishCalibration() ...@@ -54,12 +55,12 @@ void CameraCalibration::finishCalibration()
void CameraCalibration::onCalibrated() void CameraCalibration::onCalibrated()
{ {
this->layout()->setEnabled(true); this->layout()->setEnabled(true);
updateCalibrationStatus( calibrationSuccessful ); updateCalibrationStatus( calibrated );
calibrationTogglePB->setText("Start"); calibrationTogglePB->setText("Start");
calibrationTogglePB->setEnabled(true); calibrationTogglePB->setEnabled(true);
undistortPB->setEnabled(true); undistortPB->setEnabled(true);
settingsGB->setEnabled(true); settingsGB->setEnabled(true);
emit calibrationFinished( calibrationSuccessful ); emit calibrationFinished( calibrated );
} }
void CameraCalibration::updateCalibrationStatus(bool success) void CameraCalibration::updateCalibrationStatus(bool success)
...@@ -121,15 +122,13 @@ void CameraCalibration::newSample(const Mat &frame) ...@@ -121,15 +122,13 @@ void CameraCalibration::newSample(const Mat &frame)
undistortSample(frame); undistortSample(frame);
} }
void CameraCalibration::undistortSample(const Mat &frame) void CameraCalibration::undistortSample(const Mat &frame)
{ {
if (undistortPB->isEnabled()) if (undistortPB->isEnabled())
return; return;
Mat tmp; Mat tmp;
if (fishEyeCB->isChecked()) undistort(frame, tmp);
remap(frame, tmp, map1, map2, CV_INTER_AREA);
else
remap(frame, tmp, map1, map2, CV_INTER_AREA);
imshow("Undistorted Image", tmp); imshow("Undistorted Image", tmp);
this->activateWindow(); this->activateWindow();
this->setFocus(); this->setFocus();
...@@ -153,7 +152,7 @@ void CameraCalibration::processSample(const Mat &frame) ...@@ -153,7 +152,7 @@ void CameraCalibration::processSample(const Mat &frame)
Size patternSize( hPatternSizeSB->value(), vPatternSizeSB->value() ); Size patternSize( hPatternSizeSB->value(), vPatternSizeSB->value() );
int chessBoardFlags = CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_NORMALIZE_IMAGE; int chessBoardFlags = CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_NORMALIZE_IMAGE;
if( !fishEyeCB->isChecked()) if( !fishEye)
chessBoardFlags |= CALIB_CB_FAST_CHECK; chessBoardFlags |= CALIB_CB_FAST_CHECK;
switch( patternCB->currentData().toInt() ) switch( patternCB->currentData().toInt() )
...@@ -204,16 +203,36 @@ void CameraCalibration::processSample(const Mat &frame) ...@@ -204,16 +203,36 @@ void CameraCalibration::processSample(const Mat &frame)
collectPB->setEnabled(true); collectPB->setEnabled(true);
} }
void CameraCalibration::internalInitUndistortRectifyMap()
{
float alpha = 1;
if (fishEye) {
fisheye::estimateNewCameraMatrixForUndistortRectify(cameraMatrix, distCoeffs, imageSize, Matx33d::eye(), newCameraMatrix, alpha, imageSize);
fisheye::initUndistortRectifyMap(cameraMatrix, distCoeffs, Matx33d::eye(),
newCameraMatrix, imageSize, CV_16SC2,
map1, map2
);
} else {
newCameraMatrix = getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, imageSize, alpha, imageSize);
initUndistortRectifyMap(cameraMatrix, distCoeffs, Mat(),
newCameraMatrix, imageSize, CV_16SC2,
map1, map2
);
}
}
void CameraCalibration::calibrate() void CameraCalibration::calibrate()
{ {
calibrated = false;
qInfo() << "Calibrating, this might take some time; please wait."; qInfo() << "Calibrating, this might take some time; please wait.";
cameraMatrix = Mat::eye(3, 3, CV_64F); cameraMatrix = Mat::eye(3, 3, CV_64F);
if (fishEyeCB->isChecked()) fishEye = fishEyeCB->isChecked();
if (fishEye)
distCoeffs = Mat::zeros(4, 1, CV_64F); distCoeffs = Mat::zeros(4, 1, CV_64F);
else else
distCoeffs = Mat::zeros(8, 1, CV_64F); distCoeffs = Mat::zeros(8, 1, CV_64F);
calibrationSuccessful = false;
rms = 0; rms = 0;
if (imagePoints.size() < 5) if (imagePoints.size() < 5)
...@@ -225,28 +244,20 @@ void CameraCalibration::calibrate() ...@@ -225,28 +244,20 @@ void CameraCalibration::calibrate()
try { try {
Mat rv, tv; Mat rv, tv;
if (fishEyeCB->isChecked()) { if (fishEye) {
int fisheyeFlags = 0; int fisheyeFlags = 0;
fisheyeFlags |= fisheye::CALIB_RECOMPUTE_EXTRINSIC; fisheyeFlags |= fisheye::CALIB_RECOMPUTE_EXTRINSIC;
fisheyeFlags |= fisheye::CALIB_CHECK_COND; fisheyeFlags |= fisheye::CALIB_CHECK_COND;
fisheyeFlags |= fisheye::CALIB_FIX_SKEW; fisheyeFlags |= fisheye::CALIB_FIX_SKEW;
rms = fisheye::calibrate(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, rv, tv, fisheyeFlags); rms = fisheye::calibrate(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, rv, tv, fisheyeFlags);
fisheye::estimateNewCameraMatrixForUndistortRectify(cameraMatrix, distCoeffs, imageSize, Matx33d::eye(), newCameraMatrix, 1, imageSize);
fisheye::initUndistortRectifyMap(cameraMatrix, distCoeffs, Matx33d::eye(),
newCameraMatrix, imageSize, CV_16SC2,
map1, map2);
} 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, 1, imageSize);
initUndistortRectifyMap( cameraMatrix, distCoeffs, Mat(),
newCameraMatrix, imageSize, CV_16SC2,
map1, map2
);
} }
calibrationSuccessful = true; internalInitUndistortRectifyMap();
calibrated = true;
} catch (cv::Exception &e) { } catch (cv::Exception &e) {
qWarning() << "Calibration failed:" << e.what(); qWarning() << "Calibration failed:" << e.what();
calibrationSuccessful = false; calibrated = false;
} }
} }
...@@ -260,14 +271,14 @@ void CameraCalibration::store(const QString &fileName) ...@@ -260,14 +271,14 @@ void CameraCalibration::store(const QString &fileName)
fs << "sampleCount" << sampleCount; fs << "sampleCount" << sampleCount;
fs << "coverage" << coverage; fs << "coverage" << coverage;
fs << "rms" << rms; fs << "rms" << rms;
fs << "fisheye" << fishEyeCB->isChecked(); fs << "fishEye" << fishEye;
} }
void CameraCalibration::load(const QString &fileName) void CameraCalibration::load(const QString &fileName)
{ {
QFileInfo info(fileName); QFileInfo info(fileName);
if ( !info.exists() ) { if ( !info.exists() ) {
calibrationSuccessful = false; calibrated = false;
} else { } else {
FileStorage fs( QString(fileName).toStdString(), FileStorage::READ); FileStorage fs( QString(fileName).toStdString(), FileStorage::READ);
fs["cameraMatrix"] >> cameraMatrix; fs["cameraMatrix"] >> cameraMatrix;
...@@ -277,19 +288,10 @@ void CameraCalibration::load(const QString &fileName) ...@@ -277,19 +288,10 @@ void CameraCalibration::load(const QString &fileName)
fs["sampleCount"] >> sampleCount; fs["sampleCount"] >> sampleCount;
fs["coverage"] >> coverage; fs["coverage"] >> coverage;
fs["rms"] >> rms; fs["rms"] >> rms;
bool isFisheye; fs["fishEye"] >> fishEye;
fs["fisheye"] >> isFisheye; fishEyeCB->setChecked(fishEye);
calibrationSuccessful = true; internalInitUndistortRectifyMap();
if (isFisheye) { calibrated = true;
fisheye::initUndistortRectifyMap(cameraMatrix, distCoeffs, Matx33d::eye(),
newCameraMatrix, imageSize, CV_16SC2,
map1, map2);
} else {
initUndistortRectifyMap( cameraMatrix, distCoeffs, Mat(),
newCameraMatrix, imageSize, CV_32FC1,
map1, map2
);
}
} }
updateCalibrationStatus(calibrationSuccessful); updateCalibrationStatus(calibrated);
} }
...@@ -32,7 +32,7 @@ class CameraCalibration : public QDialog ...@@ -32,7 +32,7 @@ class CameraCalibration : public QDialog
public: public:
CameraCalibration(QString id, QWidget *parent=0) CameraCalibration(QString id, QWidget *parent=0)
: QDialog(parent), : QDialog(parent),
calibrationSuccessful(false), calibrated(false),
sampleCount(0), sampleCount(0),
coverage(0), coverage(0),
id(id) id(id)
...@@ -129,15 +129,39 @@ public: ...@@ -129,15 +129,39 @@ public:
CHESSBOARD = 2, CHESSBOARD = 2,
}; };
cv::Mat cameraMatrix;
cv::Mat newCameraMatrix; void undistort(const cv::Mat &in, cv::Mat &out) {
cv::Mat distCoeffs; if ( !calibrated || in.cols != imageSize.width || in.rows != imageSize.height ) {
cv::Size imageSize; out = in.clone();
cv::Rect covered; return;
int sampleCount; }
double coverage;
double rms; if (fishEye)
bool calibrationSuccessful; remap(in, out, map1, map2, CV_INTER_AREA);
else
remap(in, out, map1, map2, CV_INTER_AREA);
}
cv::Mat getCameraMatrix(cv::Size size) {
if ( !calibrated || size != imageSize ) {
return (cv::Mat_<double>(3,3) <<
size.width, 0, 0.5*size.width,
0, size.width, 0.5*size.height,
0, 0 ,1 );
}
return cameraMatrix;
}
cv::Mat getDistortionCoefficients(cv::Size size) {
if ( !calibrated || size != imageSize )
return (cv::Mat_<double>(4,1) << 0, 0, 0, 0);
// our coefficients are k1,k2,k3,k4, but estimatePoseSingleMarkers wants (k1,k2,p1,p2[,k3[,k4,k5,k6],[s1,s2,s3,s4]])
if (fishEye)
return (cv::Mat_<double>(4,1) << distCoeffs.at<double>(0,0), distCoeffs.at<double>(1,0), 0, 0);
else
return distCoeffs;
}
signals: signals:
void requestSample(); void requestSample();
...@@ -176,6 +200,16 @@ private: ...@@ -176,6 +200,16 @@ private:
QFutureWatcher<void> watcher; QFutureWatcher<void> watcher;
std::vector<std::vector<cv::Point2f> > imagePoints; std::vector<std::vector<cv::Point2f> > imagePoints;
cv::Mat cameraMatrix;
cv::Mat newCameraMatrix;
cv::Mat distCoeffs;
cv::Size imageSize;
cv::Rect covered;
int sampleCount;
double coverage;
double rms;
bool fishEye;
std::atomic<bool> calibrated;
cv::Mat map1, map2; cv::Mat map1, map2;
void processSample(const cv::Mat &frame); void processSample(const cv::Mat &frame);
...@@ -183,6 +217,7 @@ private: ...@@ -183,6 +217,7 @@ private:
void calculateBoardCorners(std::vector<cv::Point3f> &corners); void calculateBoardCorners(std::vector<cv::Point3f> &corners);
void calibrate(); void calibrate();
void updateCalibrationStatus(bool success); void updateCalibrationStatus(bool success);
void internalInitUndistortRectifyMap();
void setLabelText(QLabel* label, QString val, QString color) { void setLabelText(QLabel* label, QString val, QString color) {
label->setStyleSheet("QLabel { font : bold; color : " + color + " }"); label->setStyleSheet("QLabel { font : bold; color : " + color + " }");
label->setText( val ); label->setText( val );
......
...@@ -53,15 +53,23 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren ...@@ -53,15 +53,23 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren
this, SLOT(noCamera(QString))); this, SLOT(noCamera(QString)));
// debugging preview // debugging preview
//connect(camera, SIGNAL(newFrame(Timestamp, const cv::Mat&)), //connect(camera, SIGNAL(newFrame(Timestamp, const cv::Mat&)),
// this, SLOT(preview(Timestamp, const cv::Mat&)) ); // this, SLOT(preview(Timestamp, const cv::Mat&)) );
cameraCalibration = new CameraCalibration(id);
connect(cameraCalibration, SIGNAL(requestSample()),
this, SLOT(requestCameraCalibrationSample()) );
connect(cameraCalibration, SIGNAL(calibrationFinished(bool)),
this, SLOT(onCameraCalibrationFinished(bool)) );
cameraCalibration->load(gCfgDir + "/" + id + "Calibration.xml");
// Image Processor // Image Processor
processorThread = new QThread(); processorThread = new QThread();
processorThread->setObjectName(id + " Processor"); processorThread->setObjectName(id + " Processor");
processorThread->start(); processorThread->start();
processorThread->setPriority(QThread::TimeCriticalPriority); processorThread->setPriority(QThread::TimeCriticalPriority);
imageProcessor = new ImageProcessor(id, type); imageProcessor = new ImageProcessor(id, type);
imageProcessor->moveToThread(processorThread); imageProcessor->cameraCalibration = cameraCalibration;
imageProcessor->moveToThread(processorThread);
switch (type) { switch (type) {
case ImageProcessor::Eye: case ImageProcessor::Eye:
imageProcessor->eyeProcessorUI = new EyeImageProcessorUI; imageProcessor->eyeProcessorUI = new EyeImageProcessorUI;
...@@ -70,8 +78,8 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren ...@@ -70,8 +78,8 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren
connect(imageProcessor, SIGNAL(newData(EyeData)), connect(imageProcessor, SIGNAL(newData(EyeData)),
this, SIGNAL(newData(EyeData)) ); this, SIGNAL(newData(EyeData)) );
break; break;
case ImageProcessor::Field: case ImageProcessor::Field:
imageProcessor->fieldProcessorUI = new FieldImageProcessorUI; imageProcessor->fieldProcessorUI = new FieldImageProcessorUI;
connect(imageProcessor, SIGNAL(newData(FieldData)), connect(imageProcessor, SIGNAL(newData(FieldData)),
this, SLOT(preview(FieldData)) ); this, SLOT(preview(FieldData)) );
connect(imageProcessor, SIGNAL(newData(FieldData)), connect(imageProcessor, SIGNAL(newData(FieldData)),
...@@ -79,7 +87,7 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren ...@@ -79,7 +87,7 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren
break; break;
} }
QMetaObject::invokeMethod(imageProcessor, "create"); QMetaObject::invokeMethod(imageProcessor, "create");
connect(camera, SIGNAL(newFrame(Timestamp, const cv::Mat&)), connect(camera, SIGNAL(newFrame(Timestamp, const cv::Mat&)),
imageProcessor, SIGNAL(process(Timestamp, const cv::Mat&)) ); imageProcessor, SIGNAL(process(Timestamp, const cv::Mat&)) );
// Data Recorder // Data Recorder
...@@ -91,13 +99,6 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren ...@@ -91,13 +99,6 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren
recorder->moveToThread(recorderThread); recorder->moveToThread(recorderThread);
QMetaObject::invokeMethod(recorder, "create"); QMetaObject::invokeMethod(recorder, "create");
cameraCalibration = new CameraCalibration(id);
connect(cameraCalibration, SIGNAL(requestSample()),
this, SLOT(requestCameraCalibrationSample()) );
connect(cameraCalibration, SIGNAL(calibrationFinished(bool)),
this, SLOT(onCameraCalibrationFinished(bool)) );
cameraCalibration->load(gCfgDir + "/" + id + "Calibration.xml");
// GUI // GUI
optionsGroup = new QActionGroup(this); optionsGroup = new QActionGroup(this);
connect(optionsGroup, SIGNAL(triggered(QAction*)), connect(optionsGroup, SIGNAL(triggered(QAction*)),
......
...@@ -11,8 +11,9 @@ FieldImageProcessor::FieldImageProcessor(QString id, QObject *parent) ...@@ -11,8 +11,9 @@ FieldImageProcessor::FieldImageProcessor(QString id, QObject *parent)
: id(id), : id(id),
sROI(QPointF(0,0)), sROI(QPointF(0,0)),
eROI(QPointF(1,1)), eROI(QPointF(1,1)),
forceSanitize(false), forceSanitize(false),
QObject(parent) cameraCalibration(NULL),
QObject(parent)
{ {
settings = new QSettings(gCfgDir + "/" + id + " ImageProcessor", QSettings::IniFormat); settings = new QSettings(gCfgDir + "/" + id + " ImageProcessor", QSettings::IniFormat);
updateConfig(); updateConfig();
...@@ -59,16 +60,21 @@ void FieldImageProcessor::process(Timestamp timestamp, const Mat &frame) ...@@ -59,16 +60,21 @@ void FieldImageProcessor::process(Timestamp timestamp, const Mat &frame)
} }
if (cfg.flip != CV_FLIP_NONE) if (cfg.flip != CV_FLIP_NONE)
flip(data.input, data.input, cfg.flip); flip(data.input, data.input, cfg.flip);
sanitizeCameraParameters( Size(data.input.cols, data.input.rows) ); sanitizeCameraParameters( Size(data.input.cols, data.input.rows) );
data.undistorted = cfg.undistort; data.undistorted = cfg.undistort;
if (data.undistorted) if (data.undistorted) {
remap(data.input, data.input, map1, map2, CV_INTER_AREA); if (cameraCalibration) {
Mat tmp;
cameraCalibration->undistort(data.input, tmp);
data.input = tmp;
}
}
data.width = data.input.cols; data.width = data.input.cols;
data.height = data.input.rows; data.height = data.input.rows;
// Marker detection and pose estimation // Marker detection and pose estimation
vector<int> ids; vector<int> ids;
...@@ -84,7 +90,6 @@ void FieldImageProcessor::process(Timestamp timestamp, const Mat &frame) ...@@ -84,7 +90,6 @@ void FieldImageProcessor::process(Timestamp timestamp, const Mat &frame)
} }
if (cfg.markerDetectionMethod == "aruco" || gCalibrating) { if (cfg.markerDetectionMethod == "aruco" || gCalibrating) {
detectMarkers(downscaled, dict, corners, ids, detectorParameters); detectMarkers(downscaled, dict, corners, ids, detectorParameters);
if (cfg.processingDownscalingFactor > 1) { // Upscale if necessary if (cfg.processingDownscalingFactor > 1) { // Upscale if necessary
...@@ -103,15 +108,12 @@ void FieldImageProcessor::process(Timestamp timestamp, const Mat &frame) ...@@ -103,15 +108,12 @@ void FieldImageProcessor::process(Timestamp timestamp, const Mat &frame)
* An initial (and short) test with a pupil labs wide angle camera at 720p seeemed * An initial (and short) test with a pupil labs wide angle camera at 720p seeemed
* to match the distance measured with a laser distance meter. * to match the distance measured with a laser distance meter.
*/ */
if (ids.size() > 0) { if (ids.size() > 0) {
if (data.undistorted) { if (data.undistorted) {
Mat emptyCameraMatrix = (Mat_<double>(3,3) << qWarning() << "Marker pose estimation using undistorted image is not implemented yet.";
data.width, 0, data.width/2, // TODO: undistort the corners, then apply the estimation
0 , data.width, data.height/2, estimatePoseSingleMarkers(corners, cfg.collectionMarkerSizeMeters, cameraMatrix, distCoeffs, rvecs, tvecs);
0 ,0 , 1); } else
Mat emptyDistCoeffs = (Mat_<double>(1,4) << 0, 0, 0, 0);
estimatePoseSingleMarkers(corners, cfg.collectionMarkerSizeMeters, emptyCameraMatrix, emptyDistCoeffs, rvecs, tvecs);
} else
estimatePoseSingleMarkers(corners, cfg.collectionMarkerSizeMeters, cameraMatrix, distCoeffs, rvecs, tvecs); estimatePoseSingleMarkers(corners, cfg.collectionMarkerSizeMeters, cameraMatrix, distCoeffs, rvecs, tvecs);
} }
...@@ -152,63 +154,12 @@ void FieldImageProcessor::newROI(QPointF sROI, QPointF eROI) ...@@ -152,63 +154,12 @@ void FieldImageProcessor::newROI(QPointF sROI, QPointF eROI)
} }
} }
void FieldImageProcessor::sanitizeCameraParameters(Size size) void FieldImageProcessor::sanitizeCameraParameters(cv::Size size)
{ {
if (!forceSanitize) { if (!forceSanitize && size == expectedSize)
if ( (size == imageSize) && !map1.empty() && !map2.empty() ) return;
return; forceSanitize = false;
} else expectedSize = size;
forceSanitize = false; cameraMatrix = cameraCalibration->getCameraMatrix(size);
distCoeffs = cameraCalibration->getDistortionCoefficients(size);
/* TODO:
*
* 1) Move camera parameters logic to the Camera instead so it's
* considered for the eye cameras as well.
*
* 2) Drop the logic for resizing the intrinsic parameters since it's not
* throughly tested.
*
*/
FileStorage fs( QString(gCfgDir + "/" + id + "Calibration.xml").toStdString(), FileStorage::READ);
fs["cameraMatrix"] >> cameraMatrix;
fs["distCoeffs"] >> distCoeffs;
fs["imageSize"] >> imageSize;
bool haveCameraParameters = false;
if (!cameraMatrix.empty() && !distCoeffs.empty())
haveCameraParameters = true;
double currentAspectRatio = size.width / (float) size.height;
double originalAspectRatio = imageSize.width / (float) imageSize.height;
if (haveCameraParameters && (currentAspectRatio == originalAspectRatio) ) {
qInfo() << "Found intrinsic parameters.";
double rx = imageSize.width / (double) size.width;
double ry = imageSize.height / (double) size.height;
cameraMatrix.at<double>(0,2) = cameraMatrix.at<double>(0,2) / rx;
cameraMatrix.at<double>(1,2) = cameraMatrix.at<double>(1,2) / ry;
cameraMatrix.at<double>(0,0) = cameraMatrix.at<double>(0,0) / rx;
cameraMatrix.at<double>(1,1) = cameraMatrix.at<double>(1,1) / rx;
imageSize = size;
} else {
qInfo() << "No valid intrinsic parameters available. Using dummy values";
// Dummy estimation
cameraMatrix = (Mat_<double>(3,3) <<
size.width, 0, 0.5*size.width,
0, size.width, 0.5*size.height,
0, 0 ,1 );
distCoeffs = (Mat_<double>(1,4) << 0, 0, 0, 0);
imageSize = size;
}
initUndistortRectifyMap(
cameraMatrix,
distCoeffs,
Mat(),
getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, imageSize, 1, imageSize),
imageSize,
CV_32FC1,
map1,
map2
);
} }
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include <opencv2/aruco.hpp> #include <opencv2/aruco.hpp>
#include <opencv2/aruco/charuco.hpp> #include <opencv2/aruco/charuco.hpp>
#include "CameraCalibration.h"
#include "InputWidget.h" #include "InputWidget.h"
#include "utils.h" #include "utils.h"
...@@ -56,8 +58,6 @@ public: ...@@ -56,8 +58,6 @@ public:
extrapolatedGazeEstimate = 0; extrapolatedGazeEstimate = 0;
markers = std::vector<Marker>(); markers = std::vector<Marker>();
collectionMarker = Marker(); collectionMarker = Marker();
cameraMatrix = cv::Mat();
distCoeffs = cv::Mat();
undistorted = false; undistorted = false;
width = 0; width = 0;
height = 0; height = 0;
...@@ -69,9 +69,8 @@ public: ...@@ -69,9 +69,8 @@ public:
int extrapolatedGazeEstimate; int extrapolatedGazeEstimate;
Marker collectionMarker; Marker collectionMarker;
std::vector<Marker> ma