OpenCV-Python是旨在解决计算机视觉问题的Python绑定库。cv2.imshow()
方法用于在窗口中显示图像。窗口自动适合图像尺寸。
用法: cv2.imshow(window_name, image)
参数:
window_name:一个字符串,代表要在其中显示图像的窗口的名称。
image:它是要显示的图像。
返回值:它不会返回任何内容。
用于以下所有示例的图像:
示例1:
# Python program to explain cv2.imshow() method
# importing cv2
import cv2
# path
path = r'C:\Users\Rajnish\Desktop\geeksforgeeks.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)
输出:
示例2:
# Python program to explain cv2.imshow() method
# importing cv2
import cv2
# path
path = r'C:\Users\Rajnish\Desktop\geeksforgeeks.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)
输出:
相关用法
- Python OpenCV cv2.imwrite()用法及代码示例
- Python OpenCV cv2.ellipse()用法及代码示例
- Python OpenCV cv2.putText()用法及代码示例
- Python OpenCV cv2.blur()用法及代码示例
- Python OpenCV cv2.rectangle()用法及代码示例
- Python OpenCV cv2.circle()用法及代码示例
- Python OpenCV cv2.line()用法及代码示例
- Python OpenCV cv2.erode()用法及代码示例
- Python OpenCV cv2.cvtColor()用法及代码示例
- Python OpenCV cv2.copyMakeBorder()用法及代码示例
- Python OpenCV cv2.arrowedLine()用法及代码示例
- Python OpenCV cv2.imread()用法及代码示例
注:本文由纯净天空筛选整理自Rajnis09大神的英文原创作品 Python OpenCV | cv2.imshow() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。