-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
64 lines (49 loc) · 1.58 KB
/
main.cpp
File metadata and controls
64 lines (49 loc) · 1.58 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
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <vector>
#include <fstream>
#include <iostream>
#include <stdio.h>
int h_max;
int h_min;
int s_min;
int s_max;
int v_min;
int v_max;
int main(int argc, char* argv[]) {
if ( argc < 4 ) {
std::cout << "Usage: " << argv[0] << " image_file_name blur_kernel_w blur_kernel_h\n";
return 0;
}
int blur_kernel_w = std::stoi(std::string(argv[2]));
int blur_kernel_h = std::stoi(std::string(argv[3]));
// Step 1: Load image
cv::Mat image = cv::imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
// Find the field
// 1. blur
cv::Mat blurred;
cv::Size kernel(blur_kernel_w, blur_kernel_h);
cv::blur(image, blurred, kernel);
cv::Mat blurredcolor;
cvtColor(blurred, blurredcolor, CV_GRAY2RGB);
// 2. find corners
std::vector<cv::Point2f> corners;
cv::goodFeaturesToTrack( blurred, corners, 280, 0.05 /* quality magic */, 3 /* min distance corners magic */, cv::Mat(), 3 /* Block size Shi-Tomasi magic */, false /* fuck harris */, 0.04 );
// Select points
// Find point correspondences
// Undistort
// print result
std::string window = "result";
cv::namedWindow( window, CV_WINDOW_AUTOSIZE );
for (auto & p : corners) {
cv::circle( blurredcolor, p, 4, CV_RGB(255, 0, 0), -1, 8, 0 );
}
cv::imshow(window, blurredcolor);
int key = 0;
while( key != 'q' )
key = cv::waitKey( 1 );
cv::destroyWindow("result");
return 0;
}