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