ich eine lokale .avi
Dateien lesen und machen es shaw auf einem window.Here ist mein Code:get (cv2.CAP_PROP_FOURCC) return Fehler mit OpenCV und Python
import os,cv2
user=os.path.expanduser('~')
capture=cv2.VideoCapture(str(user)+"/Downloads/vehicle/Sunny/april21.avi")
if(capture.isOpened()):
print "Open"
else:
print "Fail to open!"
fps=capture.get(cv2.CAP_PROP_FPS)
fourcc=capture.get(cv2.CAP_PROP_FOURCC)
print fourcc#why fourcc is return 0.0?
print "fps:%d"%fps
size=(int(capture.get(cv2.CAP_PROP_FRAME_WIDTH))/2,
(int)(capture.get(cv2.CAP_PROP_FRAME_HEIGHT))/2
)
isStop=1
while isStop:
grabbed,frame=capture.read()#frame is None
cv2.namedWindow("window")
img=cv2.resize(frame,size,interpolation=cv2.INTER_CUBIC)
cv2.imshow("window",img)
c=0xFF&cv2.waitKey(1)
if c ==27:
isStop=False
cv2.destroyAllWindows()
Aber jetzt ist das Ergebnis:
Open
0.0
fps:29
OpenCV Error: Assertion failed (ssize.area() > 0) in resize, file /Users/tom/opencv-3.1.0/modules/imgproc/src/imgwarp.cpp, line 3229
Traceback (most recent call last):
File "/Users/tom/Documents/readVideo.py", line 20, in <module>
img=cv2.resize(frame,size,interpolation=cv2.INTER_CUBIC)
cv2.error: /Users/tom/opencv-3.1.0/modules/imgproc/src/imgwarp.cpp:3229: error: (-215) ssize.area() > 0 in function resize
Das einzige, was ich sicher bin, ist dieser Codes richtig ist, weil ich eine .avi
Dateien durch cv2.VideoWriter
erstellt habe und es kann gelesen und in einem Fenster angezeigt. Danke für die Antwort.