Created
June 1, 2013 08:13
-
-
Save masazdream/5689649 to your computer and use it in GitHub Desktop.
ホモグラフィー(透視変換)を行う
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ホモグラフィー(透視変換)を行う | |
* | |
* pts1 元の4点 | |
* pts2 変換後の4点 | |
*/ | |
Mat cv_perspective(InputArray src, Point2f pts1[], Point2f pts2[]) { | |
// ホモグラフィ行列取得。サーバアプリ内でも求めているので3×3のMatを自作すれば不要。 | |
Mat perspective_matrix = getPerspectiveTransform(pts1, pts2); | |
Mat dst_img; | |
warpPerspective(src, dst_img, perspective_matrix, src.size(), INTER_LINEAR); | |
// debug | |
namedWindow("Display Image perspective src", CV_WINDOW_AUTOSIZE); | |
imshow("Display Image perspective src", src); | |
namedWindow("Display Image perspective dst", CV_WINDOW_AUTOSIZE); | |
imshow("Display Image perspective dst", dst_img); | |
return dst_img; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment