-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDivid.cpp
100 lines (69 loc) · 2.41 KB
/
Divid.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
#include"Divid.h"
dividedM::dividedM(Mat &src,float press,float h_up,float h_down, float w)
{
this->src = src;
this->press = press;
this->hor_up = h_up;
this->hor_down = h_down;
this->ver_rate = w;
hei = src.size().height;
wid = src.size().width;
subhei = wid / 2;
subwid = hei;
}
void dividedM::pace1(){
left = Mat(src, Rect(0, 0, wid / 2, hei));
right = Mat(src, Rect(wid / 2, 0, wid / 2, hei));
transpose(left, left);
flip(left, left, 1);
transpose(right, right);
flip(right, right, 0);
pace3(left);
}
/*Mat dcolorComb::C_adjust(Mat & inputL, Mat & inputR)
{
int dh = int(((float)hei- dhei*2)*hor_rate);
int dw = int((float)wid*ver_rate);
int orwid = inputL.size().width;
int orhei = inputL.size().height;
inputL = Mat(inputL, Rect(dw, dh+ dhei, wid/2-2*dw, hei - 2 * (dh+dhei)));
inputR = Mat(inputR, Rect(dw, dh + dhei, wid/2 - 2 * dw, hei - 2 * (dh + dhei)));
cv::resize(inputL,inputL,cv::Size(orwid,orhei),0,0,INTER_LINEAR);
cv::resize(inputR,inputR,cv::Size(orwid,orhei),0,0,INTER_LINEAR);
int totalCols = inputL.cols + inputR.cols;
Mat mergedDescriptors(hei, wid, inputL.type());
Mat submat = mergedDescriptors.rowRange(0,inputL.rows).colRange(0,inputL.cols);
inputL.copyTo(submat);
submat = mergedDescriptors.rowRange(0,inputL.rows).colRange(inputL.cols, totalCols);
inputR.copyTo(submat);
return mergedDescriptors;
}
Mat dcolorComb::process()
{
Mat out_T = T_adjust(this->src);
return out_T;
}
*/
void dividedM::pace3(Mat &img){
double pare = tan(press * 3.1415926 / 360);
dwid = int(subhei * pare);
vector<Point2f> src_corners(4);
vector<Point2f> dst_corners(4);
src_corners[0]= Point2f(0,0);
src_corners[1]= Point2f(subwid - 1,0);
src_corners[2]= Point2f(0, subhei - 1);
src_corners[3]= Point2f(subwid - 1, subhei - 1);
dst_corners[0]= Point2f(dwid,0);
dst_corners[1]= Point2f(subwid - 1 - dwid,0);
dst_corners[2]= Point2f(0, subhei - 1);
dst_corners[3]= Point2f(subwid - 1, subhei - 1);
Mat transMtx = getPerspectiveTransform(src_corners, dst_corners);
warpPerspective(img, img, transMtx, Size(subwid, subhei));
/*test
printf("rows & cols:%d,%d\nhei & wid:%d,%d\n",img.rows,img.cols,subhei,subwid);
string outFilename("pressed.jpg");
cout << "Saving pressed image : " << outFilename << endl;
imwrite(outFilename, img);
*/
return ;
}