paddu
paddu

Reputation: 1

logic behind the code

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));

Upvotes: 0

Views: 413

Answers (2)

JSBձոգչ
JSBձոգչ

Reputation: 41378

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.

Upvotes: 2

Justin Ethier
Justin Ethier

Reputation: 134177

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?

Upvotes: 1

Related Questions