|
43 | 43 |
|
44 | 44 | using namespace std;
|
45 | 45 | using namespace cv;
|
| 46 | +using namespace testing; |
46 | 47 |
|
47 | 48 | const string FEATURES2D_DIR = "features2d";
|
48 | 49 | const string IMAGE_FILENAME = "tsukuba.png";
|
@@ -417,68 +418,82 @@ TEST( Features2d_DescriptorExtractor, batch )
|
417 | 418 | }
|
418 | 419 | }
|
419 | 420 |
|
420 |
| -TEST( Features2d_Feature2d, no_crash ) |
| 421 | +class DescriptorImage : public TestWithParam<std::string> |
| 422 | +{ |
| 423 | +protected: |
| 424 | + virtual void SetUp() { |
| 425 | + pattern = GetParam(); |
| 426 | + } |
| 427 | + |
| 428 | + std::string pattern; |
| 429 | +}; |
| 430 | + |
| 431 | +TEST_P(DescriptorImage, no_crash) |
421 | 432 | {
|
422 |
| - const String& pattern = string(cvtest::TS::ptr()->get_data_path() + "shared/*.png"); |
423 | 433 | vector<String> fnames;
|
424 |
| - glob(pattern, fnames, false); |
| 434 | + glob(cvtest::TS::ptr()->get_data_path() + pattern, fnames, false); |
425 | 435 | sort(fnames.begin(), fnames.end());
|
426 | 436 |
|
427 |
| - Ptr<AKAZE> akaze = AKAZE::create(); |
| 437 | + Ptr<AKAZE> akaze_mldb = AKAZE::create(AKAZE::DESCRIPTOR_MLDB); |
| 438 | + Ptr<AKAZE> akaze_mldb_upright = AKAZE::create(AKAZE::DESCRIPTOR_MLDB_UPRIGHT); |
| 439 | + Ptr<AKAZE> akaze_mldb_256 = AKAZE::create(AKAZE::DESCRIPTOR_MLDB, 256); |
| 440 | + Ptr<AKAZE> akaze_mldb_upright_256 = AKAZE::create(AKAZE::DESCRIPTOR_MLDB_UPRIGHT, 256); |
| 441 | + Ptr<AKAZE> akaze_kaze = AKAZE::create(AKAZE::DESCRIPTOR_KAZE); |
| 442 | + Ptr<AKAZE> akaze_kaze_upright = AKAZE::create(AKAZE::DESCRIPTOR_KAZE_UPRIGHT); |
428 | 443 | Ptr<ORB> orb = ORB::create();
|
429 | 444 | Ptr<KAZE> kaze = KAZE::create();
|
430 | 445 | Ptr<BRISK> brisk = BRISK::create();
|
431 |
| - size_t i, n = fnames.size(); |
| 446 | + size_t n = fnames.size(); |
432 | 447 | vector<KeyPoint> keypoints;
|
433 | 448 | Mat descriptors;
|
434 | 449 | orb->setMaxFeatures(5000);
|
435 | 450 |
|
436 |
| - for( i = 0; i < n; i++ ) |
| 451 | + for(size_t i = 0; i < n; i++ ) |
437 | 452 | {
|
438 | 453 | printf("%d. image: %s:\n", (int)i, fnames[i].c_str());
|
439 | 454 | if( strstr(fnames[i].c_str(), "MP.png") != 0 )
|
| 455 | + { |
| 456 | + printf("\tskip\n"); |
440 | 457 | continue;
|
| 458 | + } |
441 | 459 | bool checkCount = strstr(fnames[i].c_str(), "templ.png") == 0;
|
442 | 460 |
|
443 | 461 | Mat img = imread(fnames[i], -1);
|
444 |
| - printf("\tAKAZE ... "); fflush(stdout); |
445 |
| - akaze->detectAndCompute(img, noArray(), keypoints, descriptors); |
446 |
| - printf("(%d keypoints) ", (int)keypoints.size()); fflush(stdout); |
447 |
| - if( checkCount ) |
448 |
| - { |
449 |
| - EXPECT_GT((int)keypoints.size(), 0); |
450 |
| - } |
451 |
| - ASSERT_EQ(descriptors.rows, (int)keypoints.size()); |
452 |
| - printf("ok\n"); |
453 | 462 |
|
454 |
| - printf("\tKAZE ... "); fflush(stdout); |
455 |
| - kaze->detectAndCompute(img, noArray(), keypoints, descriptors); |
456 |
| - printf("(%d keypoints) ", (int)keypoints.size()); fflush(stdout); |
457 |
| - if( checkCount ) |
458 |
| - { |
459 |
| - EXPECT_GT((int)keypoints.size(), 0); |
460 |
| - } |
| 463 | + printf("\t%dx%d\n", img.cols, img.rows); |
| 464 | + |
| 465 | +#define TEST_DETECTOR(name, descriptor) \ |
| 466 | + keypoints.clear(); descriptors.release(); \ |
| 467 | + printf("\t" name "\n"); fflush(stdout); \ |
| 468 | + descriptor->detectAndCompute(img, noArray(), keypoints, descriptors); \ |
| 469 | + printf("\t\t\t(%d keypoints, descriptor size = %d)\n", (int)keypoints.size(), descriptors.cols); fflush(stdout); \ |
| 470 | + if (checkCount) \ |
| 471 | + { \ |
| 472 | + EXPECT_GT((int)keypoints.size(), 0); \ |
| 473 | + } \ |
461 | 474 | ASSERT_EQ(descriptors.rows, (int)keypoints.size());
|
462 |
| - printf("ok\n"); |
463 | 475 |
|
464 |
| - printf("\tORB ... "); fflush(stdout); |
465 |
| - orb->detectAndCompute(img, noArray(), keypoints, descriptors); |
466 |
| - printf("(%d keypoints) ", (int)keypoints.size()); fflush(stdout); |
467 |
| - if( checkCount ) |
468 |
| - { |
469 |
| - EXPECT_GT((int)keypoints.size(), 0); |
470 |
| - } |
471 |
| - ASSERT_EQ(descriptors.rows, (int)keypoints.size()); |
472 |
| - printf("ok\n"); |
473 |
| - |
474 |
| - printf("\tBRISK ... "); fflush(stdout); |
475 |
| - brisk->detectAndCompute(img, noArray(), keypoints, descriptors); |
476 |
| - printf("(%d keypoints) ", (int)keypoints.size()); fflush(stdout); |
477 |
| - if( checkCount ) |
478 |
| - { |
479 |
| - EXPECT_GT((int)keypoints.size(), 0); |
480 |
| - } |
481 |
| - ASSERT_EQ(descriptors.rows, (int)keypoints.size()); |
482 |
| - printf("ok\n"); |
| 476 | + TEST_DETECTOR("AKAZE:MLDB", akaze_mldb); |
| 477 | + TEST_DETECTOR("AKAZE:MLDB_UPRIGHT", akaze_mldb_upright); |
| 478 | + TEST_DETECTOR("AKAZE:MLDB_256", akaze_mldb_256); |
| 479 | + TEST_DETECTOR("AKAZE:MLDB_UPRIGHT_256", akaze_mldb_upright_256); |
| 480 | + TEST_DETECTOR("AKAZE:KAZE", akaze_kaze); |
| 481 | + TEST_DETECTOR("AKAZE:KAZE_UPRIGHT", akaze_kaze_upright); |
| 482 | + TEST_DETECTOR("KAZE", kaze); |
| 483 | + TEST_DETECTOR("ORB", orb); |
| 484 | + TEST_DETECTOR("BRISK", brisk); |
483 | 485 | }
|
484 | 486 | }
|
| 487 | + |
| 488 | +INSTANTIATE_TEST_CASE_P(Features2d, DescriptorImage, |
| 489 | + testing::Values( |
| 490 | + "shared/lena.png", |
| 491 | + "shared/box*.png", |
| 492 | + "shared/fruits*.png", |
| 493 | + "shared/airplane.png", |
| 494 | + "shared/graffiti.png", |
| 495 | + "shared/1_itseez-0001*.png", |
| 496 | + "shared/pic*.png", |
| 497 | + "shared/templ.png" |
| 498 | + ) |
| 499 | +); |
0 commit comments