如何在媒体播放器(例如 MPV)中播放 opencv 帧?
我只是定义窗口并在此脚本中播放视频,但如何通过媒体播放器而不是 opencv 播放视频?理想情况下,我会进行图像处理并能够在 mpv 中实时查看它。
#!/usr/bin/python
from cv2 import cv2
def main():
def rescale_frame(frame, percent):
width = int(frame.shape[1] * percent / 100)
height = int(frame.shape[0] * percent / 100)
dim = (width, height)
return cv2.resize(frame, dim, interpolation=cv2.INTER_AREA)
cap = cv2.VideoCapture("test.webm")
while cap.isOpened():
ret, frame = cap.read()
rescaled = rescale_frame(frame, percent=50)
if ret is True:
cv2.imshow('Frame', rescaled)
if cv2.waitKey(25) & 0xFF == ord('q'):
break
else:
break
cap.release()
cv2.destroyAllWindows()
if __name__ == '__main__':
main()
I just define the window and play the video in this script, though how would I play the video through a media player instead of opencv? Ideally, I'd do my image processing and be able to view it in mpv in real time.
#!/usr/bin/python
from cv2 import cv2
def main():
def rescale_frame(frame, percent):
width = int(frame.shape[1] * percent / 100)
height = int(frame.shape[0] * percent / 100)
dim = (width, height)
return cv2.resize(frame, dim, interpolation=cv2.INTER_AREA)
cap = cv2.VideoCapture("test.webm")
while cap.isOpened():
ret, frame = cap.read()
rescaled = rescale_frame(frame, percent=50)
if ret is True:
cv2.imshow('Frame', rescaled)
if cv2.waitKey(25) & 0xFF == ord('q'):
break
else:
break
cap.release()
cv2.destroyAllWindows()
if __name__ == '__main__':
main()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论