Commit 8dff3303 authored by Thiago Santini's avatar Thiago Santini

Small changes for PuRe / PuReST performance

parent 374cd9b0
......@@ -85,7 +85,7 @@ PuRe::~PuRe()
{
}
void PuRe::estimateParameters(int rows, int cols)
void PuRe::estimateParameters(const int rows, const int cols)
{
/*
* Assumptions:
......@@ -113,7 +113,7 @@ void PuRe::init(const Mat &frame)
}
Mat PuRe::canny(const Mat &in, bool blurImage, bool useL2, int bins, float nonEdgePixelsRatio, float lowHighThresholdRatio)
Mat PuRe::canny(const Mat &in, const bool blurImage, const bool useL2, const int bins, const float nonEdgePixelsRatio, const float lowHighThresholdRatio)
{
(void) useL2;
/*
......@@ -524,7 +524,7 @@ void PuRe::findPupilEdgeCandidates(const Mat &intensityImage, Mat &edge, vector<
for (size_t i=curves.size(); i-->0;) {
PupilCandidate candidate(curves[i]);
if (candidate.isValid(intensityImage, minPupilDiameterPx, maxPupilDiameterPx, outlineBias))
candidates.push_back( candidate );
candidates.emplace_back( candidate );
}
}
......@@ -560,12 +560,12 @@ void PuRe::combineEdgeCandidates(const cv::Mat &intensityImage, cv::Mat &edge, s
vector<Point> mergedPoints = pc->points;
mergedPoints.insert(mergedPoints.end(), pc2->points.begin(), pc2->points.end());
PupilCandidate candidate( mergedPoints );
PupilCandidate candidate( std::move(mergedPoints) );
if (!candidate.isValid(intensityImage, minPupilDiameterPx, maxPupilDiameterPx, outlineBias))
continue;
if (candidate.outlineContrast < pc->outlineContrast || candidate.outlineContrast < pc2->outlineContrast)
continue;
mergedCandidates.push_back( candidate );
mergedCandidates.emplace_back( candidate );
}
}
candidates.insert( candidates.end(), mergedCandidates.begin(), mergedCandidates.end() );
......
......@@ -201,7 +201,7 @@ protected:
* Initialization
*/
void init(const cv::Mat &frame);
void estimateParameters(int rows, int cols);
void estimateParameters(const int rows, const int cols);
/*
* Downscaling
......@@ -218,13 +218,13 @@ protected:
// Canny
cv::Mat dx, dy, magnitude;
cv::Mat edgeType, edge;
cv::Mat canny(const cv::Mat &in, bool blur=true, bool useL2=true, int bins=64, float nonEdgePixelsRatio=0.7f, float lowHighThresholdRatio=0.4f);
cv::Mat canny(const cv::Mat &in, const bool blur=true, const bool useL2=true, const int bins=64, const float nonEdgePixelsRatio=0.7f, const float lowHighThresholdRatio=0.4f);
// Edge filtering
void filterEdges(cv::Mat &edges);
// Remove duplicates (e.g., from closed loops)
int pointHash(cv::Point p, int cols) { return p.y*cols+p.x;}
int pointHash(const cv::Point &p, const int cols) { return p.y*cols+p.x;}
void removeDuplicates(std::vector<std::vector<cv::Point> > &curves, const int& cols) {
std::map<int,uchar> contourMap;
for (size_t i=curves.size(); i-->0;) {
......
......@@ -151,7 +151,7 @@ void PuReST::generateCombinations(const std::vector<GreedyCandidate> &seeds, std
points.insert(points.end(), hull.begin(), hull.end());
}
}
candidates.emplace_back( GreedyCandidate(points) );
candidates.emplace_back( std::move(GreedyCandidate(points)) );
} while ( next_permutation(v.begin(), v.end()) );
}
......@@ -234,7 +234,7 @@ bool PuReST::greedySearch(const cv::Mat &greedyDetectorEdges, const Pupil &baseP
vector<Point> ac;
approxPolyDP( *c, ac, 1.5, false);
if ( ac.size() > 3 ) {
approxCurves.push_back(ac);
approxCurves.push_back(std::move(ac));
c++;
} else {
c = curves.erase(c);
......
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