rindarith / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

Invalid Memory Access using FloatPointer and PointVectorVector (chamerMatching()) #132

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I'm calling the function the OpenCV function chamerMatching, which works about 
50% of the time as below, and the other amount of the time I get:

Invalid memory access of location 0x1c60f6c61cc rip=0x11bcc01ea

Though its hard to debug this issue with such an uninformative error message, 
am i creating the javacpp objects FloatPointer and PointVectorVector correctly?

Thanks!

Adam

CvMemStorage storage = CvMemStorage.create();

        String tempName = "/Users/adamhaber/jMonkeyProjects/AdamSim/assets/ChamferTemplates/semi-circle.png";

        test = IplImage.createFrom(im);
        IplImage template = cvLoadImage(tempName, 0);

        if (test != null && template != null) {
            // System.out.println("Images loaded successfully..");
        }

        /*Canny edge detection*/
        cvCanny(test, test, 25, 25, 3);

        /*javaCPP versions of the c++ objects Vector<Vector<CvPoint>> and Vector<float> */
        PointVectorVector detected_pixels = new PointVectorVector();
        FloatPointer costs = new FloatPointer();

        /*Chamfer Matching parameters*/
        double templScale = 0.7;       //default = 1;
        int maxMatches = 5;             //default = 20;
        double minMatchDistance = 5;   //default = 1.0;
        int padX = 10;                   //default = 3;
        int padY = 10;                   //default = 3;
        int scales = 15;                 //default = 5;
        double minScale = 0.5;          //default =0.6;
        double maxScale = 3;          //default = 1.6;
        double orientationWeight = 0.5; //default =0.5;
        double truncate = 20;           //default =20;

        /* call the openCV function chamerMatching. The function returns a Vector of Vector<Points> Each point is a point detected
         * which, if coloured in (as below) shows where the template is found in the target image.
         */
         System.out.println("trying chamerMatching");
        int best = chamerMatching(test, template, detected_pixels, costs, templScale, maxMatches, minMatchDistance, padX, padY, scales, minScale, maxScale, orientationWeight, truncate);

Original issue reported on code.google.com by mynameis...@hotmail.com on 15 Nov 2011 at 1:10

GoogleCodeExporter commented 9 years ago
It seems like chamerMatching() is overwriting the content of the images, and 
crashes on its own modifications when called a second time. It works fine for 
me if I reload the images before another call to chamerMatching().

I get the exact same behavior when calling it directly from C++, so this is not 
a problem with JavaCV.

And yes creating a PointVectorVector and FloatPointer that way is fine.

Original comment by samuel.a...@gmail.com on 26 Nov 2011 at 6:57