From 7a78559708776b28d33c2ff8a5d46a0699f748f2 Mon Sep 17 00:00:00 2001 From: Konstantin Matskevich Date: Fri, 6 Dec 2013 12:12:24 +0400 Subject: [PATCH] some fixes --- samples/ocl/facedetect.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/samples/ocl/facedetect.cpp b/samples/ocl/facedetect.cpp index 0f452b945f..78a0775151 100644 --- a/samples/ocl/facedetect.cpp +++ b/samples/ocl/facedetect.cpp @@ -74,7 +74,7 @@ static int facedetect_one_thread(bool useCPU, double scale ) if( !cascade.load( cascadeName ) || !cpu_cascade.load(cascadeName) ) { - cout << "ERROR: Could not load classifier cascade" << endl; + cout << "ERROR: Could not load classifier cascade: " << cascadeName << endl; return EXIT_FAILURE; } @@ -170,7 +170,12 @@ static int facedetect_one_thread(bool useCPU, double scale ) static void detectFaces(std::string fileName) { ocl::OclCascadeClassifier cascade; - cascade.load(cascadeName); + if(!cascade.load(cascadeName)) + { + std::cout << "ERROR: Could not load classifier cascade: " << cascadeName << std::endl; + return; + } + Mat img = imread(fileName, CV_LOAD_IMAGE_COLOR); if (img.empty()) { @@ -187,8 +192,16 @@ static void detectFaces(std::string fileName) for(unsigned int i = 0; i 0 && outputName[n-1] != '.') + n--; + if( n == 0 ) + { + std::cout << "Invalid output file name: " << outputName << std::endl; + return; + } + imwrite(outputName.substr(0,n-1) + "_" + std::to_string(_threadid) + outputName.substr(n-1, outputName.length()-1), img); } static void facedetect_multithreading(int nthreads)