OpenCV的Python
是旨在解决计算机视觉问题的Python绑定库。 cv2.imshow()方法用于在窗口中显示图像。窗口自动适合图像尺寸。
语法:cv2.imshow(window_name, image)参数:window_name:字符串, 表示要在其中显示图像的窗口的名称。图像:这是要显示的图像。返回值:不返回任何内容。
用于以下所有示例的图像:
![Python OpenCV | cv2.imshow()方法1](http://www.srcmini02.com/wp-content/uploads/2021/04/geeks14.png)
示例1:
# Python program to explain cv2.imshow() method
# importing cv2
import cv2
# path
path = r 'C:\Users\Rajnish\Desktop\srcmini.png'
# Reading an image in default mode
image = cv2.imread(path)
# Window name in which image is displayed
window_name = 'image'
# Using cv2.imshow() method
# Displaying the image
cv2.imshow(window_name, image)
#waits for user to press any key
#(this is necessary to avoid Python kernel form crashing)
cv2.waitKey( 0 )
#closing all open windows
cv2.destroyAllWindows()
输出如下:
![Python OpenCV | cv2.imshow()方法2](http://www.srcmini02.com/wp-content/uploads/2021/04/Annotation-2019-08-02-022111.png)
示例2:
# Python program to explain cv2.imshow() method
# importing cv2
import cv2
# path
path = r 'C:\Users\Rajnish\Desktop\srcmini.png'
# Reading an image in grayscale mode
image = cv2.imread(path, 0 )
# Window name in which image is displayed
window_name = 'image'
# Using cv2.imshow() method
# Displaying the image
cv2.imshow(window_name, image)
# waits for user to press any key
# (this is necessary to avoid Python kernel form crashing)
cv2.waitKey( 0 )
# closing all open windows
cv2.destroyAllWindows()
输出如下:
![Python OpenCV | cv2.imshow()方法3](http://www.srcmini02.com/wp-content/uploads/2021/04/Annotation-2019-08-02-022133.png)
首先, 你的面试准备可通过以下方式增强你的数据结构概念:Python DS课程。
来源:
https://www.srcmini02.com/70261.html