@@ -305,6 +305,7 @@ template <typename Type> void run_test(const std::string &env_ipath, const std::
305
305
306
306
// Test with binary descriptor
307
307
{
308
+ std::cout << " Detect ORB keypoints" << std::endl;
308
309
std::string keypointName = " ORB" ;
309
310
keyPoints.setDetector (keypointName);
310
311
keyPoints.setExtractor (keypointName);
@@ -324,6 +325,7 @@ template <typename Type> void run_test(const std::string &env_ipath, const std::
324
325
filename = vpIoTools::createFilePath (opath, " bin_with_img" );
325
326
vpIoTools::makeDirectory (filename);
326
327
filename = vpIoTools::createFilePath (filename, " test_save_in_bin_with_img.bin" );
328
+ std::cout << " Save keypoints in binary with image in: " << filename << std::endl;
327
329
keyPoints.saveLearningData (filename, true , true );
328
330
329
331
// Test if save is ok
@@ -335,18 +337,20 @@ template <typename Type> void run_test(const std::string &env_ipath, const std::
335
337
336
338
// Test if read is ok
337
339
vpKeyPoint read_keypoint1;
338
-
340
+ std::cout << " Read keypoints from file: " << filename << std::endl;
339
341
read_keypoint1.loadLearningData (filename, true );
340
342
341
343
std::vector<cv::KeyPoint> trainKeyPoints_read;
342
344
read_keypoint1.getTrainKeyPoints (trainKeyPoints_read);
343
345
cv::Mat trainDescriptors_read = read_keypoint1.getTrainDescriptors ();
344
346
347
+ std::cout << " Compare keypoints" << std::endl;
345
348
if (!compareKeyPoints (trainKeyPoints, trainKeyPoints_read)) {
346
349
throw vpException (vpException::fatalError, " Problem with trainKeyPoints when reading learning file saved "
347
350
" in binary with train images saved !" );
348
351
}
349
352
353
+ std::cout << " Compare descriptors" << std::endl;
350
354
if (!compareDescriptors (trainDescriptors, trainDescriptors_read)) {
351
355
throw vpException (vpException::fatalError, " Problem with trainDescriptors when reading "
352
356
" learning file saved in "
@@ -357,6 +361,7 @@ template <typename Type> void run_test(const std::string &env_ipath, const std::
357
361
filename = vpIoTools::createFilePath (opath, " bin_without_img" );
358
362
vpIoTools::makeDirectory (filename);
359
363
filename = vpIoTools::createFilePath (filename, " test_save_in_bin_without_img.bin" );
364
+ std::cout << " Save keypoints in binary without image in: " << filename << std::endl;
360
365
keyPoints.saveLearningData (filename, true , false );
361
366
362
367
// Test if save is ok
@@ -368,27 +373,31 @@ template <typename Type> void run_test(const std::string &env_ipath, const std::
368
373
369
374
// Test if read is ok
370
375
vpKeyPoint read_keypoint2;
376
+ std::cout << " Read keypoints from file: " << filename << std::endl;
371
377
read_keypoint2.loadLearningData (filename, true );
372
378
trainKeyPoints_read.clear ();
373
379
read_keypoint2.getTrainKeyPoints (trainKeyPoints_read);
374
380
trainDescriptors_read = read_keypoint2.getTrainDescriptors ();
375
381
382
+ std::cout << " Compare keypoints" << std::endl;
376
383
if (!compareKeyPoints (trainKeyPoints, trainKeyPoints_read)) {
377
384
throw vpException (vpException::fatalError, " Problem with trainKeyPoints when reading learning file saved in "
378
385
" binary without train images !" );
379
386
}
380
387
388
+ std::cout << " Compare descriptors" << std::endl;
381
389
if (!compareDescriptors (trainDescriptors, trainDescriptors_read)) {
382
390
throw vpException (vpException::fatalError, " Problem with trainDescriptors when reading "
383
391
" learning file saved in "
384
392
" binary without train images !" );
385
393
}
386
394
387
- #if defined(VISP_HAVE_PUGYXML )
395
+ #if defined(VISP_HAVE_PUGIXML )
388
396
// Save in xml with training images
389
397
filename = vpIoTools::createFilePath (opath, " xml_with_img" );
390
398
vpIoTools::makeDirectory (filename);
391
399
filename = vpIoTools::createFilePath (filename, " test_save_in_xml_with_img.xml" );
400
+ std::cout << " Save keypoints in xml with image in: " << filename << std::endl;
392
401
keyPoints.saveLearningData (filename, false , true );
393
402
394
403
// Test if save is ok
@@ -400,16 +409,19 @@ template <typename Type> void run_test(const std::string &env_ipath, const std::
400
409
401
410
// Test if read is ok
402
411
vpKeyPoint read_keypoint3;
412
+ std::cout << " Read keypoints from file: " << filename << std::endl;
403
413
read_keypoint3.loadLearningData (filename, false );
404
414
trainKeyPoints_read.clear ();
405
415
read_keypoint3.getTrainKeyPoints (trainKeyPoints_read);
406
416
trainDescriptors_read = read_keypoint3.getTrainDescriptors ();
407
417
418
+ std::cout << " Compare keypoints" << std::endl;
408
419
if (!compareKeyPoints (trainKeyPoints, trainKeyPoints_read)) {
409
420
throw vpException (vpException::fatalError, " Problem with trainKeyPoints when reading learning file saved in "
410
421
" xml with train images saved !" );
411
422
}
412
423
424
+ std::cout << " Compare descriptors" << std::endl;
413
425
if (!compareDescriptors (trainDescriptors, trainDescriptors_read)) {
414
426
throw vpException (vpException::fatalError, " Problem with trainDescriptors when reading "
415
427
" learning file saved in "
@@ -420,6 +432,7 @@ template <typename Type> void run_test(const std::string &env_ipath, const std::
420
432
filename = vpIoTools::createFilePath (opath, " xml_without_img" );
421
433
vpIoTools::makeDirectory (filename);
422
434
filename = vpIoTools::createFilePath (filename, " test_save_in_xml_without_img.xml" );
435
+ std::cout << " Save keypoints in xml without image in: " << filename << std::endl;
423
436
keyPoints.saveLearningData (filename, false , false );
424
437
425
438
// Test if save is ok
@@ -433,14 +446,17 @@ template <typename Type> void run_test(const std::string &env_ipath, const std::
433
446
vpKeyPoint read_keypoint4;
434
447
read_keypoint4.loadLearningData (filename, false );
435
448
trainKeyPoints_read.clear ();
449
+ std::cout << " Read keypoints from file: " << filename << std::endl;
436
450
read_keypoint4.getTrainKeyPoints (trainKeyPoints_read);
437
451
trainDescriptors_read = read_keypoint4.getTrainDescriptors ();
438
452
453
+ std::cout << " Compare keypoints" << std::endl;
439
454
if (!compareKeyPoints (trainKeyPoints, trainKeyPoints_read)) {
440
455
throw vpException (vpException::fatalError, " Problem with trainKeyPoints when reading learning file saved in "
441
456
" xml without train images saved !" );
442
457
}
443
458
459
+ std::cout << " Compare descriptors" << std::endl;
444
460
if (!compareDescriptors (trainDescriptors, trainDescriptors_read)) {
445
461
throw vpException (vpException::fatalError, " Problem with trainDescriptors when reading "
446
462
" learning file saved in "
@@ -457,19 +473,22 @@ template <typename Type> void run_test(const std::string &env_ipath, const std::
457
473
{
458
474
#if (VISP_HAVE_OPENCV_VERSION != 0x040504) && (VISP_HAVE_OPENCV_VERSION != 0x040505) && \
459
475
(VISP_HAVE_OPENCV_VERSION != 0x040600 ) && (VISP_HAVE_OPENCV_VERSION != 0x040700 ) && \
460
- (VISP_HAVE_OPENCV_VERSION != 0x040900 ) && (VISP_HAVE_OPENCV_VERSION != 0x041000 ) && \
476
+ (VISP_HAVE_OPENCV_VERSION != 0x040900 ) && (VISP_HAVE_OPENCV_VERSION != 0x040A00 ) && \
461
477
(defined (__APPLE__) && defined (__MACH__))
462
478
// SIFT is known to be unstable with OpenCV 4.5.4 and 4.5.5 on macOS (see #1048)
463
479
// Same for OpenCV 4.6.0 (see #1106) where it produces an Illegal Instruction error when OpenCV 4.6.0 is
464
480
// installed with brew. It seems working when OpenCV is build from source
465
481
std::string keypointName = " SIFT" ;
482
+ std::cout << " Use " << keypointName << " keypoints" << std::endl;
466
483
keyPoints.setDetector (keypointName);
467
484
keyPoints.setExtractor (keypointName);
468
485
486
+ std::cout << " Detect keypoints" << std::endl;
469
487
keyPoints.buildReference (I);
470
488
471
489
std::vector<cv::KeyPoint> trainKeyPoints;
472
490
keyPoints.getTrainKeyPoints (trainKeyPoints);
491
+ std::cout << " Get descriptors" << std::endl;
473
492
cv::Mat trainDescriptors = keyPoints.getTrainDescriptors ();
474
493
if (trainKeyPoints.empty () || trainDescriptors.empty () || (int )trainKeyPoints.size () != trainDescriptors.rows ) {
475
494
throw vpException (vpException::fatalError, " Problem when detecting keypoints or when "
@@ -480,6 +499,7 @@ template <typename Type> void run_test(const std::string &env_ipath, const std::
480
499
filename = vpIoTools::createFilePath (opath, " bin_with_img" );
481
500
vpIoTools::makeDirectory (filename);
482
501
filename = vpIoTools::createFilePath (filename, " test_save_in_bin_with_img.bin" );
502
+ std::cout << " Save keypoints in binary with image in: " << filename << std::endl;
483
503
keyPoints.saveLearningData (filename, true , true );
484
504
485
505
// Test if save is ok
@@ -491,16 +511,19 @@ template <typename Type> void run_test(const std::string &env_ipath, const std::
491
511
492
512
// Test if read is ok
493
513
vpKeyPoint read_keypoint1;
514
+ std::cout << " Load keypoints from: " << filename << std::endl;
494
515
read_keypoint1.loadLearningData (filename, true );
495
516
std::vector<cv::KeyPoint> trainKeyPoints_read;
496
517
read_keypoint1.getTrainKeyPoints (trainKeyPoints_read);
497
518
cv::Mat trainDescriptors_read = read_keypoint1.getTrainDescriptors ();
498
519
520
+ std::cout << " Compare keypoints" << std::endl;
499
521
if (!compareKeyPoints (trainKeyPoints, trainKeyPoints_read)) {
500
522
throw vpException (vpException::fatalError, " Problem with trainKeyPoints when reading learning file saved in "
501
523
" binary with train images saved !" );
502
524
}
503
525
526
+ std::cout << " Compare descriptors" << std::endl;
504
527
if (!compareDescriptors (trainDescriptors, trainDescriptors_read)) {
505
528
throw vpException (vpException::fatalError, " Problem with trainDescriptors when reading "
506
529
" learning file saved in "
@@ -511,6 +534,7 @@ template <typename Type> void run_test(const std::string &env_ipath, const std::
511
534
filename = vpIoTools::createFilePath (opath, " bin_without_img" );
512
535
vpIoTools::makeDirectory (filename);
513
536
filename = vpIoTools::createFilePath (filename, " test_save_in_bin_without_img.bin" );
537
+ std::cout << " Save keypoints in binary without image in: " << filename << std::endl;
514
538
keyPoints.saveLearningData (filename, true , false );
515
539
516
540
// Test if save is ok
@@ -522,23 +546,26 @@ template <typename Type> void run_test(const std::string &env_ipath, const std::
522
546
523
547
// Test if read is ok
524
548
vpKeyPoint read_keypoint2;
549
+ std::cout << " Load keypoints from: " << filename << std::endl;
525
550
read_keypoint2.loadLearningData (filename, true );
526
551
trainKeyPoints_read.clear ();
527
552
read_keypoint2.getTrainKeyPoints (trainKeyPoints_read);
528
553
trainDescriptors_read = read_keypoint2.getTrainDescriptors ();
529
554
555
+ std::cout << " Compare keypoints" << std::endl;
530
556
if (!compareKeyPoints (trainKeyPoints, trainKeyPoints_read)) {
531
557
throw vpException (vpException::fatalError, " Problem with trainKeyPoints when reading learning file saved in "
532
558
" binary without train images saved !" );
533
559
}
534
560
561
+ std::cout << " Compare descriptors" << std::endl;
535
562
if (!compareDescriptors (trainDescriptors, trainDescriptors_read)) {
536
563
throw vpException (vpException::fatalError, " Problem with trainDescriptors when reading "
537
564
" learning file saved in "
538
565
" binary without train images saved !" );
539
566
}
540
567
541
- #if defined(VISP_HAVE_PUGYXML )
568
+ #if defined(VISP_HAVE_PUGIXML )
542
569
// Save in xml with training images
543
570
filename = vpIoTools::createFilePath (opath, " xml_with_img" );
544
571
vpIoTools::makeDirectory (filename);
@@ -607,37 +634,41 @@ template <typename Type> void run_test(const std::string &env_ipath, const std::
607
634
vpKeyPoint keypoint_reset;
608
635
609
636
keypointName = " ORB" ;
637
+ std::cout << " Use " << keypointName << " as keypoints" << std::endl;
610
638
keypoint_reset.setDetector (keypointName);
611
639
keypoint_reset.setExtractor (keypointName);
612
640
613
641
keypoint_reset.buildReference (I);
642
+ std::cout << keypointName << " keypoints are detected" << std::endl;
614
643
615
644
// reset
616
645
keypoint_reset.reset ();
617
646
618
647
keypointName = " SIFT" ;
648
+ std::cout << " Use " << keypointName << " as keypoints" << std::endl;
619
649
keypoint_reset.setDetector (keypointName);
620
650
keypoint_reset.setExtractor (keypointName);
621
651
622
652
keypoint_reset.buildReference (I);
653
+ std::cout << keypointName << " keypoints are detected" << std::endl;
623
654
624
655
std::vector<cv::KeyPoint> trainKeyPoints_reset;
625
656
keypoint_reset.getTrainKeyPoints (trainKeyPoints_reset);
657
+ std::cout << " Get descriptors" << std::endl;
626
658
cv::Mat trainDescriptors_reset = keypoint_reset.getTrainDescriptors ();
627
659
628
- // If reset is ok, we should get the same keypoints and the same
629
- // descriptors
660
+ // If reset is ok, we should get the same keypoints and the same descriptors
661
+ std::cout << " Compare keypoints " << std::endl;
630
662
if (!compareKeyPoints (trainKeyPoints, trainKeyPoints_reset)) {
631
663
throw vpException (vpException::fatalError, " Problem with vpKeyPoint::reset() and trainKeyPoints !" );
632
664
}
633
665
666
+ std::cout << " Compare descriptors" << std::endl;
634
667
if (!compareDescriptors (trainDescriptors, trainDescriptors_reset)) {
635
668
throw vpException (vpException::fatalError, " Problem with vpKeyPoint::reset() and trainDescriptors !" );
636
669
}
637
670
638
- std::cout << " vpKeyPoint::reset() is ok with trainKeyPoints and "
639
- " trainDescriptors !"
640
- << std::endl;
671
+ std::cout << " vpKeyPoint::reset() is ok with trainKeyPoints and trainDescriptors !" << std::endl;
641
672
#endif // OpenCV != 4.5.4 on macOS
642
673
}
643
674
#endif
0 commit comments