Nitesh Nitesh - 3 months ago 27
iOS Question

No matching function for call to 'ellipse'

I'm using OpenCV and detecting user's body. But I'm getting the error:


No matching function for call to 'ellipse'


That function is present inside my framework still it's showing the error:

// Body Detection

std::vector<cv::Rect> body;
cascade.detectMultiScale(mat, body, 1.1, 2, 18|9, cv::Size(3,7));

std::vector<cv::Rect>::const_iterator rs = body.begin();

for(int j = 0; j<body.size(); j++){
cv::Point center(body[j].x + body[j].width * 0.5, body[j].y+ + body[j].height * 0.5);
cv::ellipse(mat, center, Size(body[j].width * 0.5 + body[j].height * 0.5), 0, 0, 360, cv::Scalar(255, 0 , 255), 4, 8, 0);

}


Error

enter image description here

Answer

The error is in this line:

cv::ellipse(mat, center, Size(body[j].width * 0.5 + body[j].height * 0.5), 0, 0, 360, cv::Scalar(255, 0 , 255), 4, 8, 0);

cv::ellipse expects a cv::Size object, while you're passing a different Size object. Also the constructor of cv::Size expects two parameters width and height. You probably are missing a comma to divide the arguments.

So the code should look like:

cv::ellipse(mat, center, cv::Size(body[j].width * 0.5, body[j].height * 0.5), 0, 0, 360, cv::Scalar(255, 0 , 255), 4, 8, 0);