Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

  • Capturing Video from Youtube or Webcams

    Well, IPCapture is a totally different library, with different methods.

    And now you are trying to use the Movie object of the video library, which has other methods:

    You said:

    I've edited it some more, now I'm getting The function "isAvailable() does not exist. This is really confused because when it was IPcapture, it worked and now I've swapped it to movie, it's getting all kinds of errors!

    Here is a metaphor:

    I tried to start the microwave, but it won't let me light a burner. This is really confusing, because when I was using an oven, lighting the burner worked. Now that I swapped it to microwave I am getting all kinds of errors!

    Both for cooking (or playing video), but different ways of working, so different controls. You have to use the controls of the new thing you are using -- not some other thing.

  • Capturing Video from Youtube or Webcams

    I've edited it some more, now I'm getting The function "isAvailable() does not exist. This is really confused because when it was IPcapture, it worked and now I've swapped it to movie, it's getting all kinds of errors!

    import processing.video.*;
    Movie myMovie;
    
    
    import gab.opencv.*;
    import processing.video.*;
    import org.opencv.core.Rect;
    import themidibus.*; //Import the library
    
    
    OpenCV opencv;
    MidiBus midi; 
    
    
    int lastMillis;
    
    int [][] timestamps = new int [16][128];
    
    
    void setup() {
      size(800, 450);
      for (int ch = 0; ch < 16; ch++) {
        for (int i = 0; i < 128; i++) {
          timestamps[ch][i] = -1;
    
      }
      }
    
      myMovie = new Movie(this, "http://" + "www.skylinewebcams.com/webcam/united-kingdom/england/brighton/brighton.html?resolution=800x450");
      myMovie.read();
      opencv = new OpenCV(this, 800, 450);
    
      opencv.startBackgroundSubtraction(5, 3, 0.5);
      MidiBus.list();
      midi = new MidiBus(this, -1, "Bus 1");
    }
    
    void sendNote(int ch, int n) {
      if (timestamps[ch][n] == -1) {
        midi.sendNoteOn(ch, n, 100);
        timestamps[ch][n] = millis();
      }
    }
    
    void draw() {
    
      //check for overdue notes
      for (int ch = 0; ch < 16; ch++) {
        for (int i = 0; i < 128; i++) {
          if (timestamps[ch][i]  > -1) {
            if (millis()>timestamps[ch][i] +400) {
              midi.sendNoteOff(ch, i, 100);
              timestamps[ch][i] = -1;
            }
          }
        }
      }
    
      if (myMovie.isAvailable()) {
        myMovie.read();
        image(myMovie, 0, 0);  
        opencv.loadImage(myMovie);
        opencv.updateBackground();
    
        opencv.dilate();
        opencv.erode();
    
    //LINE COLOUR
    
        noFill();
        stroke(0, 0);
    
        strokeWeight(1);
    
        int rx = 580; 
        int ry = 15;
        int rw = 80;
        int rh = 70;
        rect(rx, ry, rw, rh);
    
        int rx2 = 40; 
        int ry2 = 140;
        int rw2 = 70;
        int rh2 = 120;
        rect(rx2, ry2, rw2, rh2);
    
    
        int rx3 = 500; 
        int ry3 = 190;
        int rw3 = 80;
        int rh3 = 40;
        rect(rx3, ry3, rw3, rh3);
    
    
        int rx4 = 200; 
        int ry4 = 50;
        int rw4 = 75;
        int rh4 = 150;
        rect(rx4, ry4, rw4, rh4);
    
        int rx401 = 275; 
        int ry401= 50;
        int rw401 = 75;
        int rh401 = 150;
        rect(rx401, ry401, rw401, rh401);
    
    
        int rx5 = 50; 
        int ry5 = 280;
        int rw5 = 80;
        int rh5 = 80;
        rect(rx5, ry5, rw5, rh5);
    
        int rx501 = 50; 
        int ry501 = 280;
        int rw501 = 80;
        int rh501 = 80;
        rect(rx501, ry501, rw501, rh501);
    
        int rx6 = 490; 
        int ry6 = 300;
        int rw6 = 100;
        int rh6 = 40;
        rect(rx6, ry6, rw6, rh6);
    
        int rx7 = 310; 
        int ry7 = 300;
        int rw7 = 100;
        int rh7 = 140;
        rect(rx7, ry7, rw7, rh7);
    
    
        int rx8 = 50; 
        int ry8 = 380;
        int rw8 = 90;
        int rh8 = 70;
        rect(rx8, ry8, rw8, rh8);
    
    
        int rx9 = 600; 
        int ry9 = 240;
        int rw9 = 25;
        int rh9 = 20;
        rect(rx9, ry9, rw9, rh9);
    
        int rx901 = 600; 
        int ry901 = 240;
        int rw901 = 25;
        int rh901 = 20;
        rect(rx901, ry901, rw901, rh901);
    
    
        int rx10 = 700; 
        int ry10 = 250;
        int rw10 = 35;
        int rh10 = 15;
        rect(rx10, ry10, rw10, rh10);
    
        int rx101 = 700; 
        int ry101 = 250;
        int rw101 = 90;
        int rh101 = 35;
        rect(rx101, ry101, rw101, rh101);
    
    
        int rx11 = 675; 
        int ry11 = 300;
        int rw11 = 55;
        int rh11 = 50;
        rect(rx11, ry11, rw11, rh11);
    
    
        int rx12 = 500; 
        int ry12 = 40;
        int rw12 = 45;
        int rh12 = 80;
        rect(rx12, ry12, rw12, rh12);
    
        int rx13 = 450; 
        int ry13 = 190;
        int rw13 = 45;
        int rh13 = 15;
        rect(rx13, ry13, rw13, rh13);
    
        int rx14 = 390; 
        int ry14 = 85;
        int rw14 = 45;
        int rh14 = 15;
        rect(rx14, ry14, rw14, rh14);
    
    
        int rx141 = 390; 
        int ry141 = 85;
        int rw141 = 45;
        int rh141 = 15;
        rect(rx141, ry141, rw141, rh141);
    
    
        int rx15 = 390; 
        int ry15 = 150;
        int rw15 = 45;
        int rh15 = 45;
        rect(rx15, ry15, rw15, rh15);
    
    
        int rx16 = 700; 
        int ry16 = 100;
        int rw16 = 100;
        int rh16 = 100;
        rect(rx16, ry16, rw16, rh16);
    
    
        int rx17 = 500; 
        int ry17 = 250;
        int rw17 = 100;
        int rh17 = 40;
        rect(rx17, ry17, rw17, rh17);
    
    
        int rx18 = 525; 
        int ry18 = 350;
        int rw18 = 20;
        int rh18 = 20;
        rect(rx18, ry18, rw18, rh18);
    
    
        int rx181 = 545; 
        int ry181 = 370;
        int rw181 = 20;
        int rh181 = 20;
        rect(rx181, ry181, rw181, rh181);
    
        stroke(255, 1, 1);
        strokeWeight(1);
        for (Contour contour : opencv.findContours()) {
    
    
          println(contour.getBoundingBox().x);
          println(contour.getBoundingBox().y);
          int x = contour.getBoundingBox().x;
          int y = contour.getBoundingBox().y;
    
          contour.draw();
    
    
    
          if (( x > rx && x < rx + rw) && (y > ry && y < ry + rh)) {
            sendNote(0, 60);
          }
    
          if (( x > rx2 && x < rx2 + rw2) && (y > ry2 && y < ry2 + rh2)) {
            sendNote(0, 61);
          }
    
          if (( x > rx3 && x < rx3 + rw3) && (y > ry3 && y < ry3 + rh3)) {
            sendNote(0, 62);
          }
    
          if (( x > rx4 && x < rx4 + rw4) && (y > ry4 && y < ry4 + rh4)) {
            sendNote(1, 60);
          }
    
          if (( x > rx401 && x < rx401 + rw401) && (y > ry401 && y < ry401 + rh401)) {
            sendNote(1, 51);
          }
    
    
          if (( x > rx5 && x < rx5 + rw5) && (y > ry5 && y < ry5 + rh5)) {
            sendNote(1, 61);
          }
    
          if (( x > rx501 && x < rx501 + rw501) && (y > ry501 && y < ry501 + rh501)) {
            sendNote(0, 51);
          }
    
          if (( x > rx6 && x < rx6 + rw6) && (y > ry6 && y < ry6 + rh6)) {
            sendNote(1, 62);
          }
    
          if (( x > rx7 && x < rx7 + rw7) && (y > ry7 && y < ry7 + rh7)) {
            sendNote(1, 63);
          }
    
          if (( x > rx8 && x < rx8 + rw8) && (y > ry8 && y < ry8 + rh8)) {
            sendNote(1, 64);
          }
    
          if (( x > rx9 && x < rx9 + rw9) && (y > ry9 && y < ry9 + rh9)) {
            sendNote(1, 52);
          }
    
                if (( x > rx901 && x < rx901 + rw901) && (y > ry901 && y < ry901 + rh901)) {
            sendNote(1, 65);
          }
    
          if (( x > rx10 && x < rx10 + rw10) && (y > ry10 && y < ry10 + rh10)) {
            sendNote(1, 66);
          }
    
          if (( x > rx101 && x < rx101 + rw101) && (y > ry101 && y < ry101 + rh101)) {
            sendNote(1, 53);
          }
    
    
          if (( x > rx11 && x < rx11 + rw11) && (y > ry11 && y < ry11 + rh11)) {
            sendNote(1, 67);
          }
    
          if (( x > rx12 && x < rx12 + rw12) && (y > ry12 && y < ry12 + rh12)) {
            sendNote(1, 68);
          }
    
          if (( x > rx13 && x < rx13 + rw13) && (y > ry13 && y < ry13 + rh13)) {
            sendNote(1, 69);
          }
    
          if (( x > rx14 && x < rx14 + rw14) && (y > ry14 && y < ry14 + rh14)) {
            sendNote(1, 70);
          }
    
          if (( x > rx141 && x < rx141 + rw141) && (y > ry141 && y < ry141 + rh141)) {
            sendNote(1, 54);
          }
    
          if (( x > rx15 && x < rx15 + rw15) && (y > ry15 && y < ry15 + rh15)) {
            sendNote(0, 71);
          }
    
          if (( x > rx16 && x < rx16 + rw16) && (y > ry16 && y < ry16 + rh16)) {
            sendNote(1, 55);
          }
    
          if (( x > rx17 && x < rx17 + rw17) && (y > ry17 && y < ry17 + rh17)) {
            sendNote(0, 72);
          }
    
          if (( x > rx18 && x < rx18 + rw18) && (y > ry18 && y < ry18 + rh18)) {
            sendNote(1, 72);
          }
    
                if (( x > rx181 && x < rx181 + rw181) && (y > ry181 && y < ry181 + rh181)) {
            sendNote(1, 73);
          }
    
        }
      }
    }
    
  • Capturing Video from Youtube or Webcams

    Yes, I understand I may have to use something different to ipcapture. Sorry, that's what I meant to ask, if there is an alternative to ipcapture that would work to get either of those two streams working.

    And yes koogs, I do need to tidy up the code. We went straight into a new maxmsp project for my masters and haven't had a chance to sort it out so it's nice and clean

  • Capturing Video from Youtube or Webcams

    There's an m3u8 URL associated with the first feed and that'll play if you paste it into vlc, but i doubt ipcapture will handle it. The second feed is YouTube and will be rtmp or whatever and again incompatible with ipcapture. You're going to have to rethink your code. Or find a compatible feed, which might be easier.

    (You've also not applied any of the tidying suggested in the previous thread so there's 200 lines of flab in there)

  • Capturing Video from Youtube or Webcams
    import gab.opencv.*;
    import processing.video.*;
    import ipcapture.*;
    import org.opencv.core.Rect;
    import themidibus.*; //Import the library
    
    
    OpenCV opencv;
    IPCapture cam;
    MidiBus midi; 
    
    int lastMillis;
    
    int [][] timestamps = new int [16][128];
    
    
    void setup() {
      size(800, 450);
      for (int ch = 0; ch < 16; ch++) {
        for (int i = 0; i < 128; i++) {
          timestamps[ch][i] = -1;
        }
      }
    
      cam = new IPCapture(this, "http://" + "65.152.238.150:80/mjpg/video.mjpg?resolution=800x450", "", "");
      cam.start();
      opencv = new OpenCV(this, 800, 450);
    
      opencv.startBackgroundSubtraction(5, 3, 0.5);
      MidiBus.list();
      midi = new MidiBus(this, -1, "Bus 1");
    }
    
    void sendNote(int ch, int n) {
      if (timestamps[ch][n] == -1) {
        midi.sendNoteOn(ch, n, 100);
        timestamps[ch][n] = millis();
      }
    }
    
    void draw() {
    
      //check for overdue notes
      for (int ch = 0; ch < 16; ch++) {
        for (int i = 0; i < 128; i++) {
          if (timestamps[ch][i]  > -1) {
            if (millis()>timestamps[ch][i] +400) {
              midi.sendNoteOff(ch, i, 100);
              timestamps[ch][i] = -1;
            }
          }
        }
      }
    
      if (cam.isAvailable()) {
        cam.read();
        image(cam, 0, 0);  
        opencv.loadImage(cam);
        opencv.updateBackground();
    
        opencv.dilate();
        opencv.erode();
    
    
    
        noFill();
        stroke(0, 0);
    
        strokeWeight(1);
    
        int rx = 580; 
        int ry = 15;
        int rw = 80;
        int rh = 70;
        rect(rx, ry, rw, rh);
    
        int rx2 = 40; 
        int ry2 = 140;
        int rw2 = 70;
        int rh2 = 120;
        rect(rx2, ry2, rw2, rh2);
    
    
        int rx3 = 500; 
        int ry3 = 190;
        int rw3 = 80;
        int rh3 = 40;
        rect(rx3, ry3, rw3, rh3);
    
    
        int rx4 = 200; 
        int ry4 = 50;
        int rw4 = 75;
        int rh4 = 150;
        rect(rx4, ry4, rw4, rh4);
    
        int rx401 = 275; 
        int ry401= 50;
        int rw401 = 75;
        int rh401 = 150;
        rect(rx401, ry401, rw401, rh401);
    
    
        int rx5 = 50; 
        int ry5 = 280;
        int rw5 = 80;
        int rh5 = 80;
        rect(rx5, ry5, rw5, rh5);
    
        int rx501 = 50; 
        int ry501 = 280;
        int rw501 = 80;
        int rh501 = 80;
        rect(rx501, ry501, rw501, rh501);
    
        int rx6 = 490; 
        int ry6 = 300;
        int rw6 = 100;
        int rh6 = 40;
        rect(rx6, ry6, rw6, rh6);
    
        int rx7 = 310; 
        int ry7 = 300;
        int rw7 = 100;
        int rh7 = 140;
        rect(rx7, ry7, rw7, rh7);
    
    
        int rx8 = 50; 
        int ry8 = 380;
        int rw8 = 90;
        int rh8 = 70;
        rect(rx8, ry8, rw8, rh8);
    
    
        int rx9 = 600; 
        int ry9 = 240;
        int rw9 = 25;
        int rh9 = 20;
        rect(rx9, ry9, rw9, rh9);
    
        int rx901 = 600; 
        int ry901 = 240;
        int rw901 = 25;
        int rh901 = 20;
        rect(rx901, ry901, rw901, rh901);
    
    
        int rx10 = 700; 
        int ry10 = 250;
        int rw10 = 35;
        int rh10 = 15;
        rect(rx10, ry10, rw10, rh10);
    
        int rx101 = 700; 
        int ry101 = 250;
        int rw101 = 90;
        int rh101 = 35;
        rect(rx101, ry101, rw101, rh101);
    
    
        int rx11 = 675; 
        int ry11 = 300;
        int rw11 = 55;
        int rh11 = 50;
        rect(rx11, ry11, rw11, rh11);
    
    
        int rx12 = 500; 
        int ry12 = 40;
        int rw12 = 45;
        int rh12 = 80;
        rect(rx12, ry12, rw12, rh12);
    
        int rx13 = 450; 
        int ry13 = 190;
        int rw13 = 45;
        int rh13 = 15;
        rect(rx13, ry13, rw13, rh13);
    
        int rx14 = 390; 
        int ry14 = 85;
        int rw14 = 45;
        int rh14 = 15;
        rect(rx14, ry14, rw14, rh14);
    
    
        int rx141 = 390; 
        int ry141 = 85;
        int rw141 = 45;
        int rh141 = 15;
        rect(rx141, ry141, rw141, rh141);
    
    
        int rx15 = 390; 
        int ry15 = 150;
        int rw15 = 45;
        int rh15 = 45;
        rect(rx15, ry15, rw15, rh15);
    
    
        int rx16 = 700; 
        int ry16 = 100;
        int rw16 = 100;
        int rh16 = 100;
        rect(rx16, ry16, rw16, rh16);
    
    
        int rx17 = 500; 
        int ry17 = 250;
        int rw17 = 100;
        int rh17 = 40;
        rect(rx17, ry17, rw17, rh17);
    
    
        int rx18 = 525; 
        int ry18 = 350;
        int rw18 = 20;
        int rh18 = 20;
        rect(rx18, ry18, rw18, rh18);
    
    
        int rx181 = 545; 
        int ry181 = 370;
        int rw181 = 20;
        int rh181 = 20;
        rect(rx181, ry181, rw181, rh181);
    
        stroke(255, 1, 1);
        strokeWeight(1);
        for (Contour contour : opencv.findContours()) {
    
    
          println(contour.getBoundingBox().x);
          println(contour.getBoundingBox().y);
          int x = contour.getBoundingBox().x;
          int y = contour.getBoundingBox().y;
    
          contour.draw();
    
    
    
          if (( x > rx && x < rx + rw) && (y > ry && y < ry + rh)) {
            sendNote(0, 60);
          }
    
          if (( x > rx2 && x < rx2 + rw2) && (y > ry2 && y < ry2 + rh2)) {
            sendNote(0, 61);
          }
    
          if (( x > rx3 && x < rx3 + rw3) && (y > ry3 && y < ry3 + rh3)) {
            sendNote(0, 62);
          }
    
          if (( x > rx4 && x < rx4 + rw4) && (y > ry4 && y < ry4 + rh4)) {
            sendNote(1, 60);
          }
    
          if (( x > rx401 && x < rx401 + rw401) && (y > ry401 && y < ry401 + rh401)) {
            sendNote(1, 51);
          }
    
    
          if (( x > rx5 && x < rx5 + rw5) && (y > ry5 && y < ry5 + rh5)) {
            sendNote(1, 61);
          }
    
          if (( x > rx501 && x < rx501 + rw501) && (y > ry501 && y < ry501 + rh501)) {
            sendNote(0, 51);
          }
    
          if (( x > rx6 && x < rx6 + rw6) && (y > ry6 && y < ry6 + rh6)) {
            sendNote(1, 62);
          }
    
          if (( x > rx7 && x < rx7 + rw7) && (y > ry7 && y < ry7 + rh7)) {
            sendNote(1, 63);
          }
    
          if (( x > rx8 && x < rx8 + rw8) && (y > ry8 && y < ry8 + rh8)) {
            sendNote(1, 64);
          }
    
          if (( x > rx9 && x < rx9 + rw9) && (y > ry9 && y < ry9 + rh9)) {
            sendNote(1, 52);
          }
    
                if (( x > rx901 && x < rx901 + rw901) && (y > ry901 && y < ry901 + rh901)) {
            sendNote(1, 65);
          }
    
          if (( x > rx10 && x < rx10 + rw10) && (y > ry10 && y < ry10 + rh10)) {
            sendNote(1, 66);
          }
    
          if (( x > rx101 && x < rx101 + rw101) && (y > ry101 && y < ry101 + rh101)) {
            sendNote(1, 53);
          }
    
    
          if (( x > rx11 && x < rx11 + rw11) && (y > ry11 && y < ry11 + rh11)) {
            sendNote(1, 67);
          }
    
          if (( x > rx12 && x < rx12 + rw12) && (y > ry12 && y < ry12 + rh12)) {
            sendNote(1, 68);
          }
    
          if (( x > rx13 && x < rx13 + rw13) && (y > ry13 && y < ry13 + rh13)) {
            sendNote(1, 69);
          }
    
          if (( x > rx14 && x < rx14 + rw14) && (y > ry14 && y < ry14 + rh14)) {
            sendNote(1, 70);
          }
    
          if (( x > rx141 && x < rx141 + rw141) && (y > ry141 && y < ry141 + rh141)) {
            sendNote(1, 54);
          }
    
          if (( x > rx15 && x < rx15 + rw15) && (y > ry15 && y < ry15 + rh15)) {
            sendNote(0, 71);
          }
    
          if (( x > rx16 && x < rx16 + rw16) && (y > ry16 && y < ry16 + rh16)) {
            sendNote(1, 55);
          }
    
          if (( x > rx17 && x < rx17 + rw17) && (y > ry17 && y < ry17 + rh17)) {
            sendNote(0, 72);
          }
    
          if (( x > rx18 && x < rx18 + rw18) && (y > ry18 && y < ry18 + rh18)) {
            sendNote(1, 72);
          }
    
                if (( x > rx181 && x < rx181 + rw181) && (y > ry181 && y < ry181 + rh181)) {
            sendNote(1, 73);
          }
    
        }
      }
    }
    
  • Using IP-Capture library with IP-Webcam app on android

    to wiew the stream from IP Webcam app in your sketch, replace cam = new IPCapture(this, "192.168.1.9:8080", "", ""); //local ip for the ipwebcam cam.start(); with

    cam = new IPCapture(this); cam.start("http://192.168.1.9:8080/video", "", "");

    adapt the ip, username and password parameters as necessary to work with the settings of the IP Webcam server.

  • Night:Code
            import gab.opencv.*;
            import processing.video.*;
            import ipcapture.*;
            import org.opencv.core.Rect;
            import themidibus.*; //Import the library
    
    
            OpenCV opencv;
            IPCapture cam;
            MidiBus midi; 
    
            int lastMillis;
    
            int [][] timestamps = new int [16][128];
    
    
            void setup() {
              size(800, 450);
              for (int ch = 0; ch < 16; ch++) {
                for (int i = 0; i < 128; i++) {
                  timestamps[ch][i] = -1;
                }
              }
    
              cam = new IPCapture(this, "http://65.152.238.150:80/mjpg/video.mjpg?resolution=800x450", "", "");
              cam.start();
              opencv = new OpenCV(this, 800, 450);
    
              opencv.startBackgroundSubtraction(5, 3, 0.5);
              MidiBus.list();
              midi = new MidiBus(this, -1, "Bus 1");
            }
    
            void sendNote(int ch, int n) {
              if (timestamps[ch][n] == -1) {
                midi.sendNoteOn(ch, n, 100);
                timestamps[ch][n] = millis();
              }
            }
    
            void draw() {
    
              //check for overdue notes
              for (int ch = 0; ch < 16; ch++) {
                for (int i = 0; i < 128; i++) {
                  if (timestamps[ch][i]  > -1) {
                    if (millis()>timestamps[ch][i] +400) {
                      midi.sendNoteOff(ch, i, 100);
                      timestamps[ch][i] = -1;
                    }
                  }
                }
              }
    
              if (cam.isAvailable()) {
                cam.read();
                image(cam, 0, 0);  
                opencv.loadImage(cam);
                opencv.updateBackground();
    
                opencv.dilate();
                opencv.erode();
    
            //LINE COLOUR
    
                noFill();
                stroke(0, 0);
    
                strokeWeight(1);
    
                int rx = 580; 
                int ry = 15;
                int rw = 80;
                int rh = 70;
                rect(rx, ry, rw, rh);
    
                int rx2 = 40; 
                int ry2 = 140;
                int rw2 = 70;
                int rh2 = 120;
                rect(rx2, ry2, rw2, rh2);
    
    
                int rx3 = 500; 
                int ry3 = 190;
                int rw3 = 80;
                int rh3 = 40;
                rect(rx3, ry3, rw3, rh3);
    
    
                int rx4 = 200; 
                int ry4 = 50;
                int rw4 = 75;
                int rh4 = 150;
                rect(rx4, ry4, rw4, rh4);
    
                int rx401 = 275; 
                int ry401= 50;
                int rw401 = 75;
                int rh401 = 150;
                rect(rx401, ry401, rw401, rh401);
    
    
                int rx5 = 50; 
                int ry5 = 280;
                int rw5 = 80;
                int rh5 = 80;
                rect(rx5, ry5, rw5, rh5);
    
                int rx501 = 50; 
                int ry501 = 280;
                int rw501 = 80;
                int rh501 = 80;
                rect(rx501, ry501, rw501, rh501);
    
                int rx6 = 490; 
                int ry6 = 300;
                int rw6 = 100;
                int rh6 = 40;
                rect(rx6, ry6, rw6, rh6);
    
                int rx7 = 310; 
                int ry7 = 300;
                int rw7 = 100;
                int rh7 = 140;
                rect(rx7, ry7, rw7, rh7);
    
    
                int rx8 = 50; 
                int ry8 = 380;
                int rw8 = 90;
                int rh8 = 70;
                rect(rx8, ry8, rw8, rh8);
    
    
                int rx9 = 600; 
                int ry9 = 240;
                int rw9 = 25;
                int rh9 = 20;
                rect(rx9, ry9, rw9, rh9);
    
                int rx901 = 600; 
                int ry901 = 240;
                int rw901 = 25;
                int rh901 = 20;
                rect(rx901, ry901, rw901, rh901);
    
    
                int rx10 = 700; 
                int ry10 = 250;
                int rw10 = 35;
                int rh10 = 15;
                rect(rx10, ry10, rw10, rh10);
    
                int rx101 = 700; 
                int ry101 = 250;
                int rw101 = 90;
                int rh101 = 35;
                rect(rx101, ry101, rw101, rh101);
    
    
                int rx11 = 675; 
                int ry11 = 300;
                int rw11 = 55;
                int rh11 = 50;
                rect(rx11, ry11, rw11, rh11);
    
    
                int rx12 = 500; 
                int ry12 = 40;
                int rw12 = 45;
                int rh12 = 80;
                rect(rx12, ry12, rw12, rh12);
    
                int rx13 = 450; 
                int ry13 = 190;
                int rw13 = 45;
                int rh13 = 15;
                rect(rx13, ry13, rw13, rh13);
    
                int rx14 = 390; 
                int ry14 = 85;
                int rw14 = 45;
                int rh14 = 15;
                rect(rx14, ry14, rw14, rh14);
    
    
                int rx141 = 390; 
                int ry141 = 85;
                int rw141 = 45;
                int rh141 = 15;
                rect(rx141, ry141, rw141, rh141);
    
    
                int rx15 = 390; 
                int ry15 = 150;
                int rw15 = 45;
                int rh15 = 45;
                rect(rx15, ry15, rw15, rh15);
    
    
                int rx16 = 700; 
                int ry16 = 100;
                int rw16 = 100;
                int rh16 = 100;
                rect(rx16, ry16, rw16, rh16);
    
    
                int rx17 = 500; 
                int ry17 = 250;
                int rw17 = 100;
                int rh17 = 40;
                rect(rx17, ry17, rw17, rh17);
    
    
                int rx18 = 525; 
                int ry18 = 350;
                int rw18 = 20;
                int rh18 = 20;
                rect(rx18, ry18, rw18, rh18);
    
    
                int rx181 = 545; 
                int ry181 = 370;
                int rw181 = 20;
                int rh181 = 20;
                rect(rx181, ry181, rw181, rh181);
    
                stroke(255, 1, 1);
                strokeWeight(1);
                for (Contour contour : opencv.findContours()) {
    
    
                  println(contour.getBoundingBox().x);
                  println(contour.getBoundingBox().y);
                  int x = contour.getBoundingBox().x;
                  int y = contour.getBoundingBox().y;
    
                  contour.draw();
    
    
    
                  if (( x > rx && x < rx + rw) && (y > ry && y < ry + rh)) {
                    sendNote(0, 60);
                  }
    
                  if (( x > rx2 && x < rx2 + rw2) && (y > ry2 && y < ry2 + rh2)) {
                    sendNote(0, 61);
                  }
    
                  if (( x > rx3 && x < rx3 + rw3) && (y > ry3 && y < ry3 + rh3)) {
                    sendNote(0, 62);
                  }
    
                  if (( x > rx4 && x < rx4 + rw4) && (y > ry4 && y < ry4 + rh4)) {
                    sendNote(1, 60);
                  }
    
                  if (( x > rx401 && x < rx401 + rw401) && (y > ry401 && y < ry401 + rh401)) {
                    sendNote(1, 51);
                  }
    
    
                  if (( x > rx5 && x < rx5 + rw5) && (y > ry5 && y < ry5 + rh5)) {
                    sendNote(1, 61);
                  }
    
                  if (( x > rx501 && x < rx501 + rw501) && (y > ry501 && y < ry501 + rh501)) {
                    sendNote(0, 51);
                  }
    
                  if (( x > rx6 && x < rx6 + rw6) && (y > ry6 && y < ry6 + rh6)) {
                    sendNote(1, 62);
                  }
    
                  if (( x > rx7 && x < rx7 + rw7) && (y > ry7 && y < ry7 + rh7)) {
                    sendNote(1, 63);
                  }
    
                  if (( x > rx8 && x < rx8 + rw8) && (y > ry8 && y < ry8 + rh8)) {
                    sendNote(1, 64);
                  }
    
                  if (( x > rx9 && x < rx9 + rw9) && (y > ry9 && y < ry9 + rh9)) {
                    sendNote(1, 52);
                  }
    
                        if (( x > rx901 && x < rx901 + rw901) && (y > ry901 && y < ry901 + rh901)) {
                    sendNote(1, 65);
                  }
    
                  if (( x > rx10 && x < rx10 + rw10) && (y > ry10 && y < ry10 + rh10)) {
                    sendNote(1, 66);
                  }
    
                  if (( x > rx101 && x < rx101 + rw101) && (y > ry101 && y < ry101 + rh101)) {
                    sendNote(1, 53);
                  }
    
    
                  if (( x > rx11 && x < rx11 + rw11) && (y > ry11 && y < ry11 + rh11)) {
                    sendNote(1, 67);
                  }
    
                  if (( x > rx12 && x < rx12 + rw12) && (y > ry12 && y < ry12 + rh12)) {
                    sendNote(1, 68);
                  }
    
                  if (( x > rx13 && x < rx13 + rw13) && (y > ry13 && y < ry13 + rh13)) {
                    sendNote(1, 69);
                  }
    
                  if (( x > rx14 && x < rx14 + rw14) && (y > ry14 && y < ry14 + rh14)) {
                    sendNote(1, 70);
                  }
    
                  if (( x > rx141 && x < rx141 + rw141) && (y > ry141 && y < ry141 + rh141)) {
                    sendNote(1, 54);
                  }
    
                  if (( x > rx15 && x < rx15 + rw15) && (y > ry15 && y < ry15 + rh15)) {
                    sendNote(0, 71);
                  }
    
                  if (( x > rx16 && x < rx16 + rw16) && (y > ry16 && y < ry16 + rh16)) {
                    sendNote(1, 55);
                  }
    
                  if (( x > rx17 && x < rx17 + rw17) && (y > ry17 && y < ry17 + rh17)) {
                    sendNote(0, 72);
                  }
    
                  if (( x > rx18 && x < rx18 + rw18) && (y > ry18 && y < ry18 + rh18)) {
                    sendNote(1, 72);
                  }
    
                        if (( x > rx181 && x < rx181 + rw181) && (y > ry181 && y < ry181 + rh181)) {
                    sendNote(1, 73);
                  }
    
                }
              }
            }
    
  • How to connect IP camera with Processing?

    Hi. After 2 days, I know my problem. IP capture library only support MJPEG stream while my IP camera export h264 stream (I don't know exactly what it is but surely it's not MJPEG format).

    So for someone who may concern: Make sure your IP camera export MJPEG stream before try to connect it to Processing using IPCapture library.

  • How to connect IP camera with Processing?

    Hi everybody. I'm trying to connect Ip camera of VISTALINE with processing but I can not get live image in sketch. Console always shows: Unable to open I/O streams: Server returned HTTP response code: 502 for URL: http://192.168.0.129:80/axis-cgi/mjpg/video.cgi?resolution=320x240

    The code & IP configuration of camera are shown as pictures below:

    IPCapture cam;
    
    void setup() {
      size(320,240);
      cam = new IPCapture(this, "http://192.168.0.129:80/axis-cgi/mjpg/video.cgi?resolution=320x240", "admin", "admin");
      cam.start();
    
      // this works as well:
    
      // cam = new IPCapture(this);
      // cam.start("url", "username", "password");
    
      // It is possible to change the MJPEG stream by calling stop()
      // on a running camera, and then start() it with the new
      // url, username and password.
    }
    
    void draw() {
      if (cam.isAvailable()) {
        cam.read();
        image(cam,0,0);
      }
    }
    
    void keyPressed() {
      if (key == ' ') {
        if (cam.isAlive()) cam.stop();
        else cam.start();
      }
    }
    

    Capture1

    Anybody can help me,please?

  • Still getting lag when sending midi from Processing to Ableton.

    Hello all.

    So my code is now advancing but it's still laggy. It receives the data in Ableton but it's very temperamental. I've avoided using delay functions as it delays the entire thing. If anyone has any suggestions or can see any anomalies it would be much appreciated! Thank you :)

    import gab.opencv.*;
    import processing.video.*;
    import ipcapture.*;
    import org.opencv.core.Rect;
    import themidibus.*; //Import the library
    
    
    OpenCV opencv;
    IPCapture cam;
    MidiBus midi; 
    int lastMillis;
    int [] timestamps = new int [128];
    
    void setup() {
      size(640, 480);
      //video = new Movie(this, "street.mov"); MUTED
      cam = new IPCapture(this, "http://153.201.66.43:60001/mjpg/video.mjpg?resolution=640x480", "", "");
      cam.start();
      opencv = new OpenCV(this, 640, 480);
    
      opencv.startBackgroundSubtraction(5, 3, 0.5);
      MidiBus.list();
      midi = new MidiBus(this, -1, "Bus 1");
    
      //video.loop();
      //video.play();
    }
    
    void draw() {
      if (cam.isAvailable()) {
        cam.read();
        image(cam, 0, 0);  
        opencv.loadImage(cam);
        opencv.updateBackground();
    
        opencv.dilate();
        opencv.erode();
    
        noFill();
        stroke(255);
        strokeWeight(1);
    
        int rx = 300; 
        int ry = 150;
        int rw = 30;
        int rh = 15;
        rect(rx, ry, rx+rw, ry+rh);
    
        int rx2 = 10; 
        int ry2 = 10;
        int rw2 = 15;
        int rh2 = 15;
        rect(rx2, ry2, rx2+rw2, ry2+rh2);
    
    
        stroke(255, 0, 0);
        strokeWeight(10);
        for (Contour contour : opencv.findContours()) {
    
    
          println(contour.getBoundingBox().x);
          println(contour.getBoundingBox().y);
          int x = contour.getBoundingBox().x;
          int y = contour.getBoundingBox().y;
    
          contour.draw(); 
          {
    
            int [] numbers = new int [128];
    
            if (( x > rx && x < rx + rw) && (y > ry && y < ry + rh))
    
              for (int i = -1; i < timestamps.length; i++)
    
    
                midi.sendNoteOn(0, 62, 127);
    
            timestamps[62] = millis();
    
    
            if (millis()>lastMillis+40)
              midi.sendNoteOff(0, 62, 127);
    
            println(timestamps);
          }
        }
      }
    }
    
  • MIdi signal from Processing to Ableton is very glitchy, any ideas on how to help this issue?

    Hey all.

    Finally cracked my new project of triggering midi in Ableton via webcam movement but the midi signal is very glitchy and intermittent, despite my console telling me is it sending out signals. I feel it might be an issue with buffer size as when I'm sending a small amount of data, it works okay. Anything bigger and it glitches.

    If you need a screen recording of what is happening, let me know. Otherwise I've posted the code underneath. Thanks!

    import gab.opencv.*;
    import processing.video.*;
    import ipcapture.*;
    import org.opencv.core.Rect;
    import themidibus.*; //Import the library
    
    OpenCV opencv;
    IPCapture cam;
    MidiBus midi; 
    
    
    void setup() {
      size(640, 480);
      //video = new Movie(this, "street.mov"); MUTED
      cam = new IPCapture(this, "http://" + "100.38.83.153:8081/mjpg/video.mjpg?resolution=640x480", "", "");
      cam.start();
      opencv = new OpenCV(this, 640, 480);
    
      opencv.startBackgroundSubtraction(5, 3, 0.5);
      MidiBus.list();
      midi = new MidiBus(this, -1, "IAC Bus 1");
    
      //video.loop();
      //video.play();
    }
    
    void draw() {
      if (cam.isAvailable()) {
        cam.read();
        image(cam, 0, 0);  
        opencv.loadImage(cam);
        opencv.updateBackground();
    
        opencv.dilate();
        opencv.erode();
    
        noFill();
        stroke(255, 0, 0);
        strokeWeight(5);
        for (Contour contour : opencv.findContours()) {
    
    
          println(contour.getBoundingBox().x);
          println(contour.getBoundingBox().y);
          int x = contour.getBoundingBox().x;
          int y = contour.getBoundingBox().y;
    
          contour.draw();
    
          if ((x < 700) && (x > 650)) 
            println("x1");
          midi.sendNoteOn(0, 60, 127);
          midi.sendNoteOff(0, 60, 127);
    
          if ((x < 649) && (x > 600)) 
            println("x2");
          midi.sendNoteOn(0, 61, 127);
          midi.sendNoteOff(0, 61, 127);
    
    
          if ((x < 599) && (x > 550)) 
            println("x3");
          midi.sendNoteOn(0, 62, 127);
          midi.sendNoteOff(0, 62, 127);
    
          if ((x < 549) && (x > 500)) 
            println("x4");
          midi.sendNoteOn(0, 63, 127);
          midi.sendNoteOff(0, 63, 127);
    
    
          if ((x < 499) && (x > 450)) 
            println("x5");
          midi.sendNoteOn(0, 64, 127);
          midi.sendNoteOff(0, 64, 127);
    
          if ((x < 449) && (x > 400)) 
            println("x6");
          midi.sendNoteOn(0, 65, 127);
          midi.sendNoteOff(0, 65, 127);
    
          if ((x < 399) && (x > 350)) 
            println("x7");
          midi.sendNoteOn(0, 66, 127);
          midi.sendNoteOff(0, 66, 127);
    
    
          if ((x < 349) && (x > 300)) 
            println("x8");
          midi.sendNoteOn(0, 67, 127);
          midi.sendNoteOff(0, 67, 127);
    
          if ((x < 299) && (x > 250)) 
            println("x9");
          midi.sendNoteOn(0, 68, 127);
          midi.sendNoteOff(0, 68, 127);
    
          if ((x < 249) && (x > 200)) 
            println("x10");
          midi.sendNoteOn(0, 69, 127);
          midi.sendNoteOff(0, 69, 127);
    
    
          if ((x < 199) && (x > 150)) 
            println("x11");
          midi.sendNoteOn(0, 69, 127);
          midi.sendNoteOff(0, 69, 127);
    
          if ((x < 149) && (x > 100)) 
            println("x12");
          midi.sendNoteOn(0, 69, 127);
          midi.sendNoteOff(0, 69, 127);
    
          if ((x < 99) && (x > 50)) 
            println("X13");
          midi.sendNoteOn(0, 69, 127);
          midi.sendNoteOff(0, 69, 127);
    
          if ((x < 49) && (x > 1)) 
            println("x14");
          midi.sendNoteOn(0, 69, 127);
          midi.sendNoteOff(0, 69, 127);
    
    
          if ((y < 700) && (y > 650)) 
            println("y1");
          midi.sendNoteOn(1, 60, 127);
          midi.sendNoteOff(1, 60, 127);
    
          if ((y < 649) && (y > 600)) 
            println("x2");
          midi.sendNoteOn(1, 61, 127);
          midi.sendNoteOff(1, 61, 127);
    
    
          if ((y < 599) && (y > 550)) 
            println("y");
          midi.sendNoteOn(1, 62, 127);
          midi.sendNoteOff(1, 62, 127);
    
          if ((y < 549) && (y > 500)) 
            println("x4");
          midi.sendNoteOn(1, 63, 127);
          midi.sendNoteOff(1, 63, 127);
    
    
          if ((y < 499) && (y > 450)) 
            println("y5");
          midi.sendNoteOn(1, 64, 127);
          midi.sendNoteOff(1, 64, 127);
    
          if ((y < 449) && (y > 400)) 
            println("y6");
          midi.sendNoteOn(1, 65, 127);
          midi.sendNoteOff(1, 65, 127);
    
          if ((y < 399) && (y > 350)) 
            println("y7");
          midi.sendNoteOn(1, 66, 127);
          midi.sendNoteOff(1, 66, 127);
    
    
          if ((y < 349) && (y > 300))
            println("y8");
          midi.sendNoteOn(1, 67, 127);
          midi.sendNoteOff(1, 67, 127);
    
          if ((y < 299) && (y > 250)) 
            println("y9");
          midi.sendNoteOn(1, 68, 127);
          midi.sendNoteOff(1, 68, 127);
    
          if ((y < 249) && (y > 200)) 
            println("y10");
          midi.sendNoteOn(1, 69, 127);
          midi.sendNoteOff(1, 69, 127);
    
    
          if ((y < 199) && (y > 150)) 
            println("y11");
          midi.sendNoteOn(1, 69, 127);
          midi.sendNoteOff(1, 69, 127);
    
          if ((y < 149) && (y > 100)) 
            println("y12");
          midi.sendNoteOn(1, 69, 127);
          midi.sendNoteOff(1, 69, 127);
    
          if ((y < 99) && (y > 50)) 
            println("y13");
          midi.sendNoteOn(1, 69, 127);
          midi.sendNoteOff(1, 69, 127);
    
          if ((y < 49) && (y > 1)) 
            println("y14");
          midi.sendNoteOn(1, 69, 127);
          midi.sendNoteOff(1, 69, 127);
        }
    
    
    
        // void movieEvent(Movie m) {
        //  m.read();
      }
    }
    

    EDIT. Sorry, being stupid and can't get the code quoted properly! Edit 2, Got it ;)

  • How do I use the contour x y location data to send to a MidiBus

    Hello all.

    I'm currently trying to create a project where Processing reads movements from a webcam to send data to Ableton to trigger sound clips. I have managed to merge two sets of code and am now able to track movement (using IPcapture and OpenCV) but I am struggling to get find the correct code that will help deal with the x y data. I shall post the code I have done and what I want to add. Thank you!

    What I have:

    import themidibus.*;
    
    import gab.opencv.*;
    import processing.video.*;
    import ipcapture.*;
    import org.opencv.core.Rect;
    
    
    
    OpenCV opencv;
    IPCapture cam;
    
    
    void setup() {
      size(640, 480);
      //video = new Movie(this, "street.mov"); MUTED
      cam = new IPCapture(this, "http://153.201.66.43:60001/axis-cgi/mjpg/video.cgi?resolution=640x480", "", "");
      cam.start();
      opencv = new OpenCV(this, 640, 480);
    
      opencv.startBackgroundSubtraction(5, 3, 0.5);
    
      //video.loop();coun
      //video.play();
    }
    
    void draw() {
      if (cam.isAvailable()) {
        cam.read();
        image(cam, 0, 0);  
        opencv.loadImage(cam);
    
        opencv.updateBackground();
    
        opencv.dilate();
        opencv.erode();
    
        noFill();
        stroke(255, 0, 0);
        strokeWeight(10);
        for (Contour contour : opencv.findContours()) {
    
    
      print(contour.getBoundingBox());
          contour.draw();
    

    }

    What I want to add:

    void onGoLCellChange(boolean state, int x, int y) {
          //mapping from the GoL grid to MIDI messages
          int channel, note, velocity;
          if (y < 10) {
            channel = 0;
            note = x + 20;
            velocity = (y * 5) +30;
          } else {
            channel = 1;
            note = x + 40;
            velocity = y +30;
          }
    
    
          if (state == true) {
            midi.sendNoteOn(channel, note, velocity);
          } else {
            midi.sendNoteOff(channel, note, velocity);
          }
        }
    

    The second part is from the Game Of Life code. I have figured this is close to what I want but cannot get it to work. I have tried void onBoundingBox(boolean state, int x, int y) and void oncoutour(boolean state, int x, int y) { but keep getting error messages.

    Thank you for your time!

  • How to capture image or footage from an online webcam

    I have the answer now, using IPCapture. I now have a new question though that I am proposing. (I shall also construct my question so it isn't so vague lol) Thank you though!

  • How to use Processing 3 and the video capture library on Raspberry PI ?

    I have this code does not work

    import ipcapture.*;
    
    IPCapture cam;
    
    void setup() {
      size(640,480);
    
      cam = new IPCapture(this, "http://" + "192.168.1.101/index.html", "admin", "Muitas"); 
      cam.start();
    }
    
    void draw() {
      if (cam.isAvailable()) {
        cam.read();
        image(cam,0,0);
      }
    }
    
    void keyPressed() {
      if (key == ' ') {
        if (cam.isAlive()) cam.stop();
        else cam.start();
      }
    }
    
  • GSVideo and Processing 3 problem

    hi all , i have found this library that offer video capture and playbacks and other operations , i wanted to test it in processing 3 ,but every example i try to run on my android phone it crashes at start !! the thing is i need to capture video from ip camera , i tried the IPcapture library and every thing worked fine , but the problem the processing app resolution should be the same as the camera resolution for the app to work , else it will crash , i can't show the video on my phone full screen !! i couldn't know why is that happening , so i tried the GSVideo library i thought that this would fix the problem so i added the library on my processing 3 open example , exported the apk , installed it ,but the app crashes at start always

    this is the code i tried to run :

    import codeanticode.gsvideo.*;
    
    GSPipeline pipeline;
    
    void setup() {
      size(640, 480);
    
      pipeline = new GSPipeline(this, "https://192.168.0.105:8080/video");  
      pipeline.play();
    }
    
    void draw() {
      // When the GSPipeline.available() method returns true, 
      // it means that a new frame is ready to be read.
      if (pipeline.available()) {
        pipeline.read();
        image(pipeline, 0, 0);
      }
    }
    

    Note : Processing is V3 , the phone is galaxy s6 edge with android 7.0 and i use the latest version of GSvideo library

    i also tried to use apde on android to run the code , but no luck too , i got the following errors:

    java.lang.nosuchfielderror: no field title of type i in class codeanticode.gsvideo.GSVideo. (Unknown source)

    and many other errors !

    so please anyone can help me to make the library works with me ?! or anyone can help me to find alternative library to get video and ip camera stream from url .

    Kind regards

  • Using IP CAMERA with processing 3 (IPCapture)

    @kfrajer , thanks for replay , i also tried that , but still the same problem , i found that the resolution 176x144 works by chance !

    i can't tell where is the problem ?! is it in the IPCapture object or it is in the image() function ! really wired thing !

    did you used the same code ?! resolution ? and what version of sdk ?! please if there is any others ideas please tell me about it .

  • Using IP CAMERA with processing 3 (IPCapture)

    Update : it worked with me only when i changed the resolution (using size() function ) of the app window to 176x144 any idea why ?!

    My first question is how did you figure these these values?

    In the IP Webcam app, set the video preference >> video recording >> video format and choose mp4. In video preferences, choose your video resolution. Set this resolution in your sketch size. Then change your ip address in your Processing sketch to:

    cam = new IPCapture(this, "http://"+"192.168.0.10:8080/video", "", "");

    This was tested on Win 10 x64 and P3.3.5

    Kf

  • Using IP CAMERA with processing 3 (IPCapture)

    Please read the Update note below

    hi all , i want to receive video from ip camera , sadly i don't have ip camera , but what i have is old android device , so i installed an app called ip webcam for playstore : https://play.google.com/store/apps/details?id=com.pas.webcam&hl=en

    the app worked successfully and it started stream on port 8080 and i could receive the stream using the internet browser by typing the link it provided which is (for wireless lan): http://192.168.0.10:8080

    i tried to receive the ip camera stream over processing app using the IPCapture lib using the following code (i mean get the stream on another phone that have the processing app installed on )

    import ipcapture.*;
    
    IPCapture cam;
    
    void setup() {
      size(320,240);
      cam = new IPCapture(this, "http://"+"192.168.0.10:8080", "", "");
      cam.start();
    
      // this works as well:
    
      // cam = new IPCapture(this);
      // cam.start("url", "username", "password");
    
      // It is possible to change the MJPEG stream by calling stop()
      // on a running camera, and then start() it with the new
      // url, username and password.
    }
    
    void draw() {
      if (cam.isAvailable()) {
        cam.read();
        image(cam,0,0);
      }
    }
    
    void keyPressed() {
      if (key == ' ') {
        if (cam.isAlive()) cam.stop();
        else cam.start();
      }
    }
    

    but the app always crash at the start (it start with grey background when the stream camera is OFF ) which means the http stream is causing the problem , i also tried the other direct camera stream link the app provide (http://192.168.0.10:8080/video) and still the processing app crash at starting

    Update : it worked with me only when i changed the resolution (using size() function ) of the app window to 176x144 any idea why ?!

    please help me to get this work with processing cause i really need it for my project

    p.s: i only allowed the sketch permission for the internet as the lib site said . if there is any recommendation for any other android app that works fine please tell me about it . Kind regards

  • IPCapture code example crashes

    Thanks so much for reporting https://github.com/singintime/ipcapture/issues/4 -- I hope the library maintainer has a suggested solution....