1793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*M/////////////////////////////////////////////////////////////////////////////////////// 2793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 3793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 4793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 5793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// By downloading, copying, installing or using the software you agree to this license. 6793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// If you do not agree to this license, do not download, install, 7793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// copy or use the software. 8793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 9793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 10793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// Intel License Agreement 11793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// For Open Source Computer Vision Library 12793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 13793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// Copyright (C) 2000, Intel Corporation, all rights reserved. 14793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// Third party copyrights are property of their respective owners. 15793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 16793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// Redistribution and use in source and binary forms, with or without modification, 17793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// are permitted provided that the following conditions are met: 18793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 19793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// * Redistribution's of source code must retain the above copyright notice, 20793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// this list of conditions and the following disclaimer. 21793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 22793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// * Redistribution's in binary form must reproduce the above copyright notice, 23793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// this list of conditions and the following disclaimer in the documentation 24793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// and/or other materials provided with the distribution. 25793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 26793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// * The name of Intel Corporation may not be used to endorse or promote products 27793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// derived from this software without specific prior written permission. 28793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 29793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// This software is provided by the copyright holders and contributors "as is" and 30793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// any express or implied warranties, including, but not limited to, the implied 31793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// warranties of merchantability and fitness for a particular purpose are disclaimed. 32793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// In no event shall the Intel Corporation or contributors be liable for any direct, 33793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// indirect, incidental, special, exemplary, or consequential damages 34793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// (including, but not limited to, procurement of substitute goods or services; 35793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// loss of use, data, or profits; or business interruption) however caused 36793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// and on any theory of liability, whether in contract, strict liability, 37793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// or tort (including negligence or otherwise) arising in any way out of 38793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// the use of this software, even if advised of the possibility of such damage. 39793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler// 40793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler//M*/ 41793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 42793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#include "test_precomp.hpp" 43793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#include "opencv2/highgui.hpp" 44793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 45793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerusing namespace std; 46793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerusing namespace cv; 47793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 48793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerconst string FEATURES2D_DIR = "features2d"; 49793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerconst string IMAGE_FILENAME = "tsukuba.png"; 50793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerconst string DETECTOR_DIR = FEATURES2D_DIR + "/feature_detectors"; 51793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 52793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/****************************************************************************************\ 53793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler* Regression tests for feature detectors comparing keypoints. * 54793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler\****************************************************************************************/ 55793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 56793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerclass CV_FeatureDetectorTest : public cvtest::BaseTest 57793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 58793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerpublic: 59793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler CV_FeatureDetectorTest( const string& _name, const Ptr<FeatureDetector>& _fdetector ) : 60793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler name(_name), fdetector(_fdetector) {} 61793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 62793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerprotected: 63793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler bool isSimilarKeypoints( const KeyPoint& p1, const KeyPoint& p2 ); 64793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler void compareKeypointSets( const vector<KeyPoint>& validKeypoints, const vector<KeyPoint>& calcKeypoints ); 65793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 66793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler void emptyDataTest(); 67793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler void regressionTest(); // TODO test of detect() with mask 68793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 69793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler virtual void run( int ); 70793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 71793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler string name; 72793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler Ptr<FeatureDetector> fdetector; 73793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler}; 74793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 75793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslervoid CV_FeatureDetectorTest::emptyDataTest() 76793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 77793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler // One image. 78793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler Mat image; 79793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler vector<KeyPoint> keypoints; 80793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler try 81793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 82793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler fdetector->detect( image, keypoints ); 83793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 84793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler catch(...) 85793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 86793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->printf( cvtest::TS::LOG, "detect() on empty image must not generate exception (1).\n" ); 87793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT ); 88793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 89793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 90793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler if( !keypoints.empty() ) 91793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 92793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->printf( cvtest::TS::LOG, "detect() on empty image must return empty keypoints vector (1).\n" ); 93793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT ); 94793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler return; 95793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 96793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 97793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler // Several images. 98793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler vector<Mat> images; 99793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler vector<vector<KeyPoint> > keypointCollection; 100793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler try 101793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 102793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler fdetector->detect( images, keypointCollection ); 103793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 104793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler catch(...) 105793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 106793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->printf( cvtest::TS::LOG, "detect() on empty image vector must not generate exception (2).\n" ); 107793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT ); 108793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 109793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 110793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 111793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerbool CV_FeatureDetectorTest::isSimilarKeypoints( const KeyPoint& p1, const KeyPoint& p2 ) 112793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 113793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const float maxPtDif = 1.f; 114793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const float maxSizeDif = 1.f; 115793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const float maxAngleDif = 2.f; 116793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const float maxResponseDif = 0.1f; 117793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 118793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler float dist = (float)norm( p1.pt - p2.pt ); 119793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler return (dist < maxPtDif && 120793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler fabs(p1.size - p2.size) < maxSizeDif && 121793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler abs(p1.angle - p2.angle) < maxAngleDif && 122793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler abs(p1.response - p2.response) < maxResponseDif && 123793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler p1.octave == p2.octave && 124793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler p1.class_id == p2.class_id ); 125793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 126793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 127793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslervoid CV_FeatureDetectorTest::compareKeypointSets( const vector<KeyPoint>& validKeypoints, const vector<KeyPoint>& calcKeypoints ) 128793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 129793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler const float maxCountRatioDif = 0.01f; 130793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 131793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler // Compare counts of validation and calculated keypoints. 132793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler float countRatio = (float)validKeypoints.size() / (float)calcKeypoints.size(); 133793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler if( countRatio < 1 - maxCountRatioDif || countRatio > 1.f + maxCountRatioDif ) 134793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 135793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->printf( cvtest::TS::LOG, "Bad keypoints count ratio (validCount = %d, calcCount = %d).\n", 136793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler validKeypoints.size(), calcKeypoints.size() ); 137793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT ); 138793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler return; 139793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 140793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 141793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler int progress = 0, progressCount = (int)(validKeypoints.size() * calcKeypoints.size()); 142793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler int badPointCount = 0, commonPointCount = max((int)validKeypoints.size(), (int)calcKeypoints.size()); 143793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler for( size_t v = 0; v < validKeypoints.size(); v++ ) 144793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 145793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler int nearestIdx = -1; 146793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler float minDist = std::numeric_limits<float>::max(); 147793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 148793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler for( size_t c = 0; c < calcKeypoints.size(); c++ ) 149793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 150793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler progress = update_progress( progress, (int)(v*calcKeypoints.size() + c), progressCount, 0 ); 151793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler float curDist = (float)norm( calcKeypoints[c].pt - validKeypoints[v].pt ); 152793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler if( curDist < minDist ) 153793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 154793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler minDist = curDist; 155793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler nearestIdx = (int)c; 156793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 157793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 158793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 159793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler assert( minDist >= 0 ); 160793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler if( !isSimilarKeypoints( validKeypoints[v], calcKeypoints[nearestIdx] ) ) 161793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler badPointCount++; 162793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 163793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->printf( cvtest::TS::LOG, "badPointCount = %d; validPointCount = %d; calcPointCount = %d\n", 164793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler badPointCount, validKeypoints.size(), calcKeypoints.size() ); 165793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler if( badPointCount > 0.9 * commonPointCount ) 166793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 167793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->printf( cvtest::TS::LOG, " - Bad accuracy!\n" ); 168793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY ); 169793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler return; 170793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 171793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->printf( cvtest::TS::LOG, " - OK\n" ); 172793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 173793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 174793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslervoid CV_FeatureDetectorTest::regressionTest() 175793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 176793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler assert( !fdetector.empty() ); 177793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler string imgFilename = string(ts->get_data_path()) + FEATURES2D_DIR + "/" + IMAGE_FILENAME; 178793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler string resFilename = string(ts->get_data_path()) + DETECTOR_DIR + "/" + string(name) + ".xml.gz"; 179793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 180793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler // Read the test image. 181793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler Mat image = imread( imgFilename ); 182793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler if( image.empty() ) 183793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 184793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->printf( cvtest::TS::LOG, "Image %s can not be read.\n", imgFilename.c_str() ); 185793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA ); 186793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler return; 187793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 188793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 189793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler FileStorage fs( resFilename, FileStorage::READ ); 190793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 191793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler // Compute keypoints. 192793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler vector<KeyPoint> calcKeypoints; 193793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler fdetector->detect( image, calcKeypoints ); 194793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 195793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler if( fs.isOpened() ) // Compare computed and valid keypoints. 196793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 197793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler // TODO compare saved feature detector params with current ones 198793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 199793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler // Read validation keypoints set. 200793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler vector<KeyPoint> validKeypoints; 201793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler read( fs["keypoints"], validKeypoints ); 202793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler if( validKeypoints.empty() ) 203793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 204793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->printf( cvtest::TS::LOG, "Keypoints can not be read.\n" ); 205793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA ); 206793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler return; 207793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 208793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 209793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler compareKeypointSets( validKeypoints, calcKeypoints ); 210793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 211793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler else // Write detector parameters and computed keypoints as validation data. 212793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 213793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler fs.open( resFilename, FileStorage::WRITE ); 214793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler if( !fs.isOpened() ) 215793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 216793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->printf( cvtest::TS::LOG, "File %s can not be opened to write.\n", resFilename.c_str() ); 217793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA ); 218793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler return; 219793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 220793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler else 221793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 222793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler fs << "detector_params" << "{"; 223793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler fdetector->write( fs ); 224793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler fs << "}"; 225793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 226793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler write( fs, "keypoints", calcKeypoints ); 227793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 228793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 229793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 230793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 231793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslervoid CV_FeatureDetectorTest::run( int /*start_from*/ ) 232793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 233793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler if( !fdetector ) 234793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler { 235793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->printf( cvtest::TS::LOG, "Feature detector is empty.\n" ); 236793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA ); 237793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler return; 238793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler } 239793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 240793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler emptyDataTest(); 241793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler regressionTest(); 242793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 243793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ts->set_failed_test_info( cvtest::TS::OK ); 244793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 245793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 246793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/****************************************************************************************\ 247793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler* Tests registrations * 248793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler\****************************************************************************************/ 249793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 250793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerTEST( Features2d_Detector_BRISK, regression ) 251793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 252793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler CV_FeatureDetectorTest test( "detector-brisk", BRISK::create() ); 253793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler test.safe_run(); 254793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 255793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 256793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerTEST( Features2d_Detector_FAST, regression ) 257793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 258793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler CV_FeatureDetectorTest test( "detector-fast", FastFeatureDetector::create() ); 259793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler test.safe_run(); 260793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 261793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 262793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerTEST( Features2d_Detector_AGAST, regression ) 263793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 264793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler CV_FeatureDetectorTest test( "detector-agast", AgastFeatureDetector::create() ); 265793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler test.safe_run(); 266793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 267793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 268793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerTEST( Features2d_Detector_GFTT, regression ) 269793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 270793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler CV_FeatureDetectorTest test( "detector-gftt", GFTTDetector::create() ); 271793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler test.safe_run(); 272793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 273793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 274793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerTEST( Features2d_Detector_Harris, regression ) 275793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 276793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler Ptr<GFTTDetector> gftt = GFTTDetector::create(); 277793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler gftt->setHarrisDetector(true); 278793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler CV_FeatureDetectorTest test( "detector-harris", gftt); 279793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler test.safe_run(); 280793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 281793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 282793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerTEST( Features2d_Detector_MSER, DISABLED_regression ) 283793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 284793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler CV_FeatureDetectorTest test( "detector-mser", MSER::create() ); 285793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler test.safe_run(); 286793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 287793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 288793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerTEST( Features2d_Detector_ORB, regression ) 289793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 290793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler CV_FeatureDetectorTest test( "detector-orb", ORB::create() ); 291793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler test.safe_run(); 292793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 293793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 294793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerTEST( Features2d_Detector_KAZE, regression ) 295793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 296793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler CV_FeatureDetectorTest test( "detector-kaze", KAZE::create() ); 297793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler test.safe_run(); 298793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 299793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler 300793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerTEST( Features2d_Detector_AKAZE, regression ) 301793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{ 302793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler CV_FeatureDetectorTest test( "detector-akaze", AKAZE::create() ); 303793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler test.safe_run(); 304793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} 305