Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to handle OpenCV warnings?

I've tried to make an error handler if a user provided invalid URL for an IP Cam.

try:
    cam = cv2.VideoCapture(user_config.CAMERA_IP)
except Exception, e:
    print "Unable to access camera"

However, OpenCV outputs a warning instead of error

warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:856) warning: http://admin:[email protected]:80/video.cgi (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:857)

so it didn't get captured. Is there a way to handle this warning?