Commit b7022930 authored by Thiago Santini's avatar Thiago Santini

Saves calibration tuples on recording

parent 74bcbc3a
......@@ -491,20 +491,21 @@ void GazeEstimation::loadTuplesFromFile(CollectionTuple::TupleType tupleType, QS
void GazeEstimation::saveTuplesToFile(CollectionTuple::TupleType tupleType, QString fileName)
{
vector<CollectionTuple*> pertinentTuples;
for (unsigned int i=0; i<collectedTuples.size(); i++) {
if ( tupleType == CollectionTuple::CALIBRATION)
if (collectedTuples[i].isEvaluation())
continue;
if ( tupleType == CollectionTuple::EVALUATION)
if (collectedTuples[i].isCalibration())
continue;
vector<CollectionTuple*> pertinentTuples;
for (unsigned int i=0; i<collectedTuples.size(); i++) {
//if ( tupleType == CollectionTuple::CALIBRATION)
// if (collectedTuples[i].isEvaluation())
// continue;
if ( tupleType == CollectionTuple::EVALUATION) {
if (collectedTuples[i].isCalibration())
continue;
}
pertinentTuples.push_back(&collectedTuples[i]);
}
pertinentTuples.push_back(&collectedTuples[i]);
}
saveTuplesToFile(pertinentTuples, fileName, QIODevice::WriteOnly);
saveTuplesToFile(pertinentTuples, fileName, QIODevice::WriteOnly);
}
void GazeEstimation::saveTuplesToFile(const std::vector<CollectionTuple *> &tuples, QString fileName, QFlags<QIODevice::OpenModeFlag> flags)
......
......@@ -195,7 +195,8 @@ public slots:
void saveTuplesToFile(const std::vector<CollectionTuple*> &tuples, QString fileName, QFlags<QIODevice::OpenModeFlag> flags);
void addTuple(CollectionTuple tuple);
void addTuples(std::vector<CollectionTuple> tuples);
void reset(CollectionTuple::TupleType type);
void reset(CollectionTuple::TupleType type);
void saveCalibration() { saveTuplesToFile( CollectionTuple::TupleType::CALIBRATION, QString("%1-calibration.tup").arg( gTimer.elapsed() ) ); }
void setCalibrating(bool v);
......
......@@ -13,7 +13,8 @@ GazeEstimationWidget::GazeEstimationWidget(QWidget *parent) :
isCollecting(false),
isSampling(false),
lastStatus(false),
calibrationRequested(false),
calibrationRequested(false),
isRecording(false),
ui(new Ui::GazeEstimationWidget)
{
ui->setupUi(this);
......@@ -298,6 +299,17 @@ void GazeEstimationWidget::on_collectionTypeComboBox_currentIndexChanged(int ind
currentTupleType = static_cast<CollectionTuple::TupleType>( ui->collectionTypeComboBox->itemData(index).toInt() );
}
void GazeEstimationWidget::startRecording()
{
isRecording = true;
QMetaObject::invokeMethod(gazeEstimation, "saveCalibration");
}
void GazeEstimationWidget::stopRecording()
{
isRecording = false;
}
/*
void GazeEstimationWidget::keyPressEvent(QKeyEvent *event)
{
......@@ -472,7 +484,9 @@ void GazeEstimationWidget::updateStatus(bool status, QString msg)
if (status) {
statusBarLabel->setText("Calibrated.");
statusBarLabel->setStyleSheet("QLabel { font : bold; color : green }");
statusBarLabel->setStyleSheet("QLabel { font : bold; color : green }");
if (isRecording)
QMetaObject::invokeMethod(gazeEstimation, "saveCalibration");
} else {
statusBarLabel->setText(QString("Uncalibrated: %1").arg(msg));
statusBarLabel->setStyleSheet("QLabel { font : bold; color : red }");
......@@ -480,7 +494,6 @@ void GazeEstimationWidget::updateStatus(bool status, QString msg)
}
void GazeEstimationWidget::on_minCentralCoverage_editingFinished()
{
cfg.minCentralAreaCoverage = ui->minCentralCoverage->value();
......
......@@ -42,6 +42,8 @@ public slots:
void toggleCalibration();
void enableMarkerCollection();
void disableMarkerCollection();
void startRecording();
void stopRecording();
private:
QThread *gazeEstimationThread;
......@@ -56,7 +58,8 @@ private:
bool isCollecting;
bool isSampling;
bool lastStatus;
bool calibrationRequested;
bool calibrationRequested;
bool isRecording;
QLabel *statusBarLabel;
......
......@@ -118,8 +118,10 @@ MainWindow::MainWindow(QWidget *parent) :
fieldWidget, SLOT(startRecording()) );
connect(this, SIGNAL(stopRecording()),
fieldWidget, SLOT(stopRecording()) );
// connect(this, SIGNAL(startRecording()), calibrationWidget, SLOT(startRecording()) );
// connect(this, SIGNAL(stopRecording()), calibrationWidget, SLOT(stopRecording()) );
connect(this, SIGNAL(startRecording()),
gazeEstimationWidget, SLOT(startRecording()) );
connect(this, SIGNAL(stopRecording()),
gazeEstimationWidget, SLOT(stopRecording()) );
connect(this, SIGNAL(startRecording()),
journal, SIGNAL(startRecording()) );
connect(this, SIGNAL(stopRecording()),
......
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