public void run() {
   isShutdown = false;
   while (!isShutdown) {
     try {
       // long start = System.currentTimeMillis();
       IplImage image = grabber.grab();
       if (image != null) {
         img = image.getBufferedImage();
         // System.out.println(System.currentTimeMillis() - start + "ms");
       } else {
         // System.out.println(System.currentTimeMillis() - start + "ms failed");
       }
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
  public void start() {
    try {
      grabber.start();
      grabber.setFrameRate(125);
      System.out.println(grabber.getFrameRate());
      System.out.println(grabber.getFormat());
      System.out.println(grabber.getPixelFormat());
      System.out.println(grabber.getSampleRate());
    } catch (com.googlecode.javacv.FrameGrabber.Exception e1) {
      e1.printStackTrace();
      return;
    }

    try {
      IplImage image = grabber.grab();
      img = image.getBufferedImage();
    } catch (Exception e) {
      e.printStackTrace();
    }

    webcamReaderThread = new Thread(this, "WebcamReaderThread");
    webcamReaderThread.start();
  }