Mat Tracker::process(const Mat frame, Stats& stats)
{
+ TickMeter tm;
vector<KeyPoint> kp;
Mat desc;
+
+ tm.start();
detector->detectAndCompute(frame, noArray(), kp, desc);
stats.keypoints = (int)kp.size();
homography = findHomography(Points(matched1), Points(matched2),
RANSAC, ransac_thresh, inlier_mask);
}
+ tm.stop();
+ stats.fps = 1. / tm.getTimeSec();
if(matched1.size() < 4 || homography.empty()) {
Mat res;
void drawStatistics(Mat image, const Stats& stats)
{
static const int font = FONT_HERSHEY_PLAIN;
- stringstream str1, str2, str3;
+ stringstream str1, str2, str3, str4;
str1 << "Matches: " << stats.matches;
str2 << "Inliers: " << stats.inliers;
str3 << "Inlier ratio: " << setprecision(2) << stats.ratio;
+ str4 << "FPS: " << std::fixed << setprecision(2) << stats.fps;
- putText(image, str1.str(), Point(0, image.rows - 90), font, 2, Scalar::all(255), 3);
- putText(image, str2.str(), Point(0, image.rows - 60), font, 2, Scalar::all(255), 3);
- putText(image, str3.str(), Point(0, image.rows - 30), font, 2, Scalar::all(255), 3);
+ putText(image, str1.str(), Point(0, image.rows - 120), font, 2, Scalar::all(255), 3);
+ putText(image, str2.str(), Point(0, image.rows - 90), font, 2, Scalar::all(255), 3);
+ putText(image, str3.str(), Point(0, image.rows - 60), font, 2, Scalar::all(255), 3);
+ putText(image, str4.str(), Point(0, image.rows - 30), font, 2, Scalar::all(255), 3);
}
void printStatistics(string name, Stats stats)
cout << "Inliers " << stats.inliers << endl;
cout << "Inlier ratio " << setprecision(2) << stats.ratio << endl;
cout << "Keypoints " << stats.keypoints << endl;
+ cout << "FPS " << std::fixed << setprecision(2) << stats.fps << endl;
cout << endl;
}