Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Barrel/pincushion distortion

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    1

    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

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: Barrel/pincushion distortion

    huh?
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  3. #3
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Barrel/pincushion distortion


  4. #4
    Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Spain
    Posts
    269

    Re: Barrel/pincushion distortion

    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
    "I don't know... with a casual fly"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •