Commit af6cf409 authored by Thiago Santini's avatar Thiago Santini

Fixes old tuples appearing in the Journal

Creates separate access for gaze estimation to avoid emiting new tuples
on evaluation.
Otherwise when we finish a calibration, a bunch of old tuples will be
logged to the journal
parent d52f1fb0
...@@ -333,12 +333,10 @@ void GazeEstimation::calibrate() ...@@ -333,12 +333,10 @@ void GazeEstimation::calibrate()
emit calibrationFinished(true, ""); emit calibrationFinished(true, "");
} }
GazeEstimate GazeEstimation::estimate(DataTuple dataTuple) GazeEstimate GazeEstimation::getGazeEstimate(const DataTuple& dataTuple)
{ {
GazeEstimate gazeEstimate; GazeEstimate gazeEstimate;
if (calibrated && gazeEstimationMethod) { if (calibrated && gazeEstimationMethod) {
// TODO: GazeEstimates in the DataTuple
GazeEstimate left, right, binocular; GazeEstimate left, right, binocular;
gazeEstimationMethod->estimate(dataTuple, left, right, binocular); gazeEstimationMethod->estimate(dataTuple, left, right, binocular);
...@@ -353,13 +351,15 @@ GazeEstimate GazeEstimation::estimate(DataTuple dataTuple) ...@@ -353,13 +351,15 @@ GazeEstimate GazeEstimation::estimate(DataTuple dataTuple)
gazeEstimate = right; gazeEstimate = right;
break; break;
} }
dataTuple.field.gazeEstimate = gazeEstimate;
} }
return gazeEstimate;
}
void GazeEstimation::estimate(DataTuple dataTuple)
{
dataTuple.field.gazeEstimate = getGazeEstimate(dataTuple);
drawGazeEstimationInfo(dataTuple); drawGazeEstimationInfo(dataTuple);
emit gazeEstimationDone(dataTuple); emit gazeEstimationDone(dataTuple);
return gazeEstimate;
} }
void GazeEstimation::printAccuracyInfo(const cv::Mat& errors, const QString& which, const double& diagonal, float& mu, float& sigma) void GazeEstimation::printAccuracyInfo(const cv::Mat& errors, const QString& which, const double& diagonal, float& mu, float& sigma)
...@@ -383,7 +383,7 @@ void GazeEstimation::evaluate() ...@@ -383,7 +383,7 @@ void GazeEstimation::evaluate()
evaluationTuples.clear(); evaluationTuples.clear();
for (unsigned int i = 0; i < collectedTuples.size(); i++) for (unsigned int i = 0; i < collectedTuples.size(); i++)
if (collectedTuples[i].isEvaluation() || (cfg.autoEvaluation && collectedTuples[i].isAutoEval())) { if (collectedTuples[i].isEvaluation() || (cfg.autoEvaluation && collectedTuples[i].isAutoEval())) {
if (estimate(collectedTuples[i]).valid) if (getGazeEstimate(collectedTuples[i]).valid)
evaluationTuples.push_back(&collectedTuples[i]); evaluationTuples.push_back(&collectedTuples[i]);
} }
...@@ -432,7 +432,7 @@ void GazeEstimation::evaluate() ...@@ -432,7 +432,7 @@ void GazeEstimation::evaluate()
Mat errors; Mat errors;
for (unsigned int i = 0; i < evaluationTuples.size(); i++) { for (unsigned int i = 0; i < evaluationTuples.size(); i++) {
Point3f gt = evaluationTuples[i]->field.collectionMarker.center; Point3f gt = evaluationTuples[i]->field.collectionMarker.center;
Point3f gaze = to3D(estimate(*evaluationTuples[i]).gp); Point3f gaze = to3D(getGazeEstimate(*evaluationTuples[i]).gp);
errorVectors.push_back(ErrorVector(gt, gaze)); errorVectors.push_back(ErrorVector(gt, gaze));
errors.push_back(errorVectors.back().magnitude()); errors.push_back(errorVectors.back().magnitude());
} }
......
...@@ -225,7 +225,7 @@ public slots: ...@@ -225,7 +225,7 @@ public slots:
void updateTemporalGazes(std::vector<CollectionTuple>& tuples); void updateTemporalGazes(std::vector<CollectionTuple>& tuples);
void calibrate(); void calibrate();
GazeEstimate estimate(DataTuple dataTuple); void estimate(DataTuple dataTuple);
void evaluate(); void evaluate();
void printAccuracyInfo(const cv::Mat& errors, const QString& which, const double& diagonal, float& mu, float& sigma); void printAccuracyInfo(const cv::Mat& errors, const QString& which, const double& diagonal, float& mu, float& sigma);
...@@ -255,6 +255,7 @@ private: ...@@ -255,6 +255,7 @@ private:
cv::Mat vis; cv::Mat vis;
cv::Mat overlay; cv::Mat overlay;
int lastOverlayIdx; int lastOverlayIdx;
GazeEstimate getGazeEstimate(const DataTuple& dataTuple);
private slots: private slots:
void detectOutliers(); void detectOutliers();
......
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