Coordinate transformation in OpenCV

自作多情 提交于 2019-12-11 19:49:21

问题


I have a polyline figure, given as an array of relative x and y point coordinates (0.0 to 1.0).

I have to draw the figure with random position, scale and rotation angle.

How can I do it in the best way?


回答1:


You could use a simple transformation with RT matrix.

Let X = (x y 1)^t be coordinates of one point of your figure. Let R be a 2x2 rotation matrix, and T be 2x1 translation vector of the transformation You plan to make. RT matrix A will have the form of A = [R T;0 0 1]. To get transformed coordinates of point X, You need to do this simple calculation AX = X', where X' are the new coordinates. Now, to get the whole figure transformed, instead of using a single column, You use a matrix where each column has x coordinate in first row, y in the second and 1 in the third row.

Of course You can try to use functions provided by OpenCV, shown in this tutorial, or ones intended for vectors of points instead of whole images, but the way above makes You actually understand what are You doing ;)



来源:https://stackoverflow.com/questions/23616768/coordinate-transformation-in-opencv

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