Python OpenCV 中的 resizeWindow() 方法用于将显示图像/视频的窗口调整为特定大小。指定的窗口大小适用于不包括工具栏的图像。这仅适用于具有除 CV_WINDOW_AUTOSIZE 以外的标志的已创建窗口。
用法:cv2.resizeWindow(window_name, width, height)
参数:
- window_name:将显示图像/视频的窗口的名称
- width:新窗口宽度(整数类型)
- height:新窗口高度(整数类型)
返回值:它不返回任何东西
用于以下示例的图像:
范例1:
Python3
# Python program to explain cv2.resizeWindow() method
# Importing cv2
import cv2
# Path
path = 'C:/Users/art/OneDrive/Desktop/geeks.png'
# Reading an image in default mode
image = cv2.imread(path)
# Naming a window
cv2.namedWindow("Resized_Window", cv2.WINDOW_NORMAL)
# Using resizeWindow()
cv2.resizeWindow("Resized_Window", 300, 700)
# Displaying the image
cv2.imshow("Resized_Window", image)
cv2.waitKey(0)
输出:
范例2:
Python3
# Python program to explain cv2.resizeWindow() method
# Importing cv2
import cv2
# Path
path = 'C:/Users/art/OneDrive/Desktop/geeks.png'
# Reading an image in grayscale mode
image = cv2.imread(path, 0)
# Naming a window
cv2.namedWindow("Resize", cv2.WINDOW_NORMAL)
# Using resizeWindow()
cv2.resizeWindow("Resize", 700, 200)
# Displaying the image
cv2.imshow("Resize", image)
cv2.waitKey(0)
输出:
相关用法
- Python OpenCV setWindowTitle()用法及代码示例
- Python OpenCV waitKey()用法及代码示例
- Python OpenCV waitKeyEx()用法及代码示例
- Python OpenCV getRotationMatrix2D()用法及代码示例
- Python OpenCV destroyAllWindows()用法及代码示例
- Python OpenCV namedWindow()用法及代码示例
- Python OpenCV selectroi()用法及代码示例
- Python OpenCV imdecode()用法及代码示例
- Python OpenCV getTrackbarPos()用法及代码示例
- Python OpenCV Filter2D()用法及代码示例
- Python OpenCV Canny()用法及代码示例
- Python OpenCV setTrackbarPos()用法及代码示例
- Python OpenCV getgaussiankernel()用法及代码示例
- Python OpenCV haveImageReader()用法及代码示例
注:本文由纯净天空筛选整理自vibhutijain99大神的英文原创作品 Python OpenCV – resizeWindow() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。