Width (0) and height (0) cannot be <= 0

I am working on a very simple BackgroundSubtraction code on processing. In the beginning everything was woking fine but now I get the “Width (0) and height (0) cannot be <= 0” error every time I try to play the code. Here is my code:

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

Movie video;
OpenCV opencv;

void setup() {
  size(1920,1080);
  video = new Movie(this, "Rotatie.mov");
  opencv = new OpenCV(this, 1920,1080);
  
  opencv.startBackgroundSubtraction(5, 3, 0.5);
  
  video.loop();
  video.play();
  background(255);
}

void draw() {
  //background(255);
  //scale(2);

// image(video, 0, 0);  
  opencv.loadImage(video);
  
  opencv.updateBackground();
  
  opencv.dilate();
  opencv.erode();

  
  noFill();
  stroke(122, 179, 216);
  strokeWeight(0.5);
  //noStroke();
  for (Contour contour : opencv.findContours()) {
    //float fil = map(contour.getPoints().size(),0,1000,0,255);
    //fill(0,150);
    contour.draw();
    
     //fill(0,10);
    //contour.getConvexHull().draw();
    
    
      //fill(0,10);
    //contour.getPolygonApproximation().draw();
  }
   
  }


void movieEvent(Movie m) {
  m.read();
  
  //saveFrame("output1.1/standpunt_####.png"); 
}

Hey,

Please format your code by pressing Ctrl+T in the Processing IDE code editor and insert it by pressing <\> in the message editor.

What line gives you the error?
We don’t have your resources so we won’t be able to reproduce the error.
Also, you need to format your code.

Kf

opencv.loadImage(video);

This line gives the error. Here is also the sketch folder from my file. The videos I’m using are in the data folder.

Thank you! How exactly do I put this in my script?I am very new to processing! I have tried it like this:

void setup() {
  size(960,540);
  video = new Movie(this,"Rotatie.mov").loop();
  while (myMovie.height==0) delay(2);

But then it gives me the error: “cannot convert from void to Movie”.

1 Like

It’s pretty obviously video is the variable holding the Movie object in your own sketch! :roll_eyes:

import gab.opencv.OpenCV;
import processing.video.Movie;

OpenCV opencv;
Movie video;

void setup() {
  size(960, 540);

  noFill();
  stroke(122, 179, 216);
  strokeWeight(.5);

  opencv = new OpenCV(this, width, height);
  opencv.startBackgroundSubtraction(5, 3, .5);

  ( video = new Movie(this, "Rotatie.mov") ).loop();
  while (video.height == 0)  delay(2);
}

void movieEvent(final Movie m) {
  m.read();
}

Now it gives me an error on line
video = new Movie(this, "Rotatie.mov").loop();

the error says: “cannot convert from void to Movie”.

You have miscopied ( myMovie = new Movie(this, "kat.mov") ).loop(); from my link like this:
video = new Movie(this,"Rotatie.mov").loop(); :mask:

And I’ve ended up following it in my answer post! :expressionless:

It’s fixed in my post now: ( video = new Movie(this, "Rotatie.mov") ).loop(); :construction_worker_man:

It works! Thank you very much!