📅  最后修改于: 2023-12-03 15:14:24.463000             🧑  作者: Mango
cv2.imshow
cv2.imshow
is a method in the OpenCV library that allows you to display images on the screen. It is a simple way to visualize your image processing results and debug your code.
cv2.imshow(window_name, image)
import cv2
img = cv2.imread("image.jpg")
# Create a window
cv2.namedWindow("Image", cv2.WINDOW_NORMAL)
# Display Image
cv2.imshow("Image", img)
# Wait for any key to be pressed
cv2.waitKey(0)
# Destroy all windows
cv2.destroyAllWindows()
The above code opens an image, creates a window for it, displays it, waits for any key to be pressed and then closes all the windows.
cv2.WINDOW_NORMAL
flag while creating the window.cv2.destroyAllWindows()
at the end of the program to release all resources.