Barrel/pincushion distortion

Hi There,

I have a set of primitives (segments) that I would like to overlay with distorted (barrel/pincushion) video feed. I have a good model for the distortion of the primitive (real x,y to pixel x,y) and I would like to apply that distortion to the primitives.

Is there a mapping/perspective/transformation function that I can use to simulate the camera distortion? Ideally it would use antialiasing.

Thanks in advance,

Javier

huh?

Something like that ?
http://opencv.willowgarage.com/documentation/camera_calibration_and_3d_reconstruction.html

The easiest way is painting a quad with the texture, and apply your distortion calculation within the fragment shader. Because barrel distortion is not linear (it usually has spherical and tangential factors), finding a projection matrix is impossible (as far I know)

Another option, if you dont have shaders available, is to generate a more or less dense mesh, distort the vertices, and then paint the image over it, without modifying the uv’s