Ejemplo n.º 1
0
  @Override
  protected void setup() {
    // open camera and set resolution
    cam = new VideoCapture();
    cam.open(camId);
    cam.set(Videoio.CV_CAP_PROP_FRAME_WIDTH, camWidth);
    cam.set(Videoio.CV_CAP_PROP_FRAME_HEIGHT, camHeight);

    // check if camera is open
    if (!cam.isOpened()) {
      throw new IllegalStateException("Couldn't open cam: " + camId);
    }
  }
Ejemplo n.º 2
0
 @Override
 protected void task() {
   if (count++ > 100) {
     System.gc();
     count = 0;
   }
   Mat buffer = new Mat();
   // grab a frame
   cam.grab();
   // save the grabbed frame in the buffer
   cam.retrieve(buffer);
   frame = buffer;
   // take a time stamp for latency measurement
   timeStamp = System.nanoTime();
 }
Ejemplo n.º 3
0
 @Override
 protected void shutdown() {
   System.out.println("Shutdown cam " + camId);
   cam.release();
   while (cam.isOpened()) {}
 }