Inverse homography using drawTriangles()

Flash player version 10+ native drawTriangles() method is perfect for programming homography (2D transformation that preserves lines) because of its support for UVT data. In general case, however, homography requires solving 8×8 linear equations system, so noone can be arsed to code that. Instead they implement one of two special cases – mapping rectangle to or from quadrilateral. So far, only 1st case was implemented using drawTriangles, while 2nd case was done using filters. Well, no longer so – it turned out, inverting T values in Zeh code was sufficient to make it work backwards:

One interesting thing about this code is that noone really knows exactly how it works :) I didn’t have to study all the math behind Zeh code in order to “invert” it, and Zeh… well, let me quote:

I was lucky enough to get what I wanted working after a good amount of crazy trial and error (and beer)

12 Responses to “Inverse homography using drawTriangles()”

  1. 2 Jean-Marc Le Roux October 22, 2010 at 13:36

    Nive one !

    That should be very helpful in FlarToolkit right ?

    • 3 makc3d October 23, 2010 at 03:48

      Who knows. I never checked how do they compare quadrilaterals to marker reference data, probably a bunch of getPixel calls. Can’t be too slow, 8×8 grid means only 64 of them.

  2. 4 nicoptere October 23, 2010 at 02:25

    why is there no sound?

  3. 6 Mark Lundin November 1, 2010 at 18:39

    Thats pretty neat. I completely forgot you could use drawTriangles to do this.

  4. 7 Boris May 22, 2014 at 22:26

    Ok, it was a while ago, but I’m very interested in the code of this. What exactly do you mean with “inverting T values”? Could you share your source?
    Thanks a lot,

    • 8 makc3d May 22, 2014 at 22:48

      I mean T-s in UVT array that flash’s drawTriangles() method takes. The picture in the post is clickable (and takes you straight to the source).

  5. 9 Boris May 23, 2014 at 01:12

    I love clickable pictures. Thanks again.

  1. 1 Mark Lundin: Things I know & things I've stolen Trackback on December 2, 2010 at 16:39
  2. 2 Meet qtrack « ¿noʎ ǝɹɐ ʍoɥ 'ʎǝɥ Trackback on December 29, 2010 at 21:06
  3. 3 Projector-Camera sync code on github « Coding on acid. Trackback on June 5, 2012 at 12:44

Ask a Question

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Old stuff

October 2010
« Sep   Nov »

Oh, btw…

%d bloggers like this: