如何实时处理图像并输出结果的实时视频?

如何实时处理图像并输出结果的实时视频?,第1张

如何实时处理图像并输出结果的实时视频?

您可能需要看一下这个问题:使用直接使用VideoCapture的实时摄像机预览来更新matplotlib中的帧。相反,如果您想从http中读取图像,则可以将其更改为以下内容之一。

互动模式

import cv2import matplotlib.pyplot as pltdef grab_frame():    image = io.imread('http://[ip-address]/cam_pic.php')    image_gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)    faces = detect(image_gray)    return faces_draw(image, faces)#create axesax1 = plt.subplot(111)#create image plotim1 = ax1.imshow(grab_frame())plt.ion()while True:    im1.set_data(grab_frame())    plt.pause(0.2)plt.ioff() # due to infinite loop, this gets never called.plt.show()

功能动画

import cv2import matplotlib.pyplot as pltfrom matplotlib.animation import FuncAnimationdef grab_frame():    image = io.imread('http://[ip-address]/cam_pic.php')    image_gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)    faces = detect(image_gray)    return faces_draw(image, faces)#create axesax1 = plt.subplot(111)#create axesim1 = ax1.imshow(grab_frame())def update(i):    im1.set_data(grab_frame())ani = FuncAnimation(plt.gcf(), update, interval=200)plt.show()


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5668387.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存