1
1
#include < iostream>
2
+ #include < fstream>
2
3
#include < opencv2/core.hpp>
3
4
#include < opencv2/core/utility.hpp>
4
5
#include < opencv2/highgui.hpp>
@@ -52,23 +53,35 @@ static void UpdateThreshImage(int , void *r)
52
53
53
54
imshow (" Max Quaternion corr" ,dst);
54
55
}
56
+ vector<Vec4d> LectureFichier (string s)
57
+ {
58
+ fstream f;
59
+ vector<Vec4d> q;
60
+ f.open (s, ios::in);
61
+ int nbQuat;
62
+ f >> nbQuat;
63
+ f >> nbQuat;
64
+ nbQuat = nbQuat * nbQuat;
65
+ for (int i = 0 ; i < nbQuat; i++)
66
+ {
67
+ Vec4d v;
68
+ f >> v[0 ] >> v[1 ] >> v[2 ] >> v[3 ];
69
+ q.push_back (v);
70
+ }
71
+ return q;
72
+ }
73
+
74
+
55
75
56
76
int main (int , char *[])
57
77
{
58
- #define TESTMATCHING
59
-
60
- #ifdef TESTMATCHING
61
78
Mat imgLogo = imread (" g:/lib/opencv/samples/data/opencv-logo.png" , IMREAD_COLOR);
62
- Mat fruits = imread (" g:/lib/opencv/samples/data/lena.jpg" , IMREAD_COLOR);
63
- fruits = fruits ;
64
- // resize(fruits,fruits, Size(), 0.5, 0.5);
79
+ Mat imgColor = imread (" g:/lib/opencv/samples/data/lena.jpg" , IMREAD_COLOR);
80
+ // DUPLICATE OPENCV LOGO CHANGING COLOR
65
81
Mat img,colorTemplate;
66
82
imgLogo (Rect (0 , 0 , imgLogo.cols , 580 )).copyTo (img);
67
83
resize (img, colorTemplate, Size (), 0.05 , 0.05 );
68
84
vector<Mat> colorMask (4 );
69
- inRange (colorTemplate, Vec3b (255 , 255 , 255 ), Vec3b (255 , 255 , 255 ), colorMask[0 ]);
70
- // colorTemplate.setTo(Scalar(0,0,0), colorMask[0]);
71
-
72
85
inRange (colorTemplate, Vec3b (255 , 0 , 0 ), Vec3b (255 , 0 , 0 ), colorMask[0 ]);
73
86
inRange (colorTemplate, Vec3b (0 , 255 , 0 ), Vec3b (0 ,255 , 0 ), colorMask[1 ]);
74
87
inRange (colorTemplate, Vec3b ( 0 , 0 ,255 ), Vec3b ( 0 , 0 ,255 ), colorMask[2 ]);
@@ -86,24 +99,23 @@ int main(int , char *[])
86
99
}
87
100
else
88
101
ps.pRef .push_back (p);
89
- newLogo.copyTo (fruits (Rect (p.x , p.y , newLogo.cols , newLogo.rows )));
102
+ newLogo.copyTo (imgColor (Rect (p.x , p.y , newLogo.cols , newLogo.rows )));
90
103
91
104
}
92
- #else
93
- Mat fruits = imread (" c2.png" , IMREAD_COLOR);
94
- Mat colorTemplate = imread (" c1.png" , IMREAD_COLOR);
95
- Mat img= colorTemplate;
96
- #endif
97
- imshow (" Image" , fruits);
105
+ imshow (" Image" , imgColor);
98
106
imshow (" opencv_logo" , colorTemplate);
99
-
107
+ imwrite (" g:/image.png" , imgColor);
108
+ Mat colorRef (imgColor.size (), imgColor.type (),Scalar::all (0 ));
109
+ colorTemplate.copyTo (colorRef (Rect (0 , 0 , colorTemplate.cols , colorTemplate.rows )));
110
+ imwrite (" g:/opencv_logo.png" , colorRef);
100
111
if (img.empty ())
101
112
{
102
113
cout << " Cannot load image file\n " ;
103
114
return 0 ;
104
115
}
116
+ // OK NOW WHERE IS OPENCV LOGO ?
105
117
Mat imgcorr;
106
- ximgproc::colorMatchTemplate (fruits , colorTemplate, imgcorr);
118
+ ximgproc::colorMatchTemplate (imgColor , colorTemplate, imgcorr);
107
119
imshow (" quaternion correlation real" , imgcorr);
108
120
normalize (imgcorr, imgcorr,1 ,0 ,NORM_MINMAX);
109
121
imgcorr.convertTo (ps.img , CV_8U, 255 );
@@ -115,9 +127,6 @@ int main(int , char *[])
115
127
code = waitKey (50 );
116
128
}
117
129
118
- FileStorage fs (" corr.yml" , FileStorage::WRITE);
119
- fs<<" Image" << imgcorr;
120
- fs.release ();
121
130
waitKey (0 );
122
131
return 0 ;
123
132
}
0 commit comments