我目前正在尝试为多处理的OpenCV视频流开发GUI.下面的代码确实成功地实现了这一点,因为它显示了视频源和“退出”按钮,但以奇怪的方式运行:
>程序在退出时(通过退出按钮或通过单击“X”关闭窗口)在pythonw.exe(我正在使用Windows)中引发运行时错误,说程序
“要求运行时以不寻常的方式终止”
任何关于如何解决这个问题的想法将不胜感激!
我的代码:
#!/usr/bin/python
import numpy as np
from multiprocessing import Process, Queue
from Queue import Empty
import cv2
import cv2.cv as cv
from PIL import Image, ImageTk
import time
import Tkinter as tk
#tkinter GUI functions----------------------------------------------------------
def quit_(root, process):
process.join()
root.destroy()
def update_image(image_label, queue):
frame = queue.get()
im = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
a = Image.fromarray(im)
b = ImageTk.PhotoImage(image=a)
image_label.configure(image=b)