Ask Your Question
1

OpenCV CV_WINDOW_KEEPRATIO doesn't work

asked 2015-05-28 08:07:11 -0600

Giraphant gravatar image

Hi everyone,

When I try to display image inside window it won't keep ratio when resized manually

namedWindow(WINDOW_NAME, CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED);
imshow(WINDOW_NAME, image);

effect will be something like this

image description

This problem was already described here by some other person http://code.opencv.org/issues/3800, unfortunately some time passed by but the problem still exists. Does anyone knows how it can be fixed?

OpenCV: 3.0 RC1 Qt: 5.4.1 GCC: 4.9.2 OS: Xubuntu 15.04

edit retag flag offensive close merge delete

Comments

This seems to be fixed as of OpenCV 3.1.0 with Qt 5.7.0 on Windows 7. It is still present in OpenCV 2.4.13.

kaveish gravatar imagekaveish ( 2016-07-21 08:33:40 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-04-20 10:15:02 -0600

Had the same effect, OpenCV 2.4.13, Debian Testing, KDE5 Plasma, Qt 5.7.1

For me I found two possible solutions:

  1. when compiling OpenCV, use cmake switch -DWITH_QT=4 (works even on Debian testing system with KDE5, but needs libqt4-dev package)
  2. modify .../opencv-2.4.13/modules/highgui/src/window_QT.cpp : search for resize(newSize); and insert the following line after it: viewport()->resize(newSize);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-05-28 08:07:11 -0600

Seen: 3,319 times

Last updated: May 28 '15