OpenCV:自动调整窗口大小以显示图像 [英] OpenCV: Auomatic resize of the window to the image displayed

查看:1671
本文介绍了OpenCV:自动调整窗口大小以显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当显示图像以适合图像的宽度和高度时,是否有一种方法可以强制OpenCV(cv2.imshow())显示的窗口,而无需通过鼠标来调整其大小?

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 ?

推荐答案

您需要传递 CV_WINDOW_AUTOSIZE 在创建namedWindow时(如果导入cv2而不是cv,则为WINDOW_AUTOSIZE)

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

这里是一个例子:

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

这篇关于OpenCV:自动调整窗口大小以显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆