如何使用 opencv python 定期更新图像的 plot window?
How to update plot window of image using opencv python at certain regular interval?
我有一组图像,它们由另一个 python 脚本 "image_generator.py" 以某种速率动态生成。我想动态显示这些图像。有什么方法可以让我用 "image_generator.py"?
新生成的图像更新我的图像图
image_generator.py
import numpy
def generate(height, width, channels):
img = numpy.random.rand(height, width, channels)
img = (255*img).astype(numpy.uint8)
return img
example.py
import cv2
from image_generator import generate
n_images = 20
height = 200
width = 200
channels = 3
for n in range(n_images):
img = generate(height, width, channels)
cv2.imshow('Random image', img)
k = cv2.waitKey(200)
if k == ord('q') & 0xFF:
break
请注意,这与它们在同一个 Python 文件中没有什么不同。从另一个模块导入后,您可以访问位于 Python 脚本中的函数。
我有一组图像,它们由另一个 python 脚本 "image_generator.py" 以某种速率动态生成。我想动态显示这些图像。有什么方法可以让我用 "image_generator.py"?
新生成的图像更新我的图像图image_generator.py
import numpy
def generate(height, width, channels):
img = numpy.random.rand(height, width, channels)
img = (255*img).astype(numpy.uint8)
return img
example.py
import cv2
from image_generator import generate
n_images = 20
height = 200
width = 200
channels = 3
for n in range(n_images):
img = generate(height, width, channels)
cv2.imshow('Random image', img)
k = cv2.waitKey(200)
if k == ord('q') & 0xFF:
break
请注意,这与它们在同一个 Python 文件中没有什么不同。从另一个模块导入后,您可以访问位于 Python 脚本中的函数。