使用Ubuntu 16.04和OpenCV 3.2。注意:最终我会将此代码转移到Windows系统,所以如果问题是特定于ubuntu,请告诉我。我正在尝试使用OpenCV peopledetection示例,我收到一个断言错误。我已经将代码修剪成比给定样本更简单的东西。使用的代码如下所示:
int main()
{
VideoCapture cam(0);
cam.set(CV_CAP_PROP_FRAME_WIDTH,320);
cam.set(CV_CAP_PROP_FRAME_HEIGHT,240);
Mat img;
HOGDescriptor hog;
hog.setSVMDetector(HOGDescriptor::getPeopleDetector());
namedWindow("video capture",CV_WINDOW_AUTOSIZE);
vector<Rect> found,found_filtered;
while(true)
{
cam >> img;
cout << "ep" <<endl;
hog.detectMultiScale(img, found, 0, Size(8,8), Size(32,32), 1.05, 2);
size_t i, j;
for (i=0; i<found.size(); i++)
{
Rect r = found[i];
for (j=0; j<found.size(); j++)
if (j!=i && (r & found[j])==r)
break;
if (j==found.size())
found_filtered.push_back(r);
}
for (i=0; i<found_filtered.size(); i++)
{
Rect r = found_filtered[i];
r.x += cvRound(r.width*0.1);
r.width = cvRound(r.width*0.8);
r.y += cvRound(r.height*0.06);
r.height = cvRound(r.height*0.9);
rectangle(img, r.tl(), r.br(), cv::Scalar(0,255,0), 2);
}
imshow("video capture", img);
if (waitKey(20) == 27)
break;
}
断言错误如下所示:
OpenCV错误:断言失败(clEnqueueWriteBuffer(q,(cl_mem)u-&gt; handle,CL_TRUE,dstrawofs,total,alignedPtr.getAlignedPtr(),0,0,0)&gt; = 0)in upload,file / home / alex / Desktop / OpenCV_tutorial / OpenCV / opencv-3.2.0 / modules / core / src / ocl.cpp,line 5129 在抛出'cv :: Exception'的实例后终止调用 what():/Desktop/OpenCV_tutorial/OpenCV/opencv-3.2.0/modules/core/src/ocl.cpp:5129:error:( - 1515)clEnqueueWriteBuffer(q,(cl_mem)u-&gt; handle,CL_TRUE,函数上传中的dstrawofs,total,alignedPtr.getAlignedPtr(),0,0,0)&gt; = 0
我相信我已经确定了在这一行抛出的异常:
hog.setSVMDetector(HOGDescriptor :: getPeopleDetector());
对于一般的opencv我是一个新手,但我很感激帮助解决这个错误。我可以采取哪些步骤来解决这个问题?