Commit bb39cdbf authored by Thiago Santini's avatar Thiago Santini

Starts virtual markers

parent 418052a8
......@@ -8,5 +8,6 @@
<file>icons/gazeEstimationWidget.png</file>
<file>icons/logWidget.png</file>
<file>icons/performanceMonitorWidget.png</file>
<file>utils/CalibMeCollectionMarker.png</file>
</qresource>
</RCC>
......@@ -30,7 +30,6 @@ signals:
void keyRelease(QKeyEvent* event);
public slots:
void save(QSettings* settings)
{
settings->sync();
......@@ -81,10 +80,16 @@ public slots:
}
protected:
void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE { Q_UNUSED(event)
emit closed(false); }
void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE { Q_UNUSED(event)
emit closed(false); }
void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE
{
Q_UNUSED(event)
emit closed(false);
}
void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE
{
Q_UNUSED(event)
emit closed(false);
}
void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE { emit keyPress(event); }
void keyReleaseEvent(QKeyEvent* event) Q_DECL_OVERRIDE { emit keyRelease(event); }
QString id;
......
......@@ -89,6 +89,7 @@ public:
, gazeEstimationMethod("POLY_X_Y_XY_XX_YY_XYY_YXX_XXYY")
, visualize(true)
, visualizationTimeS(5)
, showVirtualMarker(false)
, autoEvaluation(true)
, granularity(2)
, horizontalStride(0.15)
......@@ -125,6 +126,7 @@ public:
int visualizationTimeS;
// CalibMe
bool showVirtualMarker;
bool autoEvaluation;
int granularity;
double horizontalStride;
......@@ -152,6 +154,7 @@ public:
settings->setValue("CalibMe/pupilPositionOutliers", pupilPositionOutliers);
settings->setValue("CalibMe/pupilOutlineOutliers", pupilOutlineOutliers);
settings->setValue("CalibMe/pupilDiameterOutliers", pupilDiameterOutliers);
settings->setValue("CalibMe/showVirtualMarker", showVirtualMarker);
settings->setValue("CalibMe/autoEvaluation", autoEvaluation);
settings->setValue("CalibMe/granularity", granularity);
settings->setValue("CalibMe/horizontalStride", horizontalStride);
......@@ -180,6 +183,7 @@ public:
set(settings, "CalibMe/pupilPositionOutliers", pupilPositionOutliers);
set(settings, "CalibMe/pupilOutlineOutliers", pupilOutlineOutliers);
set(settings, "CalibMe/pupilDiameterOutliers", pupilDiameterOutliers);
set(settings, "CalibMe/showVirtualMarker", showVirtualMarker);
set(settings, "CalibMe/autoEvaluation", autoEvaluation);
set(settings, "CalibMe/granularity", granularity);
set(settings, "CalibMe/horizontalStride", horizontalStride);
......
......@@ -11,6 +11,7 @@ GazeEstimationWidget::GazeEstimationWidget(QString id, QWidget* parent)
, lastStatus(false)
, calibrationRequested(false)
, isRecording(false)
, virtualMarker(nullptr)
, ui(new Ui::GazeEstimationWidget)
{
ui->setupUi(this);
......@@ -109,6 +110,10 @@ GazeEstimationWidget::GazeEstimationWidget(QString id, QWidget* parent)
ui->autoEvaluationBox->setChecked(cfg.autoEvaluation);
ui->autoEvaluationBox->blockSignals(false);
ui->showMarker->blockSignals(true);
ui->showMarker->setChecked(cfg.showVirtualMarker);
ui->showMarker->blockSignals(false);
ui->horizontalStrideSB->blockSignals(true);
ui->horizontalStrideSB->setValue(100 * cfg.horizontalStride);
ui->horizontalStrideSB->blockSignals(false);
......@@ -156,6 +161,8 @@ GazeEstimationWidget::GazeEstimationWidget(QString id, QWidget* parent)
loadSoundEffect("cal-success.wav", gExeDir, successSound);
loadSoundEffect("cal-failure.wav", gExeDir, failureSound);
loadSoundEffect("cal-collected.wav", gExeDir, collectedSound);
setupVirtualMarker();
}
GazeEstimationWidget::~GazeEstimationWidget()
......@@ -266,6 +273,8 @@ void GazeEstimationWidget::on_loadTuples_clicked()
void GazeEstimationWidget::on_startFinishButton_toggled(bool checked)
{
if (checked) {
if (ui->showMarker->isChecked())
virtualMarker->show();
gCalibrating = true;
ui->startFinishButton->setText("Finish");
statusBarLabel->setText("Calibrating: click on the field widget\nor press 'c' to toggle marker collection.");
......@@ -289,6 +298,7 @@ void GazeEstimationWidget::on_startFinishButton_toggled(bool checked)
calibrationRequested = true;
emit calibrationRequest();
isCollecting = false;
virtualMarker->hide();
}
}
......@@ -308,40 +318,13 @@ void GazeEstimationWidget::stopRecording()
isRecording = false;
}
/*
void GazeEstimationWidget::keyPressEvent(QKeyEvent *event)
void GazeEstimationWidget::setupVirtualMarker()
{
if (event->isAutoRepeat())
return;
switch (event->key()) {
case Qt::Key_C:
if (isCollecting) {
connect(this, SIGNAL(inDataTuple(DataTuple)), this, SLOT(collectMarkerTuple(DataTuple)) );
collectedSound.play();
}
break;
case Qt::Key_S:
ui->startFinishButton->setChecked(!ui->startFinishButton->isChecked());
break;
default:
break;
}
virtualMarker = new VirtualMarker("VirtualCollectionMarker", this);
connect(virtualMarker, &VirtualMarker::keyPress,
this, &GazeEstimationWidget::keyPressEvent);
virtualMarker->setWindowFlags(Qt::Tool);
}
void GazeEstimationWidget::keyReleaseEvent(QKeyEvent *event)
{
if (event->isAutoRepeat())
return;
switch (event->key()) {
case Qt::Key_C:
disconnect(this, SIGNAL(inDataTuple(DataTuple)), this, SLOT(collectMarkerTuple(DataTuple)) );
if (isCollecting)
collectedSound.play();
break;
default:
break;
}
}
*/
void GazeEstimationWidget::toggleCalibration()
{
......@@ -532,3 +515,9 @@ void GazeEstimationWidget::on_maxReprojectionError_editingFinished()
cfg.maxReprojectionError = ui->maxReprojectionError->value();
updateConfig();
}
void GazeEstimationWidget::on_showMarker_toggled(bool checked)
{
cfg.showVirtualMarker = checked;
cfg.save(settings); // don't request a new calibration
}
......@@ -3,17 +3,76 @@
#include <vector>
#include <QDialog>
#include <QFileDialog>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QLabel>
#include <QMainWindow>
#include <QPixmap>
#include <QSoundEffect>
#include <QThread>
#include <QWidget>
#include "ERWidget.h"
#include "GazeEstimation.h"
#include "Synchronizer.h"
class VirtualMarker : public ERWidget {
Q_OBJECT
public:
VirtualMarker(QString id, QWidget* parent = nullptr)
: ERWidget(id, parent)
{
QWidget* centralWidget = new QWidget(this);
setCentralWidget(centralWidget);
QLabel* label = new QLabel(this);
QPixmap pixmap(":utils/CalibMeCollectionMarker.png");
label->setPixmap(pixmap);
label->setScaledContents(true);
label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
QHBoxLayout* layout = new QHBoxLayout();
layout->addWidget(label);
layout->setContentsMargins(0, 0, 0, 0);
centralWidget->setLayout(layout);
setDefaults(false, QSize(240, 240));
settings = new QSettings(gCfgDir + "/" + id + ".ini", QSettings::IniFormat);
}
void show()
{
load(settings);
ERWidget::show();
}
void hide()
{
save(settings);
ERWidget::hide();
}
~VirtualMarker()
{
settings->deleteLater();
}
signals:
void keyPress(QKeyEvent* event);
void keyRelease(QKeyEvent* event);
private:
void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE
{
emit keyPress(event);
}
void keyReleaseEvent(QKeyEvent* event) Q_DECL_OVERRIDE
{
emit keyRelease(event);
}
QSettings* settings;
};
namespace Ui {
class GazeEstimationWidget;
}
......@@ -65,6 +124,9 @@ private:
QSoundEffect startSound, successSound, failureSound, collectedSound;
VirtualMarker* virtualMarker;
void setupVirtualMarker();
private slots:
void startSampling(Timestamp timestamp, QPoint calibrationPoint, QSize previewSize);
void newSample(DataTuple dataTuple);
......@@ -100,6 +162,7 @@ private slots:
void on_minPeriphericCoverage_editingFinished();
void on_maxReprojectionError_editingFinished();
void on_outlierPupilDiameterBox_toggled(bool checked);
void on_showMarker_toggled(bool checked);
};
#endif // GAZEESTIMATIONWIDGET_H
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>254</width>
<height>735</height>
<height>760</height>
</rect>
</property>
<property name="focusPolicy">
......@@ -529,6 +529,16 @@
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showMarker">
<property name="toolTip">
<string>Shows a virtual marker on the screen (experimental)</string>
</property>
<property name="text">
<string>Show Virtual Marker</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
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