minor improvements
This commit is contained in:
parent
7a78559708
commit
894724eaf0
@ -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));
|
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<oclfaces.size(); i++)
|
for(unsigned int i = 0; i<oclfaces.size(); i++)
|
||||||
rectangle(img, Point(oclfaces[i].x, oclfaces[i].y), Point(oclfaces[i].x + oclfaces[i].width, oclfaces[i].y + oclfaces[i].height), Scalar( 0, 255, 255 ), 3);
|
rectangle(img, Point(oclfaces[i].x, oclfaces[i].y), Point(oclfaces[i].x + oclfaces[i].width, oclfaces[i].y + oclfaces[i].height), colors[i%8], 3);
|
||||||
|
|
||||||
int n = (int)outputName.length();
|
std::string::size_type pos = outputName.rfind('.');
|
||||||
while( n > 0 && outputName[n-1] != '.')
|
std::string outputNameTid = outputName + '-' + std::to_string(_threadid);
|
||||||
n--;
|
if(pos == std::string::npos)
|
||||||
if( n == 0 )
|
|
||||||
{
|
{
|
||||||
std::cout << "Invalid output file name: " << outputName << std::endl;
|
std::cout << "Invalid output file name: " << outputName << std::endl;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
imwrite(outputName.substr(0,n-1) + "_" + std::to_string(_threadid) + outputName.substr(n-1, outputName.length()-1), img);
|
{
|
||||||
|
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)
|
static void facedetect_multithreading(int nthreads)
|
||||||
@ -212,8 +215,6 @@ static void facedetect_multithreading(int nthreads)
|
|||||||
threads.push_back(std::thread(detectFaces, inputName));
|
threads.push_back(std::thread(detectFaces, inputName));
|
||||||
for(int i = 0; i<thread_number; i++)
|
for(int i = 0; i<thread_number; i++)
|
||||||
threads[i].join();
|
threads[i].join();
|
||||||
for(int i = 0; i<thread_number; i++)
|
|
||||||
threads[i].~thread();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user