-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
132 lines (102 loc) · 4.1 KB
/
main.cpp
File metadata and controls
132 lines (102 loc) · 4.1 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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include <QCoreApplication>
// Only that order
#include "slide_proc.h"
#include "video_handler.h"
#include "img_handler.h"
#define PIC "/home/dupeljan/Projects/webinar_analisator/web_analis_opencv/gen_slides/slide_8.png"
#define SLIDE_DEBUG 0
#define VIDEO_DEBUG 1
#define FREE_TEST 0
using namespace cv;
using namespace std;
#if FREE_TEST == 0
int main(int argc, char *argv[]){
#if VIDEO_DEBUG == 1
video_main();
#endif
#if SLIDE_DEBUG == 1
string imageName(PIC);
auto image = imread(imageName.c_str(), IMREAD_COLOR); // Read the file
if( image.empty() ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
Slide_proc s;
s.proccess(image);
return 0;
#endif
}
#endif
#if FREE_TEST == 1
int main(){
string root = "/home/dupeljan/Documents/courcework_2019/Latex/pictures/solution/";
auto cursor = imread(root+"cursor.png");
Mat cmp_img[2] = { imread(root + "cmp3.png"),imread(root+"cmp4.png")};
imshow("cmp0",cmp_img[0]);
imshow("cmp1",cmp_img[1]);
waitKey();
cout << cmp(cmp_img[0],cmp_img[1]) << endl << cmp(cursor,cmp_img[1]) << endl ;
return 0;
}
/*
int main(int argc, char ** argv)
{
string root = "/home/dupeljan/Documents/courcework_2019/graphics/2/";
string filename = root + "input1.jpg";
Mat I = imread(filename, 0);
Mat padded; //expand input image to optimal size
int m = getOptimalDFTSize( I.rows );
int n = getOptimalDFTSize( I.cols ); // on the border add zero values
copyMakeBorder(I, padded, 0, m - I.rows, 0, n - I.cols, BORDER_CONSTANT, Scalar::all(0));
Mat planes[] = {Mat_<float>(padded), Mat::zeros(padded.size(), CV_32F)};
Mat complexI;
merge(planes, 2, complexI); // Add to the expanded another plane with zeros
dft(complexI, complexI); // this way the result may fit in the source matrix
// compute the magnitude and switch to logarithmic scale
// => log(1 + sqrt(Re(DFT(I))^2 + Im(DFT(I))^2))
split(complexI, planes); // planes[0] = Re(DFT(I), planes[1] = Im(DFT(I))
magnitude(planes[0], planes[1], planes[0]);// planes[0] = magnitude
Mat magI = planes[0];
magI += Scalar::all(1); // switch to logarithmic scale
log(magI, magI);
// crop the spectrum, if it has an odd number of rows or columns
magI = magI(Rect(0, 0, magI.cols & -2, magI.rows & -2));
// rearrange the quadrants of Fourier image so that the origin is at the image center
int cx = magI.cols/2;
int cy = magI.rows/2;
Mat q0(magI, Rect(0, 0, cx, cy)); // Top-Left - Create a ROI per quadrant
Mat q1(magI, Rect(cx, 0, cx, cy)); // Top-Right
Mat q2(magI, Rect(0, cy, cx, cy)); // Bottom-Left
Mat q3(magI, Rect(cx, cy, cx, cy)); // Bottom-Right
Mat tmp; // swap quadrants (Top-Left with Bottom-Right)
q0.copyTo(tmp);
q3.copyTo(q0);
tmp.copyTo(q3);
q1.copyTo(tmp); // swap quadrant (Top-Right with Bottom-Left)
q2.copyTo(q1);
tmp.copyTo(q2);
normalize(magI, magI, 0, 1,NORM_MINMAX); // Transform the matrix with float values into a
// viewable image form (float between values 0 and 1).
imwrite(root + "gray_" + filename + ".jpg",I);
imshow("Input Image" , I ); // Show the result
imshow("spectrum magnitude", magI);
waitKey();
return 0;
}
*/
//int main( int argc, char** argv )
//{
// auto img = imread(PIC,1);
// imwrite("/home/dupeljan/Documents/courcework_2019/photos/tmpl_matching_inp.png",img);
// auto templ = imread(CURSOR,1);
// imwrite("/home/dupeljan/Documents/courcework_2019/photos/cursor.png",templ);
// Mat mask;
// thresh_otsu(templ,mask);
// cvtColor(mask,mask,COLOR_GRAY2BGR);
// Point matchLoc;
// matchTemplateCoords(img,templ,mask,matchLoc);
// rectangle(img,Rect(matchLoc.x,matchLoc.y,mask.cols,mask.rows),Scalar(255,0,0),2);
// imwrite("/home/dupeljan/Documents/courcework_2019/photos/templ_matching_result.png",img);
//}
#endif