@@ -266,6 +266,7 @@ void noise_test(){
266
266
Rect roi (0 , 0 , stride*m , stride*n);
267
267
268
268
test_img = test_img (roi).clone ();
269
+
269
270
Timer timer;
270
271
auto matches = detector.match (test_img, 90 , ids);
271
272
timer.out ();
@@ -297,27 +298,22 @@ void noise_test(){
297
298
auto templ = detector.getTemplates (" test" ,
298
299
match.template_id );
299
300
300
- int cols = templ[0 ].width + 1 ;
301
- int rows = templ[0 ].height + 1 ;
302
- cv::Mat view = cv::Mat (rows, cols, CV_8UC1, cv::Scalar (0 ));
303
- for (int i=0 ; i<templ[0 ].features .size (); i++){
304
- auto feat = templ[0 ].features [i];
305
- assert (feat.y <rows);
306
- assert (feat.x <cols);
307
- view.at <uchar>(feat.y , feat.x ) = 255 ;
308
- }
309
- view = view>0 ;
310
- imshow (" test" , view);
311
- waitKey (0 );
312
-
313
301
int x = templ[0 ].width + match.x ;
314
302
int y = templ[0 ].height + match.y ;
315
303
int r = templ[0 ].width /2 ;
316
- Scalar color (255 , rand ()%255 , rand ()%255 );
304
+ cv::Vec3b randColor;
305
+ randColor[0 ] = rand ()%155 + 100 ;
306
+ randColor[1 ] = rand ()%155 + 100 ;
307
+ randColor[2 ] = rand ()%155 + 100 ;
308
+
309
+ for (int i=0 ; i<templ[0 ].features .size (); i++){
310
+ auto feat = templ[0 ].features [i];
311
+ cv::circle (test_img, {feat.x +match.x , feat.y +match.y }, 2 , randColor, -1 );
312
+ }
317
313
318
314
cv::putText (test_img, to_string (int (round (match.similarity ))),
319
- Point (match.x +r-10 , match.y -3 ), FONT_HERSHEY_PLAIN, 2 , color );
320
- cv::rectangle (test_img, {match.x , match.y }, {x, y}, color , 2 );
315
+ Point (match.x +r-10 , match.y -3 ), FONT_HERSHEY_PLAIN, 2 , randColor );
316
+ cv::rectangle (test_img, {match.x , match.y }, {x, y}, randColor , 2 );
321
317
322
318
std::cout << " \n match.template_id: " << match.template_id << std::endl;
323
319
std::cout << " match.similarity: " << match.similarity << std::endl;
0 commit comments