OpenCV的Python
是旨在解决计算机视觉问题的Python绑定库。 cv2.imshow()方法用于在窗口中显示图像。窗口自动适合图像尺寸。
语法:cv2.imshow(window_name, image)参数:window_name:字符串, 表示要在其中显示图像的窗口的名称。图像:这是要显示的图像。返回值:不返回任何内容。
用于以下所有示例的图像:
示例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()
输出如下:
示例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 DS课程。
评论前必须登录!
注册