Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fitting an image to screen using imshow opencv

Tags:

I want to display an image using opencv on Mac os X 13'. The image size is 1920 × 1080. When I run this code, I see just a part of an image. I need to fit the image to the screen.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include "opencv2/opencv.hpp"
#include<string.h>
using namespace cv;
using namespace std;

int main()
{
   Mat image=imread("/Users/rafikgouiaa/Qt/projects/MakeVideo/build-MakeVideo-    Desktop_Qt_5_0_2_clang_64bit-Debug/im.jpg");
   namedWindow( "Display frame",CV_WINDOW_AUTOSIZE);
   imshow("Display frame", image);
   waitKey(0);
   return 0
}
like image 403
LearnToGrow Avatar asked Jul 19 '14 16:07

LearnToGrow


People also ask

How do I increase the size of my cv2 window?

The cv2. WINDOW_NORMAL option works correctly but the first time it displays the window in an standard size. If you resize the window like any other windows in your computer, by position the mouse over the edge of the window you want to resize and then drag the mouse to the position you want.


1 Answers

If you need to show an image that is bigger than the screen resolution, you will need to call

namedWindow("Display frame", WINDOW_NORMAL)

before the imshow.

To set desirable size of the window call please

cv::resizeWindow("Display frame", WIDTH, HEIGHT);

For more details see http://docs.opencv.org/modules/highgui/doc/user_interface.html#imshow

like image 187
Temak Avatar answered Sep 18 '22 14:09

Temak