Ask Your Question
0

How to handle OpenCV warnings?

asked 2018-09-28 05:22:37 -0600

akmalhakimi1919 gravatar image

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... (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:857)

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-09-28 05:46:13 -0600

berak gravatar image

it does not throw an exception here, so you can't catch one.

you'll have to check:

if cam.isOpened():
    # proceed..
edit flag offensive delete link more

Comments

I"ve tried isOpened() but it didn't work with IP address. It still shows the warnings.

akmalhakimi1919 gravatar imageakmalhakimi1919 ( 2018-09-30 22:27:14 -0600 )edit

Okay it actually works. Just had to wait few seconds for it to come out

akmalhakimi1919 gravatar imageakmalhakimi1919 ( 2018-09-30 22:39:06 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-09-28 05:22:37 -0600

Seen: 2,206 times

Last updated: Sep 28 '18