Quad warping / homography without opencv

started a projection-mapping simple tool experiment using as a foundation the code provided in this thread.
first code ever in openframeworks and c++ for me.



i have used the matrix and cvfindhomography code for a projected that uses 2 hd projectors.
it works pretty good.
the projectors project on to a conveyor belt. on the belt we place real objects and on to the moving objects we projected images.

but i have noticed that the position of the real and projected images do not always match. it changes through out the projection.
it matches at the start (left side of projection), lags behind towards the middle and is a head towards the right.

i know memo mentioned that short throw lens need some sort of un-warping but this is a beng w6000 with a normal lens.

here is a link to the project:

here is my code to help make the matrix map:

any ideas what is going on?


@arturo thanks so much for this code!

I have a question - does it matter which order the points 0-3 are defined in? I’m using them with the ofxSimpleGUITooQuadWarper which seems to use points defined from the top left clockwise. My destPoints are also defined as such but I’m getting unexpected results.

thanks again.


Ah. After some hair pulling, I figured it out. If you take Arturo’s code :

ofMatrix4x4 H = findHomography(sourcePoints, destPoints);    
ofVec3f v(xPos,yPos);    
ofVec3f t = v * H;   

… it doesn’t work. Instead I switched H and v and now it works!

ofVec3f t = H * v;   

Just thought I’d let you know in case this was a bug, or maybe just a slight change in the ofMatrix4x4 or ofVec2f objects.



I’m curious about the opposite of this code:

ofxMatrix4x4 H = findHomography(src,dst);  
ofxVec2f v(x,y);  
ofxVec2f t = v*H;  

Something like:

ofxMatrix4x4 H = findHomography(src,dst);  
ofxVec2f t(x,y);  
ofxVec2f v = t/H;  

Maybe someone can point me to the right direction?

I solved it in a very simple way - just by swapping the source points with destination points in the find homography function call. Like the following:

ofxMatrix4x4 H = findHomography(dst,src);  
ofxVec2f t(x,y);  
ofxVec2f v = t*H;  

That’s it!


I’m very interested in your code but the link doesnt work anymore.

Any help?

Hi !
I am curious about this as well - at the moment I created my own class out of the ofxCV example to produce homography with video using 4 points . If by any chance that could increase performance/ simplify things would love to get hands on the example zip file at the beginning of the thread.
Thanks !

this might be useful.

1 Like

Hi Roy,
I hope you are all well !
I’ll have a look,