Commit 513c2640 authored by Thiago Santini's avatar Thiago Santini

Updates eye image processor gui

Includes combo box for tracking although we only have one tracking method
at the moment
parent 5352a93e
......@@ -19,12 +19,13 @@ EyeImageProcessor::EyeImageProcessor(QString id, QObject* parent)
#ifdef SWIRSKI
availablePupilDetectionMethods.push_back(std::make_shared<Swirski>());
#endif
settings = new QSettings(gCfgDir + "/" + id + " ImageProcessor.ini", QSettings::IniFormat);
settings = new QSettings(gCfgDir + "/" + id + " Image Processor.ini", QSettings::IniFormat);
updateConfig();
pmIdx = gPerformanceMonitor.enrol(id, "Image Processor");
pupilTrackingMethod = std::make_shared<PuReST>();
availablePupilTrackingMethods.push_back(std::make_shared<PuReST>());
pupilTrackingMethod = availablePupilTrackingMethods[0];
}
void EyeImageProcessor::updateConfig()
......@@ -33,14 +34,20 @@ void EyeImageProcessor::updateConfig()
cfg.load(settings);
pupilDetectionMethod = nullptr;
for (int i = 0; i < availablePupilDetectionMethods.size(); i++)
if (cfg.pupilDetectionMethod == QString(availablePupilDetectionMethods[i]->description().c_str()))
pupilDetectionMethod = availablePupilDetectionMethods[i];
for (auto method : availablePupilDetectionMethods)
if (cfg.pupilDetectionMethod == QString(method->description().c_str()))
pupilDetectionMethod = method;
pupilTrackingMethod = nullptr;
for (auto method : availablePupilTrackingMethods)
if (cfg.pupilTrackingMethod == QString(method->description().c_str()))
pupilTrackingMethod = method;
}
EyeImageProcessor::~EyeImageProcessor()
{
availablePupilDetectionMethods.clear();
availablePupilTrackingMethods.clear();
if (settings)
settings->deleteLater();
......@@ -111,7 +118,7 @@ void EyeImageProcessor::process(Timestamp timestamp, const Mat& frame)
} else
data.coarseROI = Rect();
if (cfg.tracking && pupilTrackingMethod)
if (pupilTrackingMethod)
pupilTrackingMethod->detectAndTrack(timestamp, downscaled, coarseROI, data.pupil, pupilDetectionMethod, minPupilDiameterPx, maxPupilDiameterPx);
else
data.pupil = pupilDetectionMethod->detectWithConfidence(downscaled, coarseROI, minPupilDiameterPx, maxPupilDiameterPx);
......
......@@ -46,7 +46,7 @@ public:
, coarseDetection(false)
, processingDownscalingFactor(1)
, pupilDetectionMethod(PuRe::desc.c_str())
, tracking(true)
, pupilTrackingMethod(PuReST::desc.c_str())
, roi(0.0f, 0.0f, 1.f, 1.f)
, minPupilDiameterRatio(0.0f)
, maxPupilDiameterRatio(0.27f)
......@@ -59,7 +59,7 @@ public:
bool coarseDetection;
double processingDownscalingFactor;
QString pupilDetectionMethod;
bool tracking;
QString pupilTrackingMethod;
// these are per session!
cv::Rect2f roi;
float minPupilDiameterRatio;
......@@ -75,7 +75,7 @@ public:
settings->setValue("coarseDetection", coarseDetection);
settings->setValue("processingDownscalingFactor", processingDownscalingFactor);
settings->setValue("pupilDetectionMethod", pupilDetectionMethod);
settings->setValue("tracking", tracking);
settings->setValue("pupilTrackingMethod", pupilTrackingMethod);
}
void load(QSettings* settings)
......@@ -88,7 +88,7 @@ public:
set(settings, "coarseDetection", coarseDetection);
set(settings, "processingDownscalingFactor", processingDownscalingFactor);
set(settings, "pupilDetectionMethod", pupilDetectionMethod);
set(settings, "tracking", tracking);
set(settings, "pupilTrackingMethod", pupilTrackingMethod);
}
};
......@@ -151,20 +151,18 @@ public:
layout->addWidget(box);
formLayout = new QFormLayout();
box = new QGroupBox("Pupil Detection");
box->setWhatsThis("Selects pupil detection method.");
box = new QGroupBox("Pupil Tracking");
box->setWhatsThis("Selects pupil tracking method.");
box->setToolTip(box->whatsThis());
box->setLayout(formLayout);
coarseDetectionBox = new QCheckBox();
coarseDetectionBox->setWhatsThis("Estimate a coarse location for the pupil location prior to detection.");
coarseDetectionBox->setWhatsThis("Estimate a coarse area for the pupil location prior to detection.");
coarseDetectionBox->setToolTip(box->whatsThis());
formLayout->addRow(new QLabel("Coarse Detection:"), coarseDetectionBox);
formLayout->addRow(new QLabel("Coarse Area:"), coarseDetectionBox);
pupilDetectionComboBox = new QComboBox();
formLayout->addRow(pupilDetectionComboBox);
trackingBox = new QCheckBox();
trackingBox->setWhatsThis("Track the pupil after detection using PuReST.");
trackingBox->setToolTip(box->whatsThis());
formLayout->addRow(new QLabel("PuReST (Santini et al. 2018b):"), trackingBox);
formLayout->addRow(new QLabel("Detection:"), pupilDetectionComboBox);
pupilTrackingComboBox = new QComboBox();
formLayout->addRow(new QLabel("Tracking:"), pupilTrackingComboBox);
layout->addWidget(box);
applyButton = new QPushButton("Apply");
......@@ -177,6 +175,7 @@ public:
}
QSettings* settings;
QComboBox* pupilDetectionComboBox;
QComboBox* pupilTrackingComboBox;
signals:
void updateConfig();
......@@ -197,7 +196,9 @@ public slots:
for (int i = 0; i < pupilDetectionComboBox->count(); i++)
if (pupilDetectionComboBox->itemData(i).toString() == cfg.pupilDetectionMethod)
pupilDetectionComboBox->setCurrentIndex(i);
trackingBox->setChecked(cfg.tracking);
for (int i = 0; i < pupilTrackingComboBox->count(); i++)
if (pupilTrackingComboBox->itemData(i).toString() == cfg.pupilTrackingMethod)
pupilTrackingComboBox->setCurrentIndex(i);
move(pos);
show();
}
......@@ -210,7 +211,7 @@ public slots:
cfg.flip = static_cast<CVFlip>(flipComboBox->currentData().toInt());
cfg.coarseDetection = coarseDetectionBox->isChecked();
cfg.pupilDetectionMethod = pupilDetectionComboBox->currentData().toString();
cfg.tracking = trackingBox->isChecked();
cfg.pupilTrackingMethod = pupilTrackingComboBox->currentData().toString();
cfg.save(settings);
emit updateConfig();
}
......@@ -222,7 +223,6 @@ private:
QCheckBox* coarseDetectionBox;
QComboBox* flipComboBox;
QDoubleSpinBox* downscalingSB;
QCheckBox* trackingBox;
};
class EyeImageProcessor : public QObject {
......@@ -231,7 +231,8 @@ public:
explicit EyeImageProcessor(QString id, QObject* parent = 0);
~EyeImageProcessor();
QSettings* settings;
QVector<std::shared_ptr<PupilDetectionMethod>> availablePupilDetectionMethods;
std::vector<std::shared_ptr<PupilDetectionMethod>> availablePupilDetectionMethods;
std::vector<std::shared_ptr<PupilTrackingMethod>> availablePupilTrackingMethods;
EyeImageProcessorConfig cfg;
EyeData data;
std::shared_ptr<CameraCalibration> cameraCalibration;
......
......@@ -55,10 +55,15 @@ void ImageProcessor::create()
eyeProcessorUI, SLOT(showOptions(QPoint)));
eyeProcessorUI->settings = eyeProcessor->settings;
eyeProcessorUI->pupilDetectionComboBox->addItem("None", "");
for (int i = 0; i < eyeProcessor->availablePupilDetectionMethods.size(); i++) {
QString name = eyeProcessor->availablePupilDetectionMethods[i]->description().c_str();
for (const auto& method : eyeProcessor->availablePupilDetectionMethods) {
QString name = method->description().c_str();
eyeProcessorUI->pupilDetectionComboBox->addItem(name, name);
}
eyeProcessorUI->pupilTrackingComboBox->addItem("None", "");
for (const auto& method : eyeProcessor->availablePupilTrackingMethods) {
QString name = method->description().c_str();
eyeProcessorUI->pupilTrackingComboBox->addItem(name, name);
}
connect(eyeProcessorUI, SIGNAL(updateConfig()),
eyeProcessor, SLOT(updateConfig()));
break;
......
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