一个网友的问题:他的这个程序无法正确显示7个图片,只能显示第一张图片。
import tkinter as tk
import threading
import cv2
from PIL import Image, ImageTk
import time
import ctypes as ct
#img_TK=[]
class RunWorkThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.img=None
def run(self):
print("start")
i = 1
while i < 8:
image_path = str(i) + ".png" # 7张图片
print(image_path)
self.img=cv2.imread(image_path)
opencv_img_show_canvas(self.img,i)
i += 1
time.sleep(1)
print("end")
def opencv_img_show_canvas(opencv_img,i):
if len(opencv_img.shape) == 2: # 灰度图 or 二值图
img_cv = cv2.cvtColor(opencv_img, cv2.COLOR_GRAY2RGBA