I'm looking for an algorithm for 2D perspective transform.
I need to "stretch" a quad to a rect and I need a matrix that converts the coordinates.
I've found some code in GIMP, but I can't get it work.
Do you know any source or documentation on the web?
Thank you!
2d perspective transform
Started by lordsme, Sep 15 2008 03:19 PM
6 replies to this topic
#1
Posted 15 September 2008 - 03:19 PM
#2
Posted 15 September 2008 - 06:42 PM
Yes, I've done that.. It's not that difficult but you don't find many sources or information how to do it on the net.
I'll write and post a source that does the de-stretching (e.g. from quad to rectangle) in OpenGL to show it later..
Nils
I'll write and post a source that does the de-stretching (e.g. from quad to rectangle) in OpenGL to show it later..
Nils
My music: http://myspace.com/planetarchh <-- my music
My stuff: torus.untergrund.net <-- some diy electronic stuff and more.
My stuff: torus.untergrund.net <-- some diy electronic stuff and more.
#3
Posted 15 September 2008 - 08:17 PM
Sounds like a scale matrix.. If you really mean a rect that is.
#4
Posted 15 September 2008 - 09:18 PM
No, going from an arbitrary convex quad to a rectangle is not a simple scaling.
reedbeta.com - developer blog, OpenGL demos, and other projects
#5
Posted 15 September 2008 - 09:55 PM
You need a 3*3 projective matrix. I'm not really into the mood to write code anymore, but I've looked for the relevant paper:
http://torus.untergr...age_warping.pdf
You find a simple implementation of the math in the OpenVG reference implementation. The function is called vguComputeWarpQuadToSquare
The code can be downloaded from the khronos.org site somewhere on the OpenVG page.
Cheers,
Nils
http://torus.untergr...age_warping.pdf
You find a simple implementation of the math in the OpenVG reference implementation. The function is called vguComputeWarpQuadToSquare
The code can be downloaded from the khronos.org site somewhere on the OpenVG page.
Cheers,
Nils
My music: http://myspace.com/planetarchh <-- my music
My stuff: torus.untergrund.net <-- some diy electronic stuff and more.
My stuff: torus.untergrund.net <-- some diy electronic stuff and more.
#6
Posted 18 September 2008 - 08:13 AM
Thank you Nils, it works!
I wrote the code by myself, reading the excellent paper.
Davide
I wrote the code by myself, reading the excellent paper.
Davide
#7
Posted 18 September 2008 - 09:30 PM
Great!
And good luck with your project..
And good luck with your project..
My music: http://myspace.com/planetarchh <-- my music
My stuff: torus.untergrund.net <-- some diy electronic stuff and more.
My stuff: torus.untergrund.net <-- some diy electronic stuff and more.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











