在 python 中闪烁图像的有效方法
Efficient way of flashing images in python
在 python 中最有效的闪烁图像的方式是什么?
目前我有一个无限循环,最后调用睡眠,然后使用 matplotlib 显示图像。但是我无法让 matplotlib 替换当前图像,我不得不关闭然后再次显示,这很慢。我想以设定的频率尽可能精确地闪烁图像序列。
我愿意接受使用其他库进行就地替换的解决方案。
使用 openCV,您可以使用它来遍历图像并显示它们
for img in images:
# Show the image (will replace previously displayed images
# with the same title)
cv2.imshow('window title', img)
# Wait 1000ms before showing the next image and if the user
# pressed 'q', close the window and stop looping through the dataset
if cv2.waitKey(1000) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break
使用名为 PsychoPy 的库。它可以保证绘制所有内容,并允许您使用 window.frame() 函数控制何时绘制 window(一帧)。
在 python 中最有效的闪烁图像的方式是什么?
目前我有一个无限循环,最后调用睡眠,然后使用 matplotlib 显示图像。但是我无法让 matplotlib 替换当前图像,我不得不关闭然后再次显示,这很慢。我想以设定的频率尽可能精确地闪烁图像序列。
我愿意接受使用其他库进行就地替换的解决方案。
使用 openCV,您可以使用它来遍历图像并显示它们
for img in images:
# Show the image (will replace previously displayed images
# with the same title)
cv2.imshow('window title', img)
# Wait 1000ms before showing the next image and if the user
# pressed 'q', close the window and stop looping through the dataset
if cv2.waitKey(1000) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break
使用名为 PsychoPy 的库。它可以保证绘制所有内容,并允许您使用 window.frame() 函数控制何时绘制 window(一帧)。