问题
could any one explain me logic behind this code??
pt1.x = cvRound(x0 + 1000*(-b));
pt1.y = cvRound(y0 + 1000*(a));
pt2.x = cvRound(x0 - 1000*(-b));
pt2.y = cvRound(y0 - 1000*(a));
回答1:
You have a point defined by x0, y0
. You're now creating two other point objects, one at (-b*1000, a*1000)
and one at (b*1000, -a*1000)
relative to the original point. Presumably the 1000
is to fix problems of scale, as the values a
and b
are on a different scale than the points x0, y0
.
回答2:
It looks like a
and b
are threshold values that are being used to move pt1
in one direction (inwards or outwards) and pt2
in the opposite direction.
Perhaps they are being used to increase/decrease the area of a rectangle for a bounds check?
来源:https://stackoverflow.com/questions/3205114/logic-behind-the-code