gpt4 book ai didi

python - Opencv-Python cv2.CV_CAP_PROP_FPS错误

转载 作者:太空狗 更新时间:2023-10-29 17:56:40 27 4
gpt4 key购买 nike

我目前使用的是 opencv 3.2.0 和 python 3.5.2。执行以下代码时:

videoCapture = cv2.VideoCapture(file_path)
fps = videoCapture.get(cv2.CV_CAP_PROP_FPS)
size = (int(videoCapture.get(cv2.CV_CAP_PROP_FRAME_WIDTH)),
int(videoCapture.get(cv2.CV_CAP_PROP_FRAME_HEIGHT)))

我遇到了以下错误:

Traceback (most recent call last):
File "videoEditor.py", line 29, in <module>
fps = videoCapture.get(cv2.CV_CAP_PROP_FPS)
AttributeError: module 'cv2.cv2' has no attribute 'CV_CAP_PROP_FPS'

谁能告诉我应该怎么做?

最佳答案

在 OpenCV 3.2 中,将 CV 放在标志前面。这应该可以正常工作

videoCapture = cv2.VideoCapture(file_path)
fps = videoCapture.get(cv2.CAP_PROP_FPS)
size = (int(videoCapture.get(cv2.CAP_PROP_FRAME_WIDTH)),
int(videoCapture.get(cv2.CAP_PROP_FRAME_HEIGHT)))

关于python - Opencv-Python cv2.CV_CAP_PROP_FPS错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45215755/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com