Commit 5aa822e0 authored by Thiago Santini's avatar Thiago Santini

Adds additional outlier detector

parent a2d349ce
......@@ -192,6 +192,34 @@ void GazeEstimation::detectOutliers()
}
}
}
if (cfg.pupilDiameterOutliers) {
vector<float> ld, rd;
for (auto& cur : calibrationTuples) {
if (cur->isOutlier())
continue;
ld.push_back(cur->lEye.pupil.majorAxis());
rd.push_back(cur->rEye.pupil.majorAxis());
}
if (ld.size() > 0 && rd.size() > 0) {
double lmed = median(ld);
double rmed = median(rd);
for (auto& cur : calibrationTuples) {
if (cur->isOutlier())
continue;
auto valid = [&](const double med, const EyeData ed, const float tolerance = 0.1) {
float ma = ed.pupil.majorAxis();
return ma < (1 + tolerance) * med && ma > (1 - tolerance);
};
if (valid(lmed, cur->lEye) && valid(rmed, cur->rEye))
continue;
cur->outlierDesc = CollectionTuple::OD_PUPIL_DIAMETER;
}
}
}
}
void GazeEstimation::calibrate()
......
......@@ -82,6 +82,7 @@ public:
, pupilRatioOutliers(true)
, pupilPositionOutliers(true)
, pupilOutlineOutliers(true)
, pupilDiameterOutliers(true)
, inputType(GazeEstimationMethod::BINOCULAR_MEAN_POR)
, gazeEstimationMethod("POLY_X_Y_XY_XX_YY_XYY_YXX_XXYY")
, visualize(true)
......@@ -111,6 +112,7 @@ public:
bool pupilRatioOutliers;
bool pupilPositionOutliers;
bool pupilOutlineOutliers;
bool pupilDiameterOutliers;
// Method
GazeEstimationMethod::InputType inputType;
......@@ -147,6 +149,7 @@ public:
settings->setValue("CalibMe/pupilRatioOutliers", pupilRatioOutliers);
settings->setValue("CalibMe/pupilPositionOutliers", pupilPositionOutliers);
settings->setValue("CalibMe/pupilOutlineOutliers", pupilOutlineOutliers);
settings->setValue("CalibMe/pupilDiameterOutliers", pupilDiameterOutliers);
settings->setValue("CalibMe/autoEvaluation", autoEvaluation);
settings->setValue("CalibMe/granularity", granularity);
settings->setValue("CalibMe/horizontalStride", horizontalStride);
......@@ -174,6 +177,7 @@ public:
set(settings, "CalibMe/pupilRatioOutliers", pupilRatioOutliers);
set(settings, "CalibMe/pupilPositionOutliers", pupilPositionOutliers);
set(settings, "CalibMe/pupilOutlineOutliers", pupilOutlineOutliers);
set(settings, "CalibMe/pupilDiameterOutliers", pupilDiameterOutliers);
set(settings, "CalibMe/autoEvaluation", autoEvaluation);
set(settings, "CalibMe/granularity", granularity);
set(settings, "CalibMe/horizontalStride", horizontalStride);
......
......@@ -106,6 +106,10 @@ GazeEstimationWidget::GazeEstimationWidget(QString id, QWidget* parent)
ui->outlierPupilOutlineBox->setChecked(cfg.pupilOutlineOutliers);
ui->outlierPupilOutlineBox->blockSignals(false);
ui->outlierPupilDiameterBox->blockSignals(true);
ui->outlierPupilDiameterBox->setChecked(cfg.pupilDiameterOutliers);
ui->outlierPupilDiameterBox->blockSignals(false);
ui->autoEvaluationBox->blockSignals(true);
ui->autoEvaluationBox->setChecked(cfg.autoEvaluation);
ui->autoEvaluationBox->blockSignals(false);
......@@ -447,6 +451,12 @@ void GazeEstimationWidget::on_outlierPupilOutlineBox_toggled(bool checked)
updateConfig();
}
void GazeEstimationWidget::on_outlierPupilDiameterBox_toggled(bool checked)
{
cfg.pupilDiameterOutliers = checked;
updateConfig();
}
void GazeEstimationWidget::on_autoEvaluationBox_toggled(bool checked)
{
cfg.autoEvaluation = checked;
......
......@@ -99,6 +99,7 @@ private slots:
void on_minCentralCoverage_editingFinished();
void on_minPeriphericCoverage_editingFinished();
void on_maxReprojectionError_editingFinished();
void on_outlierPupilDiameterBox_toggled(bool checked);
};
#endif // GAZEESTIMATIONWIDGET_H
......@@ -307,6 +307,13 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="outlierPupilDiameterBox">
<property name="text">
<string>Pupil Diameter</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -51,6 +51,7 @@ public:
OD_MISSING_INPUT = 1,
OD_PUPIL_RATIO = 2,
OD_PUPIL_POSITION = 3,
OD_PUPIL_DIAMETER = 4,
};
OutlierDesc outlierDesc;
bool isOutlier() { return outlierDesc != OD_INLIER; }
......
......@@ -87,4 +87,13 @@ void set(const QSettings* settings, const QString key, T& v)
void loadSoundEffect(const QString& fileName, const QString& exeDir, QSoundEffect& effect);
template <typename T>
double median(std::vector<T> v)
{
int size = static_cast<int>(v.size());
std::sort(v.begin(), v.end());
int mid = size / 2;
return size % 2 == 0 ? (v[mid] + v[mid - 1]) / 2 : v[mid];
}
#endif // UTILS_H
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