Opencv - resizeWindow do nothing?

I tried several options, but it seems that resizeWindow does nothing. I give a simple code example, the result is that 2 windows are the same size, while it should be of different sizes.

Mat m = imread("somePath",CV_LOAD_IMAGE_COLOR); namedWindow("aa",CV_WINDOW_NORMAL); namedWindow("bb",CV_WINDOW_NORMAL); imshow("aa",m); imshow("bb",m); resizeWindow("aa",400,400); resizeWindow("bb",800,800); waitKey(0); 

I am working with eclipse-cdt on ubunto 12.04 with opencv 2.4.3.

  • I tried to debug it by hitting a function, but I was not able to add highGui modoul as an external source, I get a compilation error for some h file.
+4
source share
3 answers

The following code snippet works for me:

 namedWindow("Final", 0); resizeWindow("Final", 500,500); 

"Only windows created without the CV_WINDOW_AUTOSIZE flag can be changed."

REF: http://docs.opencv.org/modules/highgui/doc/user_interface.html#resizewindow

+4
source

Make sure OpenCV is installed with Qt support.

Quote from the documentation namedWindow() (emphasis mine):

flags - window flags. Currently only supported flag is supported. CV_WINDOW_AUTOSIZE . If this option is set, the window size is automatic (see imshow ()), and you cannot resize the window manually.

...

Note. The Qt byte supports additional flags: CV_WINDOW_NORMAL or CV_WINDOW_AUTOSIZE : CV_WINDOW_NORMAL allows you to resize the window, then CV_WINDOW_AUTOSIZE automatically adjusts the window size to (see imshow ()), and you cannot manually resize the window.

It is likely that CV_WINDOW_AUTOSIZE is the only supported flag on your system. The documentation for resizeWindow states that you can only resize those created on Windows without CV_WINDOW_AUTOSIZE . Your options:

  • install OpenCV with the Qt backend or
  • use the resize() function to resize the image before displaying it.
+3
source

I also had this problem, on the bottom line there are OpenCV windows with a minimum size, and both of the windows you are trying to create fall below it. I'm pretty sure that your image areas are also cropped, possibly with gray or other dummy information.

+1
source

All Articles