OpenCVを使ってPythonで書かれたプログラムに問題があります。 私はXubuntu(16.04)、Python 3.6を使用しています。Python OpenCV:アサーションが失敗しました
これは私のコードです:
import cv2
import numpy as np
if __name__ == "__main__":
cap = cv2.VideoCapture('movie.mp4')
key = ord('a')
while key != ord('q'):
# Capture frame by frame
ret, frame = cap.read()
# Display the result of our processing
cv2.imshow('result', frame)
# Wait a little (30 ms) for a key press - this is required
# to refresh the image in our window
key = cv2.waitKey(30)
# When everytihnd done, releas the captyur and destroy created windows
cap.release()
cv2.destroyAllWindows
、これは私が受信したエラーです:
/home/xubuntu/anaconda3/bin/python "/home/xubuntu/PycharmProjects/untitled/lab1/zad7 wideo v2.py"
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/travis/miniconda/conda-bld/conda_1486587069159/work/opencv-3.1.0/modules/highgui/src/window.cpp, line 281
Traceback (most recent call last):
File "/home/xubuntu/PycharmProjects/untitled/lab1/zad7 wideo v2.py", line 13, in <module>
cv2.imshow('result', frame)
cv2.error: /home/travis/miniconda/conda-bld/conda_1486587069159/work/opencv-3.1.0/modules/highgui/src/window.cpp:281: error: (-215) size.width>0 && size.height>0 in function imshow
Process finished with exit code 1
を、私は同じコードは、Windows上で動作することを、追加したいと仮定します。 私を助けてもらえますか?
フレームはここでは空です。 'cv2.imshow( 'result'、frame)' – ZdaR
フレームは0x0フレーム(コンテンツはありません)のようです。 –
それは私が実際に今のものです。 Linuxでは動作しませんが、Windowsでは動作します。このファイルのアクセス許可を変更しようとしましたが、どちらもうまくいきませんでした。 – fafal