I think I found the problem. The problem seems to appear on the page "grabber.start ()"; line. (Due to the fact that, commenting on this line, everything went well, and there appeared a problem with the openCV library. Therefore, I think that it is not easy to get rid of this problem.
Thanks to everyone for the effort though.
Edited: [FOUND THE SOLUTION]
It seems that the OpenCVFrameGrabber class implemented the Thread Runnable interface, so the object created by this class subsequently works like a thread. (Not the same). Anyway, as a solution to this problem, I first released grabber:
public Test() { //canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE); canvas.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.out.println("\nClosing it."); try { //if (grabber != null) grabber.release(); //grabber.stop(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } System.exit(0); } }); }
source share