Ask Your Question

Revision history [back]

Using opencv to open a IP Cam http stream on Windows

I wrote the following Python code:

import cv2

cap = cv2.VideoCapture()
cap.open("http://<user>:<password>@<ip>/mjpeg.cgi?user=<user>&password=<password&channel=0")

while (cap.isOpened()):
    ret, frame = cap.read()
    cv2.imshow('frame', frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

The code works fine on Linux, but on Windows, I got the following error:

$ python renderer.py
warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:808)
warning: http://<user>:<password>@<ip>/mjpeg.cgi?user=<user>&password=<password&channel=0 (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:809)

I suspect there's something wrong with my Windows opencv build, but couldn't figure out what. Please let me know if you have any ideas. Thanks.