简体   繁体   中英

OpenCV cv::imshow() GUI not showing

I am trying to display an image, where it is crucial to be able to zoom in. On my Ubuntu Gnome 16.04 machine, the GUI always shows and the image is zoomable.

But on my Ubuntu 18.04 machine, the GUI never shows and is not zoomable. I've tried the following ways to create the Window:

cv::namedWindow("Name", CV_WINDOW_AUTOSIZE);
cv::namedWindow("Name", CV_GUI_NORMAL);
cv::namedWindow("Name", CV_GUI_EXTENDED);

using the cv::namedWindow() and the cvNamedWindow() commands. They all work on my 16.04 machine, yet none on my 18.04.

My OpenCV Version is 3.2 and I'm using it in a ROS workspace if that makes any differences.

I guess the flags you are using might be outdated. As in the documentation of OpenCV 3.2.0 , usable flags are as follows:

  • WINDOW_NORMAL or WINDOW_AUTOSIZE : WINDOW_NORMAL enables you to resize the window, whereas WINDOW_AUTOSIZE adjusts automatically the window size to fit the displayed image (see imshow ), and you cannot change the window size manually.

  • WINDOW_FREERATIO or WINDOW_KEEPRATIO : WINDOW_FREERATIO adjusts the image with no respect to its ratio, whereas WINDOW_KEEPRATIO keeps the image ratio.

These flags might work for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM