From 894724eaf0641a2b511797dbc28cc5a97c486fe0 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Fri, 6 Dec 2013 14:49:36 +0400 Subject: [PATCH] minor improvements --- samples/ocl/facedetect.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/samples/ocl/facedetect.cpp b/samples/ocl/facedetect.cpp index 78a0775..fbb08cb 100644 --- a/samples/ocl/facedetect.cpp +++ b/samples/ocl/facedetect.cpp @@ -190,18 +190,21 @@ static void detectFaces(std::string fileName) cascade.detectMultiScale(d_img, oclfaces, 1.1, 3, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30), Size(0, 0)); for(unsigned int i = 0; i 0 && outputName[n-1] != '.') - n--; - if( n == 0 ) + std::string::size_type pos = outputName.rfind('.'); + std::string outputNameTid = outputName + '-' + std::to_string(_threadid); + if(pos == std::string::npos) { 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); + else + { + outputNameTid = outputName.substr(0, pos) + "_" + std::to_string(_threadid) + outputName.substr(pos); + imwrite(outputNameTid, img); + } + imshow(outputNameTid, img); + waitKey(0); } static void facedetect_multithreading(int nthreads) @@ -212,8 +215,6 @@ static void facedetect_multithreading(int nthreads) threads.push_back(std::thread(detectFaces, inputName)); for(int i = 0; i