Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Reading video stream from IP camera in OpenCV Java

I'm working towards an advanced motion detection plugin for openHab.org using OpenCV Java, and need to be able to read a video stream directly from an IP camera, preferably an h.264 stream.

I have found out how to do the with a webcam, but an IP camera is a very different problem. I would prefer not to store video to a file and read from the file to keep delays at a bare minimum (unless that's the only solution).

How is this best accomplished in OpenCV Java?

click to hide/show revision 2
retagged

updated 2013-11-16 07:04:18 -0600

berak gravatar image

Reading video stream from IP camera in OpenCV Java

I'm working towards an advanced motion detection plugin for openHab.org using OpenCV Java, and need to be able to read a video stream directly from an IP camera, preferably an h.264 stream.

I have found out how to do the with a webcam, but an IP camera is a very different problem. I would prefer not to store video to a file and read from the file to keep delays at a bare minimum (unless that's the only solution).

How is this best accomplished in OpenCV Java?

Reading video stream from IP camera in OpenCV Java

I'm working towards an advanced motion detection plugin for openHab.org using OpenCV Java, and need to be able to read a video stream directly from an IP camera, preferably an h.264 stream.

I have found out how to do the with a webcam, but an IP camera is a very different problem. I would prefer not to store video to a file and read from the file to keep delays at a bare minimum (unless that's the only solution).

How is this best accomplished in OpenCV Java?

Based on a suggestion by Haris below; I tried;

 VideoCapture capture = new VideoCapture();
    capture.open("http://192.168.0.156/view/viewer_index.shtml?id=87");

The results are; Exception in thread "main" java.lang.UnsatisfiedLinkError:
org.opencv.highgui.VideoCapture.VideoCapture_0()J at
org.opencv.highgui.VideoCapture.VideoCapture_0(Native Method) at org.opencv.highgui.VideoCapture.<init>(VideoCapture.java:101) at
org.openhab.action.videoanalytics.MotionDetect.main(MotionDetect.java:24)

Am I simply declaring it improperly, or is there a better way?

click to hide/show revision 4
Tried 2 potential fixes, though have not solved the problem

Reading video stream from IP camera in OpenCV Java

I'm working towards an advanced motion detection plugin for openHab.org using OpenCV Java, and need to be able to read a video stream directly from an IP camera, preferably an h.264 stream.

I have found out how to do the with a webcam, but an IP camera is a very different problem. I would prefer not to store video to a file and read from the file to keep delays at a bare minimum (unless that's the only solution).

How is this best accomplished in OpenCV Java?

Based on a suggestion by Haris below; I tried;

 VideoCapture capture = new VideoCapture();
    capture.open("http://192.168.0.156/view/viewer_index.shtml?id=87");

The results are; Exception in thread "main" java.lang.UnsatisfiedLinkError:
org.opencv.highgui.VideoCapture.VideoCapture_0()J at
org.opencv.highgui.VideoCapture.VideoCapture_0(Native Method) at org.opencv.highgui.VideoCapture.<init>(VideoCapture.java:101) at
org.openhab.action.videoanalytics.MotionDetect.main(MotionDetect.java:24)

Per Alexander Smorkalov's suggestion, I updated to 2.4.7.

Now when I execute;

*VideoCapture capture = new VideoCapture();

it throws a ClassNotFoundException, even though it checks out perfectly in Eclipse.

I even combined statements with;

VideoCapture capture = new VideoCapture("http://192.168.0.156/view/viewer_index.shtml?id=87");

But still get the same exception.

Am I simply declaring it improperly, or is there a better way?way? @Berak has said that this is not yet fully implemented in the baselined code, so do I need to report this as a bug?

Please bear with me, I'm new here and returning to Java programming after 12 years away from hands-on coding.

click to hide/show revision 5
Updated the 2 suggested fixes

Reading video stream from IP camera in OpenCV Java

I'm working towards an advanced motion detection plugin for openHab.org using OpenCV Java, and need to be able to read a video stream directly from an IP camera, preferably an h.264 stream.

I have found out how to do the with a webcam, but an IP camera is a very different problem. I would prefer not to store video to a file and read from the file to keep delays at a bare minimum (unless that's the only solution).

How is this best accomplished in OpenCV Java?

Based on a suggestion by Haris below; I tried;

 VideoCapture capture = new VideoCapture();
    capture.open("http://192.168.0.156/view/viewer_index.shtml?id=87");
capture.open("http://192.168.0.156/view/viewer_index.shtml?id=87&dummyparam=dummy.mjpg");

The results are; Exception in thread "main" java.lang.UnsatisfiedLinkError:
org.opencv.highgui.VideoCapture.VideoCapture_0()J at
org.opencv.highgui.VideoCapture.VideoCapture_0(Native Method) at org.opencv.highgui.VideoCapture.<init>(VideoCapture.java:101) at
org.openhab.action.videoanalytics.MotionDetect.main(MotionDetect.java:24)

Per Alexander Smorkalov's suggestion, I updated to 2.4.7.

Now when I execute;

*VideoCapture capture = new VideoCapture();

it throws a ClassNotFoundException, even though it checks out perfectly in Eclipse.

I even combined statements with;

VideoCapture capture = new VideoCapture("http://192.168.0.156/view/viewer_index.shtml?id=87");
VideoCapture("http://192.168.0.156/view/viewer_index.shtml?id=87&dummyparam=dummy.mjpg");

But still get the same exception.

Am I simply declaring it improperly, or is there a better way? @Berak has said that this is not yet fully implemented in the baselined code, so do I need to report this as a bug?

Please bear with me, I'm new here and returning to Java programming after 12 years away from hands-on coding.

Reading video stream from IP camera in OpenCV Java

I'm working towards an advanced motion detection plugin for openHab.org using OpenCV Java, and need to be able to read a video stream directly from an IP camera, preferably an h.264 stream.

I have found out how to do the with a webcam, but an IP camera is a very different problem. I would prefer not to store video to a file and read from the file to keep delays at a bare minimum (unless that's the only solution).

How is this best accomplished in OpenCV Java?

Based on a suggestion by Haris below; I tried;

 VideoCapture capture = new VideoCapture();
    capture.open("http://192.168.0.156/view/viewer_index.shtml?id=87&dummyparam=dummy.mjpg");

The results are; Exception in thread "main" java.lang.UnsatisfiedLinkError:
org.opencv.highgui.VideoCapture.VideoCapture_0()J at
org.opencv.highgui.VideoCapture.VideoCapture_0(Native Method) at org.opencv.highgui.VideoCapture.<init>(VideoCapture.java:101) at
org.openhab.action.videoanalytics.MotionDetect.main(MotionDetect.java:24)

Per Alexander Smorkalov's suggestion, I updated to 2.4.7.

Now when I execute;

*VideoCapture capture = new VideoCapture();

it throws a ClassNotFoundException, even though it checks out perfectly in Eclipse.

I even combined statements with;

VideoCapture capture = new VideoCapture("http://192.168.0.156/view/viewer_index.shtml?id=87&dummyparam=dummy.mjpg");

it seems to behave, with no errors thrown. I'm using Eclipse as my dev/debug environment, so I'm stepping through (and into many) lines of code with it's debugger.

The following line results in 'true' (and prints out the text), which implies that the VideoCapture connection has been opened;

if (capture.isOpened()) {
    System.out.println("Video is captured");}

But still get the same exception.there is nothing there when I go to grab frames from the mjpeg feed;

Inside the C++ VideoCapture class is a 'grab()' operation that is returning 'false';

boolean retVal = grab_0(nativeObj);

And then this error message appears;

GStreamer Plugin: Embedded video playback halted; module decodebin20 reported: Your GStreamer installation is missing a plug-in.

I went to Ubuntu Software Center, did a search on GStreamer and came up with this list of plugins, which are all installed on my system;

GStreamer FFMPEG video plugin, GStreamer extra plugins GStreamer plugins for mms, wavpak, quicktime, musepack GStreamer plugins for aas, xvid, mpeg2, faad

So I went to Synaptic to see what GStreamer plugins where loaded or available. I must say I was rather stunned by the long list, and have not been able to determine which plugin I'm missing. I'm including a screenshot of the list (and there are a few more past the end of the screenshot);

C:\fakepath\GStreamerPlugInList.png

Am I simply declaring it improperly, or is there a better way? @Berak has said that this is not yet fully implemented in the baselined code, so do I need to report this as a bug?

Please bear with me, I'm new here and returning to Java programming after 12 years away from hands-on coding.