-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
executable file
·70 lines (52 loc) · 1.55 KB
/
main.cpp
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
67
68
69
70
#include "corner_detect.h"
string config_path = "../config.json";
/*
* Get File Name from a Path with or without extension
*/
string getFileName(string filePath, bool withExtension = false, char seperator = '/')
{
// Get last dot position
size_t dotPos = filePath.rfind('.');
size_t sepPos = filePath.rfind(seperator);
if(sepPos != std::string::npos)
{
return filePath.substr(sepPos + 1, filePath.size() - (withExtension || dotPos != std::string::npos ? 1 : dotPos) );
}
return "";
}
int main_image(char image_path[100])
{
Mat image, result_image;
char out_image_path[100];
string image_filename;
uint16_t image_width, image_height;
vector<Point> corners;
load_config(config_path);
image_filename = getFileName(image_path);
image = imread(image_path, 0);
result_image = imread(image_path, 1);
if (!image.data)
{
printf("No image data \n");
return -1;
}
image_width = image.cols;
image_height = image.rows;
// detect_corner(image.data, image_width, image_height, corners);
detect_corner_lcp(image.data, image_width, image_height, corners);
draw_corner(corners, result_image);
imshow("corner detection", result_image);
imwrite(image_filename, result_image);
waitKey(0);
return 0;
}
int main(int argc, char **argv)
{
if (argc != 2)
{
printf("Please enter: ./corner_detect xxx.png\n");
return -1;
}
main_image(argv[1]);
return 0;
}