Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error when Cropping Human Image after detectMultiScale

Hi guys, I wanna crop detected human image using cv::Rect. This is my code:

int main(int argc, char *argv[])
{
 cv::Mat image = cv::imread("Man.jpg",1);
 cv::CascadeClassifier human;
 assert(human.load("hogcascade_pedestrians.xml"));


 std::vector<cv::Rect> rects;
 human.detectMultiScale(image, rects);   
 cv::Mat imgroi = image(rects);          //Error! Can't Convert Vector to Rect!

 cv::namedWindow("Original");
 cv::namedWindow("Cropped");
 cv::imshow("Original",image);
 cv::imshow("Cropped",imgroi);
 cv::waitKey(0);
 return 0;
}

I'll appreciate any help here. Thanks! :)