convert an opencv affine matrix to CGAffineTransform

雨燕双飞 提交于 2019-12-04 20:23:04

Your problem is that opencv is row major and CGAffineTransform is column major you want

t.a = T.at<float>(0,0);
t.b = T.at<float>(1,0);
t.c = T.at<float>(0,1);
t.d = T.at<float>(1,1);

you can tell because in the documentation CGAffineTransform takes the form

[a  b  0
 c  d  0
 tx ty 1]

note that tx and ty are in the bottom row. In standard row major matrices the translation components go in the rightmost column

[a c tx
 b d ty
 0 0 1]

If the problem persists after making this change (which your question suggests you have already tried) then you need to post more information. As you suggest the problem could be in the origin of your coordinate system but without any information about your origin nobody will be able to help you.

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