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:
ofRunApp(new testApp());
instead of :
testApp APP;
ofRunApp(&APP);
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.
in the RAR file you’ll find one folder with my app and a libs folder.
on the libs folder there’s just :
/libs/openframeworks/computerVision folder, which is the one i’m having the problem with. I think is the only code i’ve been playing with …
i think that if u copy an OF project that links with openCV and just modify it with my computerVision libs and copy my app code u should be able to compile it succesfully.
so bringing back the problem again : i was trying to apply a QMatrix transformation not to the whole image (as in WarpIntoMe), but to a collection of points (a contour from ofCountourFinder) …
this is the function that i’ve added to grayscale images that crashes, it should apply the transformation matrix to an array of points, but i can’t get it to work . always telling me cvGetMat error …
more inside it’s crashing the “cvPerspectiveTransform” function by some error on preparing the parameters that i can’t solve.
if you comment out that line you’ll see the test application running…
if you press “p” you have to click on four corners of area to warp.
if (contourFinder.nBlobs > 0){
grayDiff.warpPoints(contourFinder.blobs[0].pts,pts,contourFinder.blobs[0].nPts);
}
it doesn’t crash – I still don’t see the problem though.
can I ask you to maybe code a *dirt* simple example of manipulating points by opencv, ie, not hacking OF code (and preferably not using video) that shows the problem?
I’m happy to help, but I still don’t see the issue
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.