开发者

How to do non-perspective image warping in OpenCV?

开发者 https://www.devze.com 2023-02-11 13:04 出处:网络
I have an image where the user selects an arbitrary 4-cornered polygon. I want to 开发者_如何学运维stretch this polygon into the entire image.

I have an image where the user selects an arbitrary 4-cornered polygon.

I want to 开发者_如何学运维stretch this polygon into the entire image.

I've tried doing it with homography and cvWarpPerspective,

but the result was a Perspective transformation, which is not what I want.

Any ideas how to do this with OpenCV/EMGU ?

Thanks,

SW


What you're trying should work. Calculate the homography by making the 4 corners of the polygon correspond to (0,0) (0,height) (width,0) and (width,height).

Have a look at GetPerspectiveTransform


I think what you want is a reversal of perspective transform.

Here is what you must consider doing. Assume that you had the polygon at locations (x1,y1)....(x4,y4) originally on your screen (0,0) ....(w,h). Applying perspective transform using cvWarpPerspective/getPerspectiveTransform you would be able to get the original co-ordinates to the known co-ordinates. So you should basically multiply the known co-ordinates with the inverse of the perspective transform matrix (unless that is non-invertible, in which case you must add a delta term to the homogeneous -coordinate term )

0

精彩评论

暂无评论...
验证码 换一张
取 消