jinjudnjs / javacv

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

Buffers have not been created error #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi Samuel,

before all, thanks for the great job did with wrapper :)
I'm trying to implement a simple motion-detection algorithm (and maybe, when 
it's work, i can upload it into the samples code), but I've encountered a weird 
problem.
My algorithm works in this manner:
1) Take current frame and the previous one, in this way:

 while (canvasFrame.isVisible() && (frame = grabber.grab()) != null) {
   cvSmooth(frame, frame, CV_GAUSSIAN, 9, 9, 2, 2);
   if(image == null) {
     image = IplImage.create(frame.width, frame.height, IPL_DEPTH_8U, 1);
     cvCvtColor(frame, image, CV_RGB2GRAY);
   }
   else {
     prevImage = IplImage.create(frame.width, frame.height, IPL_DEPTH_8U, 1);
     prevImage = image;
     image = IplImage.create(frame.width, frame.height, IPL_DEPTH_8U, 1);
     cvCvtColor(frame, image, CV_RGB2GRAY);
   }

   if(diff == null)
     diff = IplImage.create(frame.width, frame.height, IPL_DEPTH_8U, 1);

2) then if the two images was acquired correctly, I do the difference and 
threshold it:

   if(prevImage != null) {
     cvAbsDiff(image, prevImage, diff);
     cvThreshold(diff, diff, 64, 255, CV_THRESH_BINARY);
    }

This works fine, but when I close the java-application and I rerun it, this 
error appears: Buffers have not been created, and it appears continuosly for a 
couple of attempts then it works again. 

May it be related to the SSE compiled stuff?

Any help will be greatly appreciated :)

What steps will reproduce the problem?
1. Simply compiling and running the program

What is the expected output? What do you see instead?
Working code, I've got instead an error

What version of the product are you using? On what operating system?
Netbeans 6.8 under Ubuntu 10.04 (amd64 architecture), and OpenCV 2.1

Original issue reported on code.google.com by sleeping...@gmail.com on 30 Sep 2010 at 10:40

GoogleCodeExporter commented 9 years ago
Yeah, that seems to be an issue with BufferStrategy in Java.. I am not sure 
what causes it, but it never made my program crash or work incorrectly. Does 
your program not work when that message appears?

Original comment by samuel.a...@gmail.com on 30 Sep 2010 at 1:59

GoogleCodeExporter commented 9 years ago
Actually, it freezes when the error occur. Disabling the instruction 
"canvasFrame.showImage(image)" make it works fine. Another detail I've noticed 
is that if I wait a low time before compile and run again the program (10 sec 
for example), it works without error. Maybe it's a problem with Garbage 
Collection or something related?

Original comment by sleeping...@gmail.com on 30 Sep 2010 at 2:04

GoogleCodeExporter commented 9 years ago
Ah, no, if it freezes it's probably a problem with your video card driver.. 

You can also try to use OpenGL instead of X11 SHM by setting the _JAVA_OPTIONS 
environment variable before executing your program, something like this in bash:
    export _JAVA_OPTIONS="-Dsun.java2d.opengl=True"
or put it in ~/.bashrc and relog in.

Original comment by samuel.a...@gmail.com on 30 Sep 2010 at 2:13

GoogleCodeExporter commented 9 years ago
Okay, I will try this evening then I will show the results! Thanks for help! :)

Original comment by sleeping...@gmail.com on 30 Sep 2010 at 2:18

GoogleCodeExporter commented 9 years ago
Closing this long-standing issue, assuming that OpenGL or a better video driver 
did the trick. Please reopen the issue if that is not the case, thank you.

Original comment by samuel.a...@gmail.com on 4 Nov 2010 at 10:32