illegalargumentexception width and height must be 0

Hi , when i try to run the following code :

import gab.opencv.*;
import java.awt.*;
import processing.video.*;

Capture cam;
OpenCV opencv;

void setup() {
  size(640, 480);

  String[] cameras = Capture.list();

  cam = new Capture(this, cameras[0]);

  opencv = new OpenCV(this, 640/2, 480/2);
  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE); 

  cam.start();
}


void draw() {
  scale(2);
  opencv.loadImage(cam);

  image(cam, 0 , 0 );

  noFill();
  stroke(0, 255, 0);
  strokeWeight(3);
  Rectangle[] faces = opencv.detect();
  println(faces.length);

  for (int i = 0; i < faces.length; i++) {
    println(faces[i].x + "," + faces[i].y);
    rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
  }
}

void captureEvent(Capture c) {
  c.read();
}

I get the following error :

illegalargumentexception width(0) and height(0) cannot be <=0

How do i solve this error?

Tagged:

Answers

  • Quick guess: you're trying to read a frame before the camera is available. If you use available() does that help?

  • Note that your subject is contradicted by the error message at the end of your message.

Sign In or Register to comment.