因此,opencv 3中的cap在CentOS中不起作用。 我在最初尝试的OSX或Windows 7中没有问题。 这是示例代码:
import cv2
cap = cv2.VideoCapture('/home/grad3/jalal/PycharmProjects/hw4_cs585/Concession_LAN_800k.mp4',cv2.CAP_FFMPEG)
if not cap.isOpened():
print('not opened')
while True:
ret,frame = cap.read()
if ret == False:
print('frame empty')
break
cv2.imshow('frame', frame)
if cv2.waitKey(1) == ord('q'):
break
我得到:
/usr/local/anaconda3/bin/python /home/grad3/jalal/PycharmProjects/hw4_cs585/test.py
not opened
frame empty
Process finished with exit code 0
我有opencv 3.1.0,这是一些系统信息。
$ uname -a
Linux goku.bu.edu 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
和
$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core
cv2. getBuildInformation()
General configuration for OpenCV 3.1.0 =====================================
Version control: unknown
Platform:
Host: