Seif-Abaza / javacv

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

IplImage Create error, memery allocation problem #507

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
guys,I am newer with javacv,there is a error when i use javacv,it make me 
crazy...
here is code.
public void detect() throws IOException {
        for (int i = 0; i < 10; i++) {
            BufferedImage buff = ImageIO.read(new File("d:/wts/src.png"));
            IplImage screenImage = IplImage.createFrom(buff);//8U 4cheannel
            screenImage.copyFrom(buff);
            IplImage srcImage = IplImage.create(cvSize(buff.getWidth(), buff.getHeight()), IPL_DEPTH_8U, 1);
            cvCvtColor(screenImage, srcImage, CV_BGR2GRAY);
            IplImage tarImage = cvLoadImage("d:/wts/tar.png", CV_LOAD_IMAGE_GRAYSCALE);
/*
            Settings settings = new ObjectFinder.Settings();
            settings.setUseFLANN(true);
            settings.setRansacReprojThreshold(5);
            settings.setObjectImage(tarImage);
            ObjectFinder finder = new ObjectFinder(settings);
            double[] result = finder.find(srcImage);
*/if i comment these lines , it works well.
            srcImage.release();
            screenImage.release();
            cvReleaseImage(tarImage);
        }
    }
if I comment loop(for),just call fuctio one time,the fuction work well.but 
sometimes I must call fuction many times,and problem comes,I got java runtime 
error "EXCEPTION_ACCESS_VIOLATION (0xc0000005)",error comes when second call 
fuction or third....
once I comment some lines,it works,so I think problem is memery allocation ,if 
I don't assign srcImage,screenImage,tarImage to other variable,the fution works 
well  whatever times I call.

by the way,my version is javacv0.7 opencv2.4.8 jdk1.7.
Is there anybody have some suggustion on the problem? please

Original issue reported on code.google.com by long57...@gmail.com on 23 Aug 2015 at 4:12