osx - OpenCV Python Assertion failed error when playing .avi -
i beginning learn opencv , working through tutorials here: https://opencv24-python-tutorials.readthedocs.io/en/stable/py_tutorials/py_gui/py_video_display/py_video_display.html
this code i've written play sample video.
import numpy np import cv2 cap = cv2.videocapture('samples/vtest.avi') while (cap.isopened()): ret, frame = cap.read() gray = cv2.cvtcolor(frame, cv2.color_bgr2gray) cv2.imshow('frame', gray) if cv2.waitkey(1) & 0xff == ord('q'): break cap.release() cv2.destroyallwindows() this error message get:
opencv error: assertion failed (scn == 3 || scn == 4) in cvtcolor, file /tmp/opencv-20161020-7399-1yrk4nm/opencv-2.4.13.1/modules/imgproc/src/color.cpp, line 3739 traceback (most recent call last): file "vidfile_tutorial.py", line 14, in <module> gray = cv2.cvtcolor(frame, cv2.color_bgr2gray) cv2.error: /tmp/opencv-20161020-7399-1yrk4nm/opencv-2.4.13.1/modules/imgproc/src/color.cpp:3739: error: (-215) scn == 3 || scn == 4 in function cvtcolor i'm unsure problem assertion fail error since i've chosen file specified tutorial. moreover, when attempt play vtest.avi manually encounter codec error quicktime. therefore, suspect it's video codec issues opencv. i'm unsure if diagnosis correct , how go fixing it.
thanks in advance.
okay, i've managed resolve issue using opencv 3.1.0 rather 2.4.13.1.
with opencv 3.1.0 works fine.
Comments
Post a Comment