Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cvconverter.converToIplImage crash the 2nd time #195

Closed
oelleo opened this issue Aug 7, 2015 · 3 comments
Closed

cvconverter.converToIplImage crash the 2nd time #195

oelleo opened this issue Aug 7, 2015 · 3 comments

Comments

@oelleo
Copy link

oelleo commented Aug 7, 2015

Hi,
I'm using the following code to convert a byte[] imageData to an IplImage.

InputStream in = new ByteArrayInputStream(imageData);
BufferedImage bufImage = ImageIO.read(in);
Java2DFrameConverter javaconverter = new Java2DFrameConverter(); 
Frame frame = javaconverter.convert(bufImage);
OpenCVFrameConverter.ToIplImage cvconverter = new OpenCVFrameConverter.ToIplImage(); 
IplImage iplImage = cvconverter.convertToIplImage(frame);

It works great the first time but when run again on this function it crashes Java and Stop my server.
From the debug it appears when it arrives on the last line IplImage iplImage = cvconverter.convertToIplImage(frame);
Sometimes it log EXCEPTION_ACCESS_VIOLATION but not always.
Can you help ?

Thanks

@saudet
Copy link
Member

saudet commented Aug 7, 2015

Duplicate of #150. Basically, we should be keeping the instances of FrameConverter alive instead of recreating them over and over again:
http://bytedeco.org/javacv/apidocs/org/bytedeco/javacv/FrameConverter.html
If you can think of a better way to do this, I would very much to hear about it! Thanks

@saudet saudet closed this as completed Aug 7, 2015
@oelleo
Copy link
Author

oelleo commented Aug 7, 2015

Ok, thank you for the answer and sorry for the duplicated entry.
I see in your documentation that FrameConverter is not garbage collected.
Maybe it would be good to add some function to release them like there is for IplImage (cvReleaseImage) ?

@saudet
Copy link
Member

saudet commented Aug 8, 2015

That's fine for OpenCVFrameConverter, but how would we "release" a BufferedImage in the case of Java2DFrameGrabber?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants