-
Notifications
You must be signed in to change notification settings - Fork 1
/
harrisMain.cpp
108 lines (83 loc) · 2.34 KB
/
harrisMain.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <cv.h>
#include <cvaux.h>
#include <highgui.h>
#include <cxcore.h>
#include <vector>
#include <unistd.h>
#include "gaussian.h"
#include "get_harris_points.hpp"
#include "harris_plot.hpp"
#include "computeHarrisResponse.h"
bool debug = false;
int main (int argc, char *argv[]) {
Mat img, harrisResponse, imgBlurred;
std::list<Point> points;
Point tmpPoint;
char usage[] = "[-d] [-s] [-k kernel_size] [-b integration_sigma ] [-t treshold] -i ime_slike";
char opt;
char optstring[] = "si:k:t:b:d";
char *imgName = NULL;
bool disableBlur = false;
unsigned char kernelSize = 3;
float treshold = 0.1;
int sigma = 5;
if (argc < 3) {
fprintf (stderr, "Upotreba: %s %s\n", argv[0], usage);
return 1;
}
while ((opt = getopt (argc, argv, optstring)) != -1) {
switch (opt) {
case 'i':
imgName = optarg;
break;
case 's':
disableBlur = true;
break;
case 'k':
kernelSize = atoi(optarg)/2 * 2 + 1;
assert (kernelSize > 2);
break;
case 'b':
sigma = atoi(optarg);
assert (sigma > 0);
break;
case 't':
treshold = atof (optarg);
assert (treshold > 0);
break;
case 'd':
debug = true;
break;
default:
fprintf (stderr, "Nepodrzana opcija.\n");
fprintf (stderr, "Upotreba: %s %s\n", argv[0], usage);
return 1;
}
}
img = imread (imgName, CV_LOAD_IMAGE_GRAYSCALE);
if (img.empty()) {
cerr << "Greska pri citanju fajla.\n" << endl;
return 2;
}
imgBlurred = Mat (img.size(), CV_8UC1, Scalar::all(0));
if (disableBlur == true) {
imgBlurred = img;
}
else {
// Prvo treba zagladiti sliku:
grayscaleGaussianBlur (img, imgBlurred, kernelSize, kernelSize);
}
harrisResponse = Mat (img.size(), CV_64F);
computeHarrisResponse(imgBlurred, harrisResponse, sigma);
//debug_saveResponse (harrisResponse);
//debug_loadResponse (harrisResponse);
// for(int row = 0; row < harrisResponse.rows; ++row) {
// for(int col = 0; col < harrisResponse.cols; ++col) {
// fprintf (stderr, "Element: %f\n", harrisResponse.at<int>(row,col));
// }
// }
if (debug) imshow ("harrisResponse", harrisResponse);
points = get_harris_points (harrisResponse, 10, treshold);
plotHarrisPoints (img, points);
return 0;
}