程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

为什么 cv2.imshow('windowName',frame) 在 python 中不显示视频剪辑?

发布于2023-11-18 10:22     阅读(1195)     评论(0)     点赞(27)     收藏(5)


我用 Python 编写了一段代码,可以从文件中读取视频剪辑并将其显示在窗口中。但剪辑不显示在窗口中。窗口打开但不显示任何内容。当然,在while循环中,例如我捕获2000帧时,该帧显示成功。代码片段如下:

import cv2

# capture WMV format clip from a file
videoCapture = cv2.VideoCapture('clipWMV.wmv')

# getting fps of the captured video from its file
fps = videoCapture.get(cv2.CAP_PROP_FPS)
print('fps=', fps) # 25.0

# getting size of the captured video from its file
size = (int(videoCapture.get(cv2.CAP_PROP_FRAME_WIDTH)), int(videoCapture.get(cv2.CAP_PROP_FRAME_HEIGHT)))
print('size=', size) # (400, 226)

# define a window to showing the clip
cv2.namedWindow('clipWindow')

# reading captured video frames
success, frame = videoCapture.read()

while success:  # Loop until there are no more frames
    cv2.imshow('clipWindow', frame)
    success, frame = videoCapture.read()

cv2.destroyWindow('clipWindow')

问题是什么?谢谢您的指导。


解决方案


暂无回答



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:https://www.pythonheidong.com/blog/article/2039592/e44152aa78af649bb2d0/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

27 0
收藏该文
已收藏

评论内容:(最多支持255个字符)