Commit 4f8b7a01 authored by Thiago Santini's avatar Thiago Santini

Improves coarse location runtime

parent c6d5c265
......@@ -100,7 +100,7 @@ void EyeImageProcessor::process(Timestamp timestamp, const Mat &frame)
// If the user wants a coarse location and the method has none embedded,
// we further constrain the search using the generic one
if (!pupilDetectionMethod->hasCoarseLocation() && cfg.coarseDetection) {
coarseROI = PupilDetectionMethod::coarsePupilDetection( downscaled, 0.5f );
coarseROI = PupilDetectionMethod::coarsePupilDetection( downscaled, 0.5f, 60, 40);
data.coarseROI = Rect(
userROI.tl() + coarseROI.tl() / scalingFactor,
userROI.tl() + coarseROI.br() / scalingFactor
......
......@@ -6,7 +6,7 @@ using namespace cv;
//#define DBG_COARSE_PUPIL_DETECTION
//#define DBG_OUTLINE_CONTRAST
#include <QElapsedTimer>
Rect PupilDetectionMethod::coarsePupilDetection(const Mat &frame, const float &minCoverage, const int &workingWidth, const int &workingHeight)
{
// We can afford to work on a very small input for haar features, but retain the aspect ratio
......@@ -25,8 +25,7 @@ Rect PupilDetectionMethod::coarsePupilDetection(const Mat &frame, const float &m
// Pupil radii is based on PuRe assumptions
int min_r = (int) (0.5 * 0.07 * d);
int max_r = (int) (0.5 * 0.29 * d);
int r_step = (int) max<float>( 0.1f*(max_r + min_r), 1.0f);
int r_step = (int) max<float>( 0.2f*(max_r + min_r), 1.0f);
// TODO: padding so we consider the borders as well!
/* Haar-like feature suggested by Swirski. For details, see
......@@ -80,6 +79,9 @@ Rect PupilDetectionMethod::coarsePupilDetection(const Mat &frame, const float &m
float outer_mean = outer_norm*outer;
float response = (outer_mean - inner_mean);
if ( response < 0.5*best_response)
continue;
if (response > best_response)
best_response = response;
......@@ -93,13 +95,6 @@ Rect PupilDetectionMethod::coarsePupilDetection(const Mat &frame, const float &m
}
}
// Eliminate low response candidates then sort and combine
for ( auto c = candidates.begin(); c != candidates.end();) {
if ( c->second < 0.5 * best_response)
c = candidates.erase(c);
else
c++;
}
auto compare = [] (const pair<Rect, float> &a, const pair<Rect,float> &b) {
return (a.second > b.second);
};
......
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