Connect to public IP camera in Java

asked 2015-12-11 10:58:12 -0500

JTrejo gravatar image

I'm trying to connect to a public IP camera (http://iris.not.iac.es/axis-cgi/mjpg/...) in Java by using the following:

import org.opencv.core.Core;
import org.opencv.videoio.VideoCapture;

public class Main
{
    public static void main(String[] args)
    {
        System.out.println("Welcome to OpenCV " + Core.VERSION);
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        VideoCapture ip_cam = new VideoCapture();

        ip_cam.open("http://iris.not.iac.es/axis-cgi/mjpg/video.cgi?resolution=320x240");

        if (!ip_cam.isOpened())
        {
            System.out.print("Error while trying to open the webcam");
            return;
        }


        System.out.println("Success!");

        ip_cam.release();
    }
}

However, it refuses to open. It doesn't throws any error messages nor anything. I've tried running it as admin, downgrading from OpenCV 3.0.0 to 2.4.11, trying to connect to a different IP camera.. nothing. Since it's such a simple program I just can't figure out what's wrong.

I'm using OpenCV 3.0.0, Eclipse Mars 1 4.5.1 and Win7 64bits.

edit retag flag offensive close merge delete

Comments

1

Check this answer here: http://answers.opencv.org/question/13... ... I quickly tried with appending "?x.mjpeg" to your url and it worked (x can be anything). Although I don't know why, so I'm just adding that as comment.

RolandC gravatar imageRolandC ( 2015-12-12 02:48:35 -0500 )edit