I am using opencv 2 with a webcam. I can get the video stream and process it, but I can't seem to figure out a way to resize the display window. I have some video images stacked horizontally, but the image dimension is very small that it's difficult to see things.
My code is pretty simple, and along the lines of this:
cv2.namedWindow("main")
....
result = np.hstack((res2, foreground))
result = np.hstack((ff, result))
cv2.imshow("main", result)
cv2.waitKey(20)
The opencv documentation states:
namedWindow
flags – Flags of the window. Currently the only supported flag is CV_WINDOW_AUTOSIZE . If this is set, the window size is automatically adjusted to fit the displayed image (see imshow() ), and you cannot change the window size manually.
But qt backends apparently have extra flags. I don't have a qt backend. Is there a way for me to increase the size of the images so that I can see them?
The cv2. WINDOW_NORMAL option works correctly but the first time it displays the window in an standard size. If you resize the window like any other windows in your computer, by position the mouse over the edge of the window you want to resize and then drag the mouse to the position you want.
Yes, unfortunately you can't manually resize a nameWindow
window without Qt backend. Your options:
cv2.resize
function to resize the image to desired size prior to displaying the imagecv2.namedWindow("main", CV_WINDOW_NORMAL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With