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