blitting with rotation and perspective warp

Started by raft, January 09, 2014, 09:23:21 AM

Previous topic - Next topic

raft

i want to blit an image with rotation and perspective warp, how can I do that?

OpenCv finds my template in camera image and it also gives me a 2d affine transform (3x3 matrix) to transform the borders of the template (it's a rectangle) to camera space. the white lines in the image reflects transformed template borders.

i want to blit an image to fit that distorted rectangle, how can I do that? is it possible to add such a blitting method to FrameBuffer? or what else can I do? going reverse and put a quad and calculate corner points of the quad based on fov and camera distance may also an option but seems complicated. i also want the result perspectively correct, i.e. there should be no discontinuity accross the diagonal line, i'm not sure quad solution will provide that.

any other suggestions?


EgonOlsen

You will never get a perspective correct result unless you know the depth of the corners in 3D (i.e. their distance from the camera). If you have these, you can simply take the points in 2D, use Interact2D to project them back into 3D and then use a vertex controller to make a quad with these coordinates. But it think that the problem is, that you don't have the depth...i'm not sure how to solve this. Do you have any 3d information or just 2d?

raft

indeed I have. OpenCV takes camera parameters (fov etc), object space 3d point coordinates and projection of that points onto camera as input and calculates 3d transform of object in camera space, both translation and rotation. pretty amazing :) so I know the rotation and translation of the template border in the image. I successfully placed a jPCT object onto that.

i've never tried but docs say, it can also apply the previously mentioned 2d transform to images. so I was hoping openGL can also do that and blitting is an easier solution to place planar things.

Thomas.

You can use overlay...? Are you using any library or can you provide sources?

raft

Quote from: Thomas. on January 09, 2014, 09:39:47 PM
You can use overlay...? Are you using any library or can you provide sources?
how? overlay does not have a rotation or perspective warp

EgonOlsen

Quote from: Thomas. on January 09, 2014, 09:39:47 PM
You can use overlay...?
You can rotate an overlay, but you can't tilt it. The only way is to use an actual 3d object. You won't get a perspective correct rendering otherwise.


raft

right, saw it after you said it has.

so there is no way to apply an affine transform to a quad with open gl except using 3d?

EgonOlsen

An affine transformation won't give you a perspective correct result. It would turn out like texture mapping on the Playstation 1.

raft