Detected faces are returned as a set of rectangles surrounding the faces. As the documentation says, the output of Vector of rectangles where each rectangle contains the detected object.
So, one rectangle consists of [ initial x, initial y, width, height ]
. So you can find its center ( x + width*0.5 , y + height*0.5 )
. This center is also for an ellipse.
If you want to draw rectangles, use the rectangle
function. See the documentation .
The arguments to the function will be as follows:
pt1 = ( x , y ) pt2 = ( x + width , y + height )
Change the line drawing ellipse to the following line:
rectangle(frame,Point (faces[i].x,faces[i].y),Point (faces[i].x+faces[i].width, faces[i].y+faces[i].height),Scalar(255,0,255),4,8,0);
It gives the result as follows:
source share