/** Stop the capture and release the frame grabbers */ private void releaseVideo() { try { frameGrabberLeft.stopCapture(); } catch (Exception e) { } try { frameGrabberRight.stopCapture(); } catch (Exception e) { } try { videoDevLeft.releaseFrameGrabber(); } catch (Exception e) { } try { videoDevRight.releaseFrameGrabber(); } catch (Exception e) { } }
/** * Initialise two FrameGrabber objects with the given parameters * * @param devLeft the video device file to capture from * @param devRight the video device file to capture from * @param w the desired capture width * @param h the desired capture height * @param std the capture standard * @param channel the capture channel * @param qty the JPEG compression quality * @throws V4L4JException if any parameter if invalid */ private void initFrameGrabber( String devLeft, String devRight, int w, int h, int std, int channel, int qty) throws V4L4JException { videoDevLeft = new VideoDevice(devLeft); videoDevRight = new VideoDevice(devRight); frameGrabberLeft = videoDevLeft.getJPEGFrameGrabber(w, h, channel, std, qty); frameGrabberRight = videoDevRight.getJPEGFrameGrabber(w, h, channel, std, qty); frameGrabberLeft.setCaptureCallback(this); frameGrabberRight.setCaptureCallback(this); frameGrabberLeft.startCapture(); frameGrabberRight.startCapture(); widthLeft = frameGrabberLeft.getWidth(); heightLeft = frameGrabberLeft.getHeight(); widthRight = frameGrabberRight.getWidth(); heightRight = frameGrabberRight.getHeight(); System.out.println( "Starting capture at:\n" + "Left: " + widthLeft + "x" + heightLeft + "\nRight: " + widthRight + "x" + heightRight); frame.setSize(widthLeft + widthRight, heightLeft); labelLeft.setMaximumSize(new Dimension(widthLeft, heightLeft)); labelRight.setMaximumSize(new Dimension(widthRight, heightRight)); labelLeft.setBorder(BorderFactory.createLineBorder(Color.RED)); labelRight.setBorder(BorderFactory.createLineBorder(Color.RED)); }