Merged the trunk r8589:8653 - all changes related to build warnings
This commit is contained in:
@@ -53,12 +53,12 @@ using namespace std;
|
||||
//#define TOTAL_NO_PAIR_E "totalNoPairE"
|
||||
|
||||
#define DETECTOR_NAMES "detector_names"
|
||||
#define DETECTORS "detectors"
|
||||
#define DETECTORS "detectors"
|
||||
#define IMAGE_FILENAMES "image_filenames"
|
||||
#define VALIDATION "validation"
|
||||
#define FILENAME "fn"
|
||||
#define FILENAME "fn"
|
||||
|
||||
#define C_SCALE_CASCADE "scale_cascade"
|
||||
#define C_SCALE_CASCADE "scale_cascade"
|
||||
|
||||
class CV_DetectorTest : public cvtest::BaseTest
|
||||
{
|
||||
@@ -68,9 +68,9 @@ protected:
|
||||
virtual int prepareData( FileStorage& fs );
|
||||
virtual void run( int startFrom );
|
||||
virtual string& getValidationFilename();
|
||||
|
||||
virtual void readDetector( const FileNode& fn ) = 0;
|
||||
virtual void writeDetector( FileStorage& fs, int di ) = 0;
|
||||
|
||||
virtual void readDetector( const FileNode& fn ) = 0;
|
||||
virtual void writeDetector( FileStorage& fs, int di ) = 0;
|
||||
int runTestCase( int detectorIdx, vector<vector<Rect> >& objects );
|
||||
virtual int detectMultiScale( int di, const Mat& img, vector<Rect>& objects ) = 0;
|
||||
int validate( int detectorIdx, vector<vector<Rect> >& objects );
|
||||
@@ -118,10 +118,10 @@ int CV_DetectorTest::prepareData( FileStorage& _fs )
|
||||
FileNodeIterator it = fn[DETECTOR_NAMES].begin();
|
||||
for( ; it != fn[DETECTOR_NAMES].end(); )
|
||||
{
|
||||
string name;
|
||||
it >> name;
|
||||
detectorNames.push_back(name);
|
||||
readDetector(fn[DETECTORS][name]);
|
||||
string _name;
|
||||
it >> _name;
|
||||
detectorNames.push_back(_name);
|
||||
readDetector(fn[DETECTORS][_name]);
|
||||
}
|
||||
}
|
||||
test_case_count = (int)detectorNames.size();
|
||||
@@ -175,18 +175,18 @@ void CV_DetectorTest::run( int )
|
||||
}
|
||||
validationFS << "]"; // DETECTOR_NAMES
|
||||
|
||||
// write detectors
|
||||
validationFS << DETECTORS << "{";
|
||||
assert( detectorNames.size() == detectorFilenames.size() );
|
||||
nit = detectorNames.begin();
|
||||
for( int di = 0; di < detectorNames.size(), nit != detectorNames.end(); ++nit, di++ )
|
||||
{
|
||||
validationFS << *nit << "{";
|
||||
writeDetector( validationFS, di );
|
||||
validationFS << "}";
|
||||
}
|
||||
validationFS << "}";
|
||||
|
||||
// write detectors
|
||||
validationFS << DETECTORS << "{";
|
||||
assert( detectorNames.size() == detectorFilenames.size() );
|
||||
nit = detectorNames.begin();
|
||||
for( int di = 0; di < detectorNames.size(), nit != detectorNames.end(); ++nit, di++ )
|
||||
{
|
||||
validationFS << *nit << "{";
|
||||
writeDetector( validationFS, di );
|
||||
validationFS << "}";
|
||||
}
|
||||
validationFS << "}";
|
||||
|
||||
// write image filenames
|
||||
validationFS << IMAGE_FILENAMES << "[";
|
||||
vector<string>::const_iterator it = imageFilenames.begin();
|
||||
@@ -252,8 +252,8 @@ int CV_DetectorTest::runTestCase( int detectorIdx, vector<vector<Rect> >& object
|
||||
return cvtest::TS::FAIL_INVALID_TEST_DATA;
|
||||
}
|
||||
int code = detectMultiScale( detectorIdx, image, imgObjects );
|
||||
if( code != cvtest::TS::OK )
|
||||
return code;
|
||||
if( code != cvtest::TS::OK )
|
||||
return code;
|
||||
|
||||
objects.push_back( imgObjects );
|
||||
|
||||
@@ -300,17 +300,17 @@ int CV_DetectorTest::validate( int detectorIdx, vector<vector<Rect> >& objects )
|
||||
vector<Rect> valRects;
|
||||
if( node.node->data.seq != 0 )
|
||||
{
|
||||
for( FileNodeIterator it = node.begin(); it != node.end(); )
|
||||
for( FileNodeIterator it2 = node.begin(); it2 != node.end(); )
|
||||
{
|
||||
Rect r;
|
||||
it >> r.x >> r.y >> r.width >> r.height;
|
||||
it2 >> r.x >> r.y >> r.width >> r.height;
|
||||
valRects.push_back(r);
|
||||
}
|
||||
}
|
||||
totalValRectCount += (int)valRects.size();
|
||||
|
||||
|
||||
// compare rectangles
|
||||
vector<uchar> map(valRects.size(), 0);
|
||||
vector<uchar> map(valRects.size(), 0);
|
||||
for( vector<Rect>::const_iterator cr = it->begin();
|
||||
cr != it->end(); ++cr )
|
||||
{
|
||||
@@ -337,10 +337,10 @@ int CV_DetectorTest::validate( int detectorIdx, vector<vector<Rect> >& objects )
|
||||
{
|
||||
Rect vr = valRects[minIdx];
|
||||
if( map[minIdx] != 0 || (minDist > dist) || (abs(cr->width - vr.width) > wDiff) ||
|
||||
(abs(cr->height - vr.height) > hDiff) )
|
||||
(abs(cr->height - vr.height) > hDiff) )
|
||||
noPair++;
|
||||
else
|
||||
map[minIdx] = 1;
|
||||
else
|
||||
map[minIdx] = 1;
|
||||
}
|
||||
}
|
||||
noPair += (int)count_if( map.begin(), map.end(), isZero );
|
||||
@@ -371,10 +371,10 @@ class CV_CascadeDetectorTest : public CV_DetectorTest
|
||||
public:
|
||||
CV_CascadeDetectorTest();
|
||||
protected:
|
||||
virtual void readDetector( const FileNode& fn );
|
||||
virtual void writeDetector( FileStorage& fs, int di );
|
||||
virtual void readDetector( const FileNode& fn );
|
||||
virtual void writeDetector( FileStorage& fs, int di );
|
||||
virtual int detectMultiScale( int di, const Mat& img, vector<Rect>& objects );
|
||||
vector<int> flags;
|
||||
vector<int> flags;
|
||||
};
|
||||
|
||||
CV_CascadeDetectorTest::CV_CascadeDetectorTest()
|
||||
@@ -384,40 +384,40 @@ CV_CascadeDetectorTest::CV_CascadeDetectorTest()
|
||||
|
||||
void CV_CascadeDetectorTest::readDetector( const FileNode& fn )
|
||||
{
|
||||
string filename;
|
||||
int flag;
|
||||
fn[FILENAME] >> filename;
|
||||
detectorFilenames.push_back(filename);
|
||||
fn[C_SCALE_CASCADE] >> flag;
|
||||
if( flag )
|
||||
flags.push_back( 0 );
|
||||
else
|
||||
flags.push_back( CV_HAAR_SCALE_IMAGE );
|
||||
string filename;
|
||||
int flag;
|
||||
fn[FILENAME] >> filename;
|
||||
detectorFilenames.push_back(filename);
|
||||
fn[C_SCALE_CASCADE] >> flag;
|
||||
if( flag )
|
||||
flags.push_back( 0 );
|
||||
else
|
||||
flags.push_back( CV_HAAR_SCALE_IMAGE );
|
||||
}
|
||||
|
||||
void CV_CascadeDetectorTest::writeDetector( FileStorage& fs, int di )
|
||||
{
|
||||
int sc = flags[di] & CV_HAAR_SCALE_IMAGE ? 0 : 1;
|
||||
fs << FILENAME << detectorFilenames[di];
|
||||
fs << C_SCALE_CASCADE << sc;
|
||||
int sc = flags[di] & CV_HAAR_SCALE_IMAGE ? 0 : 1;
|
||||
fs << FILENAME << detectorFilenames[di];
|
||||
fs << C_SCALE_CASCADE << sc;
|
||||
}
|
||||
|
||||
int CV_CascadeDetectorTest::detectMultiScale( int di, const Mat& img,
|
||||
vector<Rect>& objects)
|
||||
{
|
||||
string dataPath = ts->get_data_path(), filename;
|
||||
filename = dataPath + detectorFilenames[di];
|
||||
string dataPath = ts->get_data_path(), filename;
|
||||
filename = dataPath + detectorFilenames[di];
|
||||
CascadeClassifier cascade( filename );
|
||||
if( cascade.empty() )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG, "cascade %s can not be opened");
|
||||
return cvtest::TS::FAIL_INVALID_TEST_DATA;
|
||||
}
|
||||
if( cascade.empty() )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG, "cascade %s can not be opened");
|
||||
return cvtest::TS::FAIL_INVALID_TEST_DATA;
|
||||
}
|
||||
Mat grayImg;
|
||||
cvtColor( img, grayImg, CV_BGR2GRAY );
|
||||
equalizeHist( grayImg, grayImg );
|
||||
cascade.detectMultiScale( grayImg, objects, 1.1, 3, flags[di] );
|
||||
return cvtest::TS::OK;
|
||||
return cvtest::TS::OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------- HOGDetectorTest -----------------------------------
|
||||
@@ -426,8 +426,8 @@ class CV_HOGDetectorTest : public CV_DetectorTest
|
||||
public:
|
||||
CV_HOGDetectorTest();
|
||||
protected:
|
||||
virtual void readDetector( const FileNode& fn );
|
||||
virtual void writeDetector( FileStorage& fs, int di );
|
||||
virtual void readDetector( const FileNode& fn );
|
||||
virtual void writeDetector( FileStorage& fs, int di );
|
||||
virtual int detectMultiScale( int di, const Mat& img, vector<Rect>& objects );
|
||||
};
|
||||
|
||||
@@ -438,15 +438,15 @@ CV_HOGDetectorTest::CV_HOGDetectorTest()
|
||||
|
||||
void CV_HOGDetectorTest::readDetector( const FileNode& fn )
|
||||
{
|
||||
string filename;
|
||||
if( fn[FILENAME].node->data.seq != 0 )
|
||||
fn[FILENAME] >> filename;
|
||||
detectorFilenames.push_back( filename);
|
||||
string filename;
|
||||
if( fn[FILENAME].node->data.seq != 0 )
|
||||
fn[FILENAME] >> filename;
|
||||
detectorFilenames.push_back( filename);
|
||||
}
|
||||
|
||||
void CV_HOGDetectorTest::writeDetector( FileStorage& fs, int di )
|
||||
{
|
||||
fs << FILENAME << detectorFilenames[di];
|
||||
fs << FILENAME << detectorFilenames[di];
|
||||
}
|
||||
|
||||
int CV_HOGDetectorTest::detectMultiScale( int di, const Mat& img,
|
||||
@@ -458,7 +458,7 @@ int CV_HOGDetectorTest::detectMultiScale( int di, const Mat& img,
|
||||
else
|
||||
assert(0);
|
||||
hog.detectMultiScale(img, objects);
|
||||
return cvtest::TS::OK;
|
||||
return cvtest::TS::OK;
|
||||
}
|
||||
|
||||
TEST(Objdetect_CascadeDetector, regression) { CV_CascadeDetectorTest test; test.safe_run(); }
|
||||
|
Reference in New Issue
Block a user