Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opencv - resizeWindow do nothing?

I tried some variations but it seem that resizeWindow don't do anything. I give simple code example,the result is that the 2 windows are in the same size , eventough it supposed to be in 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 work with eclipse-cdt on ubunto 12.04 with opencv 2.4.3.

  • I tried to debug it,getting into the the function but I don't succeed to add highGui modoul as external source, i get compile error of some h file missing.
like image 905
shanif Avatar asked Apr 09 '13 11:04

shanif


2 Answers

The following code snippet works for me:

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

"Only windows created without CV_WINDOW_AUTOSIZE flag can be resized."

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

like image 50
Luqman Avatar answered Nov 27 '22 04:11

Luqman


Make sure that OpenCV is installed with Qt backend support.

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

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.

...

Note: Qt backend supports additional flags: CV_WINDOW_NORMAL or CV_WINDOW_AUTOSIZE: CV_WINDOW_NORMAL enables you to resize the window, whereas CV_WINDOW_AUTOSIZE adjusts automatically the window size to fit the displayed image (see imshow() ), and you cannot change the window size manually.

It is likely that CV_WINDOW_AUTOSIZE is the only supported flag on your system. Documentation for resizeWindow says that only windows created without CV_WINDOW_AUTOSIZE flag can be resized. Your options are:

  • install OpenCV with Qt backend, or
  • use resize() function to resize the image before displaying it.
like image 24
Alexey Avatar answered Nov 27 '22 04:11

Alexey