1 | initial version |
(rect[0], rect[1]) yes those are exactly upper left and,.. , (rect[2], rect[3]) are the lower left corners..
you can just do the following
xFaceCenter=(rect[2]-rect[0])/2
yFaceCenter=(rect[3]-rect[1])/2
and now you have the height and width of the image frame lets say h,w
then you can easily use
dy=(h/2)-yFaceCenter
dx=(w/2)-xFaceCenter
So you now just have to make these dy
and dx
values to be zero by changing the horizontal and vertical servo angle accordingly