@Override
 public void disconnect() {
   try {
     cam.disconnect();
   } catch (CameraConnectionException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
  @Override
  public boolean captureNewImage(BufferedImage imageData) {
    int failure = 0;
    while (failure < 5) {
      try {
        // Thread.sleep(3000);
        // bufferedImageToMat(cam.getPicture(), imageData);
        AbstractImageProvider.deepCopy(cam.getPicture(), imageData);
        return true;
      } catch (CameraConnectionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return false;
      } catch (CameraShootException e) {
        e.printStackTrace();

        failure++;
      }
    }
    return false;
  }
 public CHDKImageProvider() throws PTPTimeoutException, GenericCameraException {
   cam = CameraFactory.getCamera(SupportedCamera.SX160IS);
   cam.connect();
   cam.setOperaionMode(CameraMode.RECORD);
 }