前提・実現したいこと
WebカメラとOpenCVを用いて動画を撮影,保存したいのですが,VideoWrite_fourccが見つかりません,となってしまいます.
発生している問題
以下は公式のチュートリアルコードです.
Python2.7
1import numpy as np 2import cv2 3 4cap = cv2.VideoCapture(0) 5 6# Define the codec and create VideoWriter object 7fourcc = cv2.VideoWriter_fourcc(*'XVID') 8out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480)) 9 10while(cap.isOpened()): 11 ret, frame = cap.read() 12 if ret==True: 13 frame = cv2.flip(frame,0) 14 15 # write the flipped frame 16 out.write(frame) 17 18 cv2.imshow('frame',frame) 19 if cv2.waitKey(1) & 0xFF == ord('q'): 20 break 21 else: 22 break 23 24# Release everything if job is finished 25cap.release() 26out.release() 27cv2.destroyAllWindows()
ここで7行目VideoWrite_fourccでエラーが発生します.
PyCharmを使っているのですが,カーソルを合わせると次のようなエラー文があります.
Cannot find reference 'VideoWriter_fourcc' in 'init.py'
Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.
実行時のエラー文は次のようになります.
AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'
補足情報
Python 2.7.15
windows7 32bit
PyCharm 2018.2.4
OpenCV 2.4.9
薄々32bitマシンなのがいけない気がするのですが,それが原因ならどうしようもないのでしょうか.
何卒よろしくお願いします.
回答1件
あなたの回答
tips
プレビュー