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

Tagged:

Answers

  • Answer ✓

    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

  • @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 .

  • edited September 12

    hi again , will i tried the APDE app on android to create the apk and change the resolution to 1440x1080 and it worked without any problem !!! can anyone tell me what is going on ?! i really can't understand this !

    anyway , the only problem remains here is that i can't view the cam on full phone screen because the webcam app doesn't support my galaxy s6 resolution , i'm think of another solution which is , can i create a frame inside a frame (nested frames ) and then add my control buttons on the outer frame and cam in the inner frame ?! is that possible ?

    Kind regards

  • create a frame inside a frame

    Sure, use PGraphics. Check the reference.

    Kf

  • @kfrajer , i found that the problem is when the ipcamera resolution is different than the frame size the app crash at startup ,but when both are the same resolution everything works fine . So this may be a big problem because the app supports certain resolutions and i can't find one that support the phone full screen resolution ....

    So my question is , how to make the stream resolution cover the full phone screen resolution ?

    I tried to resize the cam image since it extends the PImage class ,but no luck!

    Kind regards to all .

Sign In or Register to comment.