Merge remote-tracking branch 'origin/2.4' into merge-2.4
Conflicts: CMakeLists.txt modules/calib3d/src/calibration.cpp modules/ocl/src/cl_programcache.cpp modules/ocl/src/filtering.cpp modules/ocl/src/imgproc.cpp samples/ocl/adaptive_bilateral_filter.cpp samples/ocl/bgfg_segm.cpp samples/ocl/clahe.cpp samples/ocl/facedetect.cpp samples/ocl/pyrlk_optical_flow.cpp samples/ocl/squares.cpp samples/ocl/surf_matcher.cpp samples/ocl/tvl1_optical_flow.cpp
This commit is contained in:
@@ -32,6 +32,7 @@ static void workBegin()
|
||||
{
|
||||
work_begin = getTickCount();
|
||||
}
|
||||
|
||||
static void workEnd()
|
||||
{
|
||||
work_end += (getTickCount() - work_begin);
|
||||
@@ -42,16 +43,17 @@ static double getTime()
|
||||
return work_end /((double)cvGetTickFrequency() * 1000.);
|
||||
}
|
||||
|
||||
void detect( Mat& img, vector<Rect>& faces,
|
||||
|
||||
static void detect( Mat& img, vector<Rect>& faces,
|
||||
ocl::OclCascadeClassifier& cascade,
|
||||
double scale, bool calTime);
|
||||
|
||||
|
||||
void detectCPU( Mat& img, vector<Rect>& faces,
|
||||
static void detectCPU( Mat& img, vector<Rect>& faces,
|
||||
CascadeClassifier& cascade,
|
||||
double scale, bool calTime);
|
||||
|
||||
void Draw(Mat& img, vector<Rect>& faces, double scale);
|
||||
static void Draw(Mat& img, vector<Rect>& faces, double scale);
|
||||
|
||||
|
||||
// This function test if gpu_rst matches cpu_rst.
|
||||
@@ -59,7 +61,6 @@ void Draw(Mat& img, vector<Rect>& faces, double scale);
|
||||
// Else if will return (total diff of each cpu and gpu rects covered pixels)/(total cpu rects covered pixels)
|
||||
double checkRectSimilarity(Size sz, vector<Rect>& cpu_rst, vector<Rect>& gpu_rst);
|
||||
|
||||
|
||||
int main( int argc, const char** argv )
|
||||
{
|
||||
const char* keys =
|
||||
@@ -75,10 +76,12 @@ int main( int argc, const char** argv )
|
||||
CommandLineParser cmd(argc, argv, keys);
|
||||
if (cmd.get<bool>("help"))
|
||||
{
|
||||
cout << "Usage : facedetect [options]" << endl;
|
||||
cout << "Available options:" << endl;
|
||||
cmd.printMessage();
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
CvCapture* capture = 0;
|
||||
Mat frame, frameCopy, image;
|
||||
|
||||
@@ -92,8 +95,8 @@ int main( int argc, const char** argv )
|
||||
|
||||
if( !cascade.load( cascadeName ) || !cpu_cascade.load(cascadeName) )
|
||||
{
|
||||
cerr << "ERROR: Could not load classifier cascade" << endl;
|
||||
return -1;
|
||||
cout << "ERROR: Could not load classifier cascade" << endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if( inputName.empty() )
|
||||
@@ -102,25 +105,17 @@ int main( int argc, const char** argv )
|
||||
if(!capture)
|
||||
cout << "Capture from CAM 0 didn't work" << endl;
|
||||
}
|
||||
else if( inputName.size() )
|
||||
else
|
||||
{
|
||||
image = imread( inputName, 1 );
|
||||
image = imread( inputName, CV_LOAD_IMAGE_COLOR );
|
||||
if( image.empty() )
|
||||
{
|
||||
capture = cvCaptureFromAVI( inputName.c_str() );
|
||||
if(!capture)
|
||||
cout << "Capture from AVI didn't work" << endl;
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
image = imread( "lena.jpg", 1 );
|
||||
if(image.empty())
|
||||
cout << "Couldn't read lena.jpg" << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
cvNamedWindow( "result", 1 );
|
||||
if( capture )
|
||||
@@ -137,24 +132,16 @@ int main( int argc, const char** argv )
|
||||
frame.copyTo( frameCopy );
|
||||
else
|
||||
flip( frame, frameCopy, 0 );
|
||||
|
||||
if(useCPU)
|
||||
{
|
||||
detectCPU(frameCopy, faces, cpu_cascade, scale, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
detect(frameCopy, faces, cascade, scale, false);
|
||||
}
|
||||
|
||||
Draw(frameCopy, faces, scale);
|
||||
if( waitKey( 10 ) >= 0 )
|
||||
goto _cleanup_;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
waitKey(0);
|
||||
|
||||
|
||||
_cleanup_:
|
||||
cvReleaseCapture( &capture );
|
||||
}
|
||||
else
|
||||
@@ -167,9 +154,7 @@ _cleanup_:
|
||||
{
|
||||
cout << "loop" << i << endl;
|
||||
if(useCPU)
|
||||
{
|
||||
detectCPU(image, faces, cpu_cascade, scale, i==0?false:true);
|
||||
}
|
||||
else
|
||||
{
|
||||
detect(image, faces, cascade, scale, i==0?false:true);
|
||||
|
Reference in New Issue
Block a user