如何通过单击右上角的X图标关闭OpenCV窗口?

时间:2019-06-28 16:54:07

标签: python opencv ubuntu

我想通过单击窗口右上角的关闭按钮来关闭我的OpenCV窗口。希望你能理解这张照片

image

这是我编写的代码

import cv2
import numpy as np
import pyzbar.pyzbar as pyzbar

cap = cv2.VideoCapture(0)
font = cv2.FONT_HERSHEY_PLAIN
while True:
    _, frame = cap.read()

    decodedObjects = pyzbar.decode(frame)
    for obj in decodedObjects:
        print("Data", obj.data)
        cv2.putText(frame, str(obj.data), (60, 60),font,3,(255,0,0), 3)

    cv2.imshow("Frame", frame)

    key = cv2.waitKey(1)

    if key == 27:

        cv2.destroyWindow("Frame")
        break

请帮助我

0 个答案:

没有答案