~paparazzi-uav/paparazzi/v5.0-manual

« back to all changes in this revision

Viewing changes to sw/ext/opencv_bebop/opencv/samples/cpp/tutorial_code/features2D/AKAZE_tracking/utils.h

  • Committer: Paparazzi buildbot
  • Date: 2016-05-18 15:00:29 UTC
  • Revision ID: felix.ruess+docbot@gmail.com-20160518150029-e8lgzi5kvb4p7un9
Manual import commit 4b8bbb730080dac23cf816b98908dacfabe2a8ec from v5.0 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef UTILS_H
 
2
#define UTILS_H
 
3
 
 
4
#include <opencv2/core.hpp>
 
5
#include <vector>
 
6
#include "stats.h"
 
7
 
 
8
using namespace std;
 
9
using namespace cv;
 
10
 
 
11
void drawBoundingBox(Mat image, vector<Point2f> bb);
 
12
void drawStatistics(Mat image, const Stats& stats);
 
13
void printStatistics(string name, Stats stats);
 
14
vector<Point2f> Points(vector<KeyPoint> keypoints);
 
15
 
 
16
void drawBoundingBox(Mat image, vector<Point2f> bb)
 
17
{
 
18
    for(unsigned i = 0; i < bb.size() - 1; i++) {
 
19
        line(image, bb[i], bb[i + 1], Scalar(0, 0, 255), 2);
 
20
    }
 
21
    line(image, bb[bb.size() - 1], bb[0], Scalar(0, 0, 255), 2);
 
22
}
 
23
 
 
24
void drawStatistics(Mat image, const Stats& stats)
 
25
{
 
26
    static const int font = FONT_HERSHEY_PLAIN;
 
27
    stringstream str1, str2, str3;
 
28
 
 
29
    str1 << "Matches: " << stats.matches;
 
30
    str2 << "Inliers: " << stats.inliers;
 
31
    str3 << "Inlier ratio: " << setprecision(2) << stats.ratio;
 
32
 
 
33
    putText(image, str1.str(), Point(0, image.rows - 90), font, 2, Scalar::all(255), 3);
 
34
    putText(image, str2.str(), Point(0, image.rows - 60), font, 2, Scalar::all(255), 3);
 
35
    putText(image, str3.str(), Point(0, image.rows - 30), font, 2, Scalar::all(255), 3);
 
36
}
 
37
 
 
38
void printStatistics(string name, Stats stats)
 
39
{
 
40
    cout << name << endl;
 
41
    cout << "----------" << endl;
 
42
 
 
43
    cout << "Matches " << stats.matches << endl;
 
44
    cout << "Inliers " << stats.inliers << endl;
 
45
    cout << "Inlier ratio " << setprecision(2) << stats.ratio << endl;
 
46
    cout << "Keypoints " << stats.keypoints << endl;
 
47
    cout << endl;
 
48
}
 
49
 
 
50
vector<Point2f> Points(vector<KeyPoint> keypoints)
 
51
{
 
52
    vector<Point2f> res;
 
53
    for(unsigned i = 0; i < keypoints.size(); i++) {
 
54
        res.push_back(keypoints[i].pt);
 
55
    }
 
56
    return res;
 
57
}
 
58
 
 
59
#endif // UTILS_H