OpenCV: resizing a window in a window to a displayed image

Is there a way to force the window displayed by OpenCV ( cv2.imshow() ) when displaying the image according to the width and height of the image without having to resize it with the mouse for this?

0
source share
1 answer

You need to pass CV_WINDOW_AUTOSIZE when creating 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) 
0
source

Source: https://habr.com/ru/post/1242213/


All Articles