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
}
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With