【发布时间】:2016-04-01 10:00:41
【问题描述】:
我正在尝试使用 HOG 分类器检测人和其他物体。我首先使用以下代码检测人:
capt >> frame_capture;
capt1 >> frame_capture1;
cv::cvtColor(frame_capture1,gray, CV_RGB2GRAY);
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
findContours(gray,contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
vector <Rect> listOfRectangles;
// detecting objects
listOfRectangles = drawBoundingBox(contours);
if(!frame_capture.empty()){
for (int i =0; i<listOfRectangles.size();++i)
{
//rectangle (frame_capture, listOfRectangles[i],Scalar(255,255,0),1,8,0); //! display detections
cv::Mat roi;
roi.create(frame_capture.size(),CV_8UC3);
cv::Mat image=imread("");
roi = image(listOfRectangles[i]);
cv::Mat window;
cv::resize(roi, window, cv::Size(64, 128));
hog.detect(window, foundLocations);
if (!foundLocations.empty())
{
cout << "person .." << endl;
}
}
//oVideoWriter.write(frame_capture);
imshow("video",frame_capture);
waitKey(25);
}
我收到了这个错误:
OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in Mat
【问题讨论】: