i’m trying to use the cvPerspectiveTransform() function to transform a set of points from a blob contour by the projection matrix, so similar to actual WarpIntome function but applied to a set of points instead of to the whole image.
i’m using the same matrix that uses of_warpIntoMe() function so a 3x3.
i’ve the specification of this function here :
can you post if possible a very small example (the smallest example possible, no video, etc) that does this and I will try to take a look ?
printfs or commenting out can show you which call is doing it - if you know the call, you probably know more specifically what to google about.
today I actually have to do something similar (compute homography and just warp opengl drawing instead of image based stuff). the opengl warping is a bit like the simple opengl shadow tutorials, where you compute a tranformation matrix based off of light position and the floor plane. In the end you mulitply a box of numbers by the points you draw (opengl does this automatically all the time) the same thing you are trying to do by hand in opencv - so it might be helpful.
keys// – “q/a” + and - thershold level – “p” then u have to set a quad of 4 points with the mouse
which define the transformation to be done.
(starting by the top-left and counterclockwise) – “z” swap between two modes :
1/calculate matrix from 4 points then apply it to the whole image. get contour.
2/this is the mode that i’m trying to do : apply transformation to the vertexs of a contour.CRASHES.
i’m just including the /openframeworks/computervision lib because it’s the only one that changed.
basically i’ve a function to calculate the matrix from 4+4 points.(warpMatrixQ) and another function to apply this transformation to the whole image(warpImage) and the last one is the one to apply transformation to collection of vertex (warpPoints).(the one that crashes)
why add delete(temp) ? this is bad, bad, bad – swap temp is just switching pointers of two images, if you delete one of them, you will break ofCvGrayscaleImage’s ability to work. in fact, it works only once and the second time you do anything with the image, it breaks since one of the two pointers is deleted.
can you please recode it without altering too much the OF code? I am having trouble getting to the specific problem you are writing about…
another small note:
in main.cpp, you can do this:
instead of :
this allows “atExit” to properly delete testApp - new since 0.03, you can see it in the examples. this will help avoid getting errors as you quit the app.
sorry for that … it was an obvious error . I was looking for a memory not deallocated and i test with that non-sense stuff … it got stuck on the test version i zipped, not on my full version … sorry for the mistake … my error.
can u just delete that line and leave it as originally it was ?
still too difficult to compile ?
i modify opencv files and functions looking for necessities i need on the code . i know is not the way it should be done, i should extend the OF class with a new class adding my new needed functions … sorry for that lazyness … sometimes prototyping has this problems …
still getting error on cvPerspectiveTransform() … :_(
thanks a lot for your testApp stuff, i’ve been developping in OF.0.02 and i haven’t actualized yer to OF.0.03.
I just tried to code a small example myself and I couldn’t get it to work. I think you will have to make a very simple example and ask on the opencv mailing list. there might be a bug or something you and I are doing wrong… sorry I can’t help more.
for warping 2d points, you might want to take a look at the code from anti grain geometry - I’ve used that before for perspectival warping.