-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
59 lines (45 loc) · 1.53 KB
/
Copy pathmain.cpp
File metadata and controls
59 lines (45 loc) · 1.53 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
#include <string>
#include <opencv2/opencv.hpp>
#include "settings.h"
#include "Motion.h"
int frame_width = 0;
int frame_number = 0;
int frame_count = 0;
int main(int argc, char *argv[]) {
if (argc != 3) {
std::cout << "Usage: " << argv[0] << " <filename> <number of points of interest>" << std::endl;
return 1;
}
// gather filename
const std::string filename(argv[1]);
// declare GPU frame storage
cv::Mat cpu_frame, cpu_gray;
// declare feature point and description storage
std::vector<cv::KeyPoint> points;
cv::Mat cpu_desc;
// setup ORB detector
cv::Ptr<cv::ORB> cpu_detector = cv::ORB::create(std::stoi(argv[2]), 2.0f, OCTAVES, 31, 0, 2,
cv::ORB::HARRIS_SCORE, 31, 50);
// open file on CPU
cv::VideoCapture cpu_reader(filename);
frame_count = cpu_reader.get(cv::CAP_PROP_FRAME_COUNT);
//introduce motion object
auto* motion = new Motion();
// main loop
for (;;) {
if (!cpu_reader.read(cpu_frame))
break;
if (frame_width == 0) {
frame_width = cpu_frame.cols;
}
//for each frame until end of input:
// - convert to gray scale
cv::cvtColor(cpu_frame, cpu_gray, cv::COLOR_BGRA2GRAY);
// - detect feature points and compute their descriptors
cpu_detector->detectAndCompute(cpu_gray, cv::noArray(), points, cpu_desc);
motion->add_frame(points, cpu_desc);
frame_number++;
}
delete motion;
return 0;
}