如何从视频调整帧大小,然后检索最终大小?

我想读取一个视频文件,将其分成单独的帧,将每个帧的大小调整为最大宽度,然后检索最终图像的宽度和高度。


我试过这个:


为真:


vs = cv2.VideoCapture(args["video"])

# grab the frame from the threaded video stream and resize it

# to have a maximum width of 400 pixels

frame = vs.read()

frame = imutils.resize(frame, width=400)


# grab the frame dimensions and convert it to a blob

w, h = cv.GetSize(frame)

但我得到:


Traceback (most recent call last):

  File "real_time_object_detection.py", line 52, in <module>

    frame = imutils.resize(frame, width=400)

  File "/home/pi/.virtualenvs/cv/lib/python3.5/site-packages/imutils/convenience.py", line 69, in resize

    (h, w) = image.shape[:2]

AttributeError: 'tuple' object has no attribute 'shape'

为什么它会抱怨一行imutils/?我该怎么做?


大话西游666
浏览 218回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python