📜  Python OpenCV – destroyWindow()函数

📅  最后修改于: 2022-05-13 01:54:50.328000             🧑  作者: Mango

Python OpenCV – destroyWindow()函数

Python Opencv destroyWindow()函数用于关闭特定窗口。此函数采用一个参数,即您要关闭或销毁的窗口名称,它不返回任何内容。

destroyWindow()函数– 示例

在此示例中,我们将读取一张图像并创建它的多个窗口。然后我们将使用 destroyWindow()函数销毁任何特定的窗口。

Python3
# import cv2 library
import cv2
  
# Read an image
img = cv2.imread("Documents/Image3.jpg",
                 cv2.IMREAD_COLOR)
  
# create two windows of images and 
# give different window name to each
cv2.imshow("I1", img)
cv2.imshow("I2", img)
  
# we will wait for user to press any key
cv2.waitKey(0)
  
# after user pressed any key only 'I2' named
# window will be closed and another image
# remains as it is.
cv2.destroyWindow("I2")


输出: