OpenCV: Auomatic resize of the window to the image displayed

女生的网名这么多〃 提交于 2019-12-11 11:23:37

问题


Is there a way to force the window displayed by OpenCV (cv2.imshow())when displaying an image to fit to the width and height of the image without the need to resize by the mouse it for that ?


回答1:


You need to pass CV_WINDOW_AUTOSIZE when creating the namedWindow (or WINDOW_AUTOSIZE if you import cv2 instead of cv)

Here is an example:

cv2.namedWindow("window", cv2.WINDOW_AUTOSIZE) 
# or cv.namedWindow("window",cv.CV_WINDOW_AUTOSIZE)
cv2.imshow("window", yourimage)


来源:https://stackoverflow.com/questions/28897880/opencv-auomatic-resize-of-the-window-to-the-image-displayed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!