@Override public void close() { if (!open) { return; } try { grabber.stop(); } catch (FrameGrabber.Exception e) { throw new WebcamException(e); } finally { dispose(); } }
public void release() throws Exception { stop(); } @Override protected void finalize() throws Throwable {
@Override public void close() { try { grabber.stop(); } catch (FrameGrabber.Exception e) { throw new RuntimeException(e); } }
@Override public void close() { this.setClosing(); if (grabber != null) { try { grabber.stop(); System.out.println("Stopping grabber (OpencV)"); } catch (Exception e) { System.out.println("Impossible to close " + e); } } }
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: // coding for webcam and taking a picture OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0); try { //start of the webcam for taking the picture grabber.start(); //grabs teh image taken from the webcam IplImage img = grabber.grab(); //checks if the webcam has taken the picture and if the picture if mot empty if(img != null) { //determines where to save the picture cvSaveImage("C:\\User1\\PrifilePicture\\"+lbl_StudnetLogin.getText()+".jpeg", img); } //stops the webcam grabber.stop(); //used to resize teh picture taken in order to display picture to the user Image imeResize = ImageIO.read(new File("C:\\SalVentri\\PrifilePicture\\"+lbl_StudnetLogin.getText()+".jpeg")); //1st ---> width _______2sn ---> height lbl_Profile.setIcon(new ImageIcon(imeResize.getScaledInstance(155, 100, 100))); } catch (Exception e) { //displays error message if problem with webcam JOptionPane.showMessageDialog(null, "Problem accessing or using the Webcam!"); } }
grabber.stop(); } catch (Exception e) {
public static void main(String[] args) throws Exception { OpenCVFrameGrabber grabber = new OpenCVFrameGrabber("http://USER:PASSWORD@187.45.142.127:80/mjpeg.cgi?user=USER&password=PASSWORD&channel=0&.mjpg"); grabber.setFormat("mjpeg"); grabber.start(); IplImage frame = grabber.grab(); CanvasFrame canvasFrame = new CanvasFrame("Camera"); canvasFrame.setCanvasSize(frame.width(), frame.height()); while (canvasFrame.isVisible() && (frame = grabber.grab()) != null) { canvasFrame.showImage(frame); } grabber.stop(); canvasFrame.dispose(); System.exit(0);
grabber.stop();
grabber.stop(); grabber.release(); frame.dispose();
grabber.stop(); canvas.dispose(); } catch (Exception e) {
grabber.stop(); canvasFrame.dispose();