1 | #include "opencv2/highgui/highgui.hpp"
|
2 | #include "opencv2/core/core.hpp"
|
3 | #include "opencv2/imgproc/imgproc.hpp"
|
4 |
|
5 | #include <iostream>
|
6 | #include <stdio.h>
|
7 |
|
8 | #define MAXSTRING 50
|
9 |
|
10 | using namespace cv;
|
11 | using namespace std;
|
12 |
|
13 |
|
14 | class percepUnit {
|
15 |
|
16 | public:
|
17 | Mat image;
|
18 | Mat mask;
|
19 | int x1, y1;
|
20 | int w, h;
|
21 |
|
22 |
|
23 | percepUnit(Mat ROI, Mat alpha, int ix, int iy, int iw, int ih) {
|
24 | ROI.copyTo(image);
|
25 | alpha.copyTo(mask);
|
26 | x1 = ix;
|
27 | y1 = iy;
|
28 | w = iw;
|
29 | h = ih;
|
30 | }
|
31 |
|
32 |
|
33 | ~percepUnit() {
|
34 |
|
35 | image.release();
|
36 | mask.release();
|
37 | }
|
38 | };
|
39 |
|
40 |
|
41 |
|
42 | int copyPercept(percepUnit &unit, Mat &dest) {
|
43 |
|
44 |
|
45 | for( int y = 0; y < unit.image.rows; y++ ) {
|
46 | for( int x = 0; x < unit.image.cols; x++ ) {
|
47 |
|
48 | if (unit.mask.at<char>(y,x) != 0) {
|
49 |
|
50 | Vec3b pixel = unit.image.at<Vec3b>(y,x);
|
51 |
|
52 |
|
53 | dest.at<Vec3b>(y+unit.y1,x+unit.x1) = pixel;
|
54 | }
|
55 | }
|
56 | }
|
57 |
|
58 | return(0);
|
59 | }
|
60 |
|
61 | int main(int argc, char* argv[])
|
62 | {
|
63 | Mat reconstruction2 = Mat(1080,1920, CV_8UC3, Scalar(255,255,255));
|
64 |
|
65 | for (int s=1070; s<1920; s++) {
|
66 |
|
67 | Mat tmpImage = Mat(s,s, CV_8UC3, Scalar(0,0,0));
|
68 | Mat tmpMask = Mat(s,s, CV_8UC1, Scalar(255,255,255));
|
69 | percepUnit tmpUnit = percepUnit(tmpImage, tmpMask, 0, 0, s, s);
|
70 |
|
71 | cout << "size: " << s << endl;
|
72 | reconstruction2 = copyPercept(tmpUnit, reconstruction2);
|
73 | }
|
74 |
|
75 | imwrite("reconstruction2.png",reconstruction2);
|
76 |
|
77 | exit(0);
|
78 | }
|