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.
Related
I'm new to openCV and I'm using 3.4.1_5, C++ in Xcode on Mac. I used Homebrew to install opencv.
I'm following an openCV tutorial which is conducted in VS on Windows. Here's a link to the tutorial.
Basically, the tutorial shows how to create/resize a window, which is easy. So I have some code like this which is basically the same as in the tutorial:
#include "opencv2/opencv.hpp"
....
namedWindow("modi", CV_WINDOW_FREERATIO);
imshow("modi", modi);
resizeWindow("modi", modi.cols/2, modi.rows/2); //modi is a Mat
....
Supposedly, the image will be the same except it will be 1/4 of the original size and fit into the resized window. This is the case in the tutorial. However, it's not the case on my mac. My image stays the same size, and only the window shrinks to 1/4. If I drag the border of the window, the "covered" part of the image is revealed.
This actually poses a problem to my project later on, so I want to figure out why. I want to achieve what the tutorial achieves, and I've tried all window parameter, like AUTOSIZE, KEEPRATIO, OPENGL, etc. None of them worked. I'm thinking about if it's due to platform or version problem, but I have no way to test them.
Please help! Any hints would be greatly appreciated!
I have an embedded device where I use Qt 5.9 and Weston. Weston has to use fbdev backend (reasons out of scope) and needs
transform=90
in its output section, otherwise the screen is rotated. It runs fine, but I am unable to get a propper screen size in Qt. To run my application in fullscreen in Qt 5.8 I used:
auto geometry = QGuiApplication::screens().first()->geometry();
view.setGeometry(geometry);
and it was ok. With Qt 5.9 the screen reports its size transposed, so I would have to use
auto geometry = QGuiApplication::screens().first()->geometry();
geometry = geometry.transposed();
view.setGeometry(geometry);
This runs fine again, but the application is no longer portable. I use it on other platforms as well, all work without correctly without transposing.
Looking into the weston log I see
fbdev output 480×854 px
which corresponds to what I get in Qt now. But how to properly detect the rotation caused by transform=90?
Recently, I changed my PC and when I run the C++ program using OpenCV library inside Code::Blocks in Ubuntu 12.04, there is a message " init done, opengl support available" and the window shape of displaying the images is different from my previous PC with the same C++ program. I want to show two images in one window using opencv but the problem is that the quality of images are low and some times a part of one image is in the other image. I ran the exact program in my old PC and there was no problem at all. Would someone please help me with that? I also uploaded one image from the problem of displaying.
I am trying to write a simple program for taking photos from the webcam using Qt.
There is an example project in the Qt Creator, where QCamera is used to take photos and record video. But it is not working the right way. I can't get supported resolutions of the camera using method QCameraImageCapture::supportedResolutions(). A null QList object is returned, and camera is always capturing images with 640x480 resolutions.
OS is Ubuntu 11.04. Same problem occurs on Windows XP.
Can anyone help me?
I have answered nearly the same question.
https://stackoverflow.com/a/21140214/2452081
In short:
Portable solution can be gstreamer, but if Windows DirectShow solution is enough for you download my code from here
I am currently making an OpenCV project in C++ where I look for motion with a kinect and use that to cue a slideshow (sans recognition). Currently, I am displaying the slideshow using OpenCV (as I've only had about a week to whip this up). It looks good and its quick. The only problem is that this is going to be on display for a big production and I can't really afford to have the window showing (I'm talking window decorations like the title bar and such).
I need to get rid of the title bar. I've done a lot of research, and I have found out that you can magically grab the window handle by calling cvGetWindowHandle("SlideShow"), but that is a void function, so I don't really know how I am supposed to get a handle from that to manipulate.
I'm developing this for both windows AND ubuntu, since it will end up on a windows machine, but I can only demo on a laptop running ubuntu.
If anyone can tell me how to take the window and render it fullscreen with a resized image to fill most if not the entire screen in either Windows or Ubuntu, I will be forever grateful.
I am using OpenCV 2.1 on Ubuntu 11.04. On my system CV_WINDOW_FULLSCREEN and CV_WINDOW_AUTOSIZE flags both map to 1
And both flags behave exactly the same. They give you a fixed size window, which would be expected for AUTOSIZE flag but not the FULLSCREEN. I think these two flags are meant for different functions although their simillar appearance is very confusing. The flag CV_WINDOW_NORMAL maps to value 0 which is what you have used. It gives you a resizable window that you could maximize, but it is not a fullscreen window.
Edit: I just found the solution in another stachoverflow post. Here is the solution from that post which worked great on my system:
cvNamedWindow("Name", CV_WINDOW_NORMAL);
cvSetWindowProperty("Name", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
cvShowImage("Name", your_image);
I get a real fullscreen with no title bar etc.
you can use the cv::setWindowProperty function for your purpose, just set it to CV_WINDOW_FULLSCREEN.
Full documentation in the openCV-WIKI
In opencv/4.5.1, this is how it is done:
namedWindow("Name", WINDOW_NORMAL);
setWindowProperty ("Name", WND_PROP_FULLSCREEN, WINDOW_FULLSCREEN);
Assuming you have added using namespace cv;