Use hog.detectMultiScale in multiple threads?
When I do pedestrian detection width Hog + SVM in OpenCV ,I try to using it in two thread to improve the detect speed.But I got OpenCV error: Assertion failed<s >=0> in unknown function,file ..\..\..\opencv\modules\core\src\matrix.cpp,line 116
My code:
DWORD WINAPI DetectFrame1(LPVOID lpPrarmeter){
HOGDescriptor hog1;
hog1.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());
while(true){
WaitForSingleObject(g_hEvent1,INFINITE);
int temp;
hog1.detectMultiScale(detImg1, found1, 0, cv::Size(8,8), cv::Size(0,0), 1.08, 2);
//cout<<"得到一帧near :"<<frame<<endl;
//temp=frame; // 标志当前处理帧 [9/26/2014 pan]
if(!detImg1.empty()){
imshow("det1",detImg1);
}
waitKey(10);
cout<<"1——检测到行人:"<<found1.size()<<endl;
SetEvent(g_hEvent1);
}
return 0;
}
DWORD WINAPI DetectFrame2(LPVOID lpPrarmeter){
HOGDescriptor hog2;
hog2.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector()); // 该函数不能并发 [9/26/2014 pan]
while(true){
WaitForSingleObject(g_hEvent2,INFINITE);
int temp;
//cout<<"得到一帧far :"<<frame<<endl;
//temp=frame; // 标志当前处理帧 [9/26/2014 pan]
hog2.detectMultiScale(detImg2, found2, 0, cv::Size(8,8), cv::Size(0,0), 1.08, 2);
if(!detImg2.empty()){
imshow("det2",detImg2);
}
waitKey(10);
cout<<"2——检测到行人:"<<found2.size()<<endl;
SetEvent(g_hEvent2); // 变为有信号状态 [9/26/2014 pan]
}
return 0;
}
Can anyone help me ,thanks.
if(!detImg1.empty()){ // this should go before hog1.detectMultiScale
thanks,i made a mistake