2

I'm starting to play with Opencv. I am using the python bindings for opencv2 on Linux. I wrote a quick test program but it seems to hang indefinitely.

import cv2

weblink = "http://continuous-video-stream-here"
cv2.namedWindow("video")

vid = cv2.VideoCapture(weblink)
key = -1

while (key < 0):
    success, img = vid.read()
    cv2.imshow("video", img)

But it hangs on this output:

(video:14388): GStreamer-CRITICAL **: gst_caps_unref: assertion `caps != NULL' failed

I have also tried reading from urllib2:

vid = cv2.VideoCapture(urllib2.urlopen(weblink).read())

But that didn't work either.

I am using Opencv 2.4.2, ffmpeg-0.11.2

EDIT: The video feed uses realplayer to display the video over http in the browser.

user1695915
  • 87
  • 3
  • 6

1 Answers1

0

Code safely and test the return of the method:

vid = cv2.VideoCapture(weblink)
if not vid:
    print("!!! Failed VideoCapture: invalid parameter!")

The address you are using is probably not supported by OpenCV.

The same practice should be used whenever a method can fail:

while (key < 0):
    success, img = vid.read()
    if not img:
        print("!!! Failed vid.read()")
        break

    cv2.imshow("video", img)
karlphillip
  • 92,053
  • 36
  • 243
  • 426