Skip to content

Commit f68153c

Browse files
committed
add a test case
1 parent 63b4992 commit f68153c

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,8 @@ running time: 1024x1024, 60ms to construct response map, 7ms for 360 templates
5757
test img & templ features
5858
![test](./test/case1/result.png)
5959
![templ](test/case1/templ.png)
60+
61+
62+
### noise test
63+
64+
![test2](test/case2/result/together.png)

test.cpp

+12-16
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ void noise_test(){
266266
Rect roi(0, 0, stride*m , stride*n);
267267

268268
test_img = test_img(roi).clone();
269+
269270
Timer timer;
270271
auto matches = detector.match(test_img, 90, ids);
271272
timer.out();
@@ -297,27 +298,22 @@ void noise_test(){
297298
auto templ = detector.getTemplates("test",
298299
match.template_id);
299300

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-
313301
int x = templ[0].width + match.x;
314302
int y = templ[0].height + match.y;
315303
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+
}
317313

318314
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);
321317

322318
std::cout << "\nmatch.template_id: " << match.template_id << std::endl;
323319
std::cout << "match.similarity: " << match.similarity << std::endl;

test/case2/result/together.png

224 KB
Loading

0 commit comments

Comments
 (0)