logic behind the code

☆樱花仙子☆ 提交于 2019-12-14 03:21:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!