/!\ UPDATE ! /!\ as mentionned by C4RLO5 and Makc3D in the comments, homography can be part of the AR video stream process.
saqoosha did 2 versions with Pixelbender and a displacementmap filter.
His benchmark simply makes this class pointless ( +/- 75 times faster :) )
check saqoosha’s article here
so this is a script to perform a transformation that my poor english might not suffice to explain: homography
now what it does is it takes a projected picture and given 4 control points, it’ll somehow undistort the projected image to retrieve a ‘flat’ map of the original.
a demo worth a thousand words:
on the top half, we have a jpg showing a projected square. you can move the handles around to change the zone to crop.
the small square underneath is the actual homography: the unprojected version of the cropped area.
and on the bottom half, I’ve used Thomas Pfeiffer’s Distort class to remap the homographic version onto 4 arbitrary points (you can also drag them).
it’s quite CPU eating but we should use it as a pre-process .
I tried to make an idiot-proof class so it goes like this:
var target:BitmapData = Homography.setTransform( source, W, H, p1, p2, p3, p4 );
where source is the source bitmapData, W / H are the desired dimensions for homography and p1,p2,p3 and p4 are the control points.
one could use it to recreate a 3D space from pictures 2 or more pictures, say like photosynth (somehow). or just collect the top, front and side maps of a milk box then unwrap them then remap it to a 3D box.
I’m thinking of some kind of motion portrait based on triangles that would use this trick to perform morphing.
well, lots of potential uses.
the class is available here: Homography.as
and the fla file here: homographie.fla
/!\ you need the Distort class to run the fla/!\
et voila!
my beloved readers wrote…