Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

line2Dup.h的transform的中心是否该用float型? #16

Closed
oUp2Uo opened this issue Mar 29, 2019 · 2 comments
Closed

line2Dup.h的transform的中心是否该用float型? #16

oUp2Uo opened this issue Mar 29, 2019 · 2 comments

Comments

@oUp2Uo
Copy link

oUp2Uo commented Mar 29, 2019

 static cv::Mat transform(cv::Mat src, float angle, float scale){
        cv::Mat dst;

        cv::Point center(src.cols/2, src.rows/2);
        cv::Mat rot_mat = cv::getRotationMatrix2D(center, angle, scale);
        cv::warpAffine(src, dst, rot_mat, src.size());

        return dst;
    }

这里边的center是否该用
cv::Point2f center((float)src.cols / 2, (float)src.rows / 2);

@oUp2Uo oUp2Uo changed the title line2Dup.h的transform的中心是否改用float型? line2Dup.h的transform的中心是否该用float型? Mar 29, 2019
@meiqua
Copy link
Owner

meiqua commented Mar 30, 2019

对,改成float最好。
不改其实也行,因为旋转不一定要绕着中心,随便绕哪个点,后面transform的时候这个点最终的位移公式都一样。选中心主要是怕旋转的时候图像转出去被截断了。

@oUp2Uo
Copy link
Author

oUp2Uo commented Apr 1, 2019

嗯,这样在template是奇数长宽的时候也ok了,本来会有问题

@oUp2Uo oUp2Uo closed this as completed Apr 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants