-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_baft.cpp
More file actions
67 lines (49 loc) · 1.38 KB
/
test_baft.cpp
File metadata and controls
67 lines (49 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* @file test_baft.cpp
* @brief Main program for testing BAFT
* @date Nov 27, 2014
* @author Jonas T. Arnfred
*/
#include "./src/utils.h"
#include "./src/baft.h"
// System
#include <string>
#include <vector>
#include <iostream>
using namespace std;
using namespace cv;
/* ************************************************************************* */
int main(int argc, char *argv[]) {
cv::Mat img;
if (argc != 2) {
cerr << "Error introducing input arguments!" << endl;
cerr << "The format needs to be: ./test_baft img" << endl;
return -1;
}
string imgFile = argv[1];
// Open the input image
img = imread(imgFile, 1);
// Create KAZE object
Ptr<Feature2D> dbaft = BAFT::create();
// Timing information
double t1 = 0.0, t2 = 0.0;
double takaze = 0.0;
// Detect BAFT features in the input image
vector<cv::KeyPoint> kpts;
cv::Mat desc;
t1 = cv::getTickCount();
dbaft->detectAndCompute(img, cv::noArray(), kpts, desc, false);
t2 = cv::getTickCount();
takaze = 1000.0*(t2-t1) / cv::getTickFrequency();
draw_keypoints(img, kpts);
// Show the detected BAFT features
cv::imshow("BAFT", img);
cv::waitKey(0);
int nr_kpts = kpts.size();
cout << "BAFT Results" << endl;
cout << "********************" << endl;
cout << "# Keypoints: \t" << nr_kpts << endl;
cout << "Time (ms): \t" << takaze << endl;
cout << endl;
return 0;
}