Export to GitHub

javacv - issue #507

IplImage Create error, memery allocation problem


Posted on Aug 23, 2015 by Happy Bear

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

Comment #1

Posted on Aug 24, 2015 by Happy Kangaroo

Please try again with version 1.0, thank you.

Comment #2

Posted on Aug 24, 2015 by Happy Bear

samuel,thanks. I use version 1.0,it works.The changes between 0.7 and 1.0 is so large.there is no fuction IplImage.createFrom(BufferedImage) or IplImage.copyFrom(BufferedImage) in ver1.0,but I really need the fuction create IplImage from BufferedImage. In my program,source image is a screenshot saved by BufferedImage.Now I have to save BufferedImage to disk,and read it again with cvLoadImage().

Comment #3

Posted on Aug 24, 2015 by Happy Kangaroo

Yes, it changed a lot. Details here: http://bytedeco.org/news/2015/04/04/javacv-frame-converters/

Status: Done

Labels:
Type-Other Priority-Medium