Home Fit zoomed image to window with OpenCV
Reply: 0

Fit zoomed image to window with OpenCV

schnarchnase
1#
schnarchnase Published in 2018-02-13 09:37:27Z

I am using OpenCV (3.3) with the Qt Backend as I want to use the integrated zoom functionality. Now I want to achieve that the zoomed image is fitted to the full window. At the moment the zoomed image is only shown in the area where the initial image was shown which is not optimal, at least when I use vertical images.

What is the best way to do this?

EDIT Example picture:

Full view

zoomed

In comparison to that the behavior of the standard Xubuntu image viewer. This is the behavior I want to achieve with OpenCV. The zoomed image fills the full window.

Full view image viewer

zoomed view image viewer


#include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

int annotate(string imageFilePath) {

    Mat img = imread(imageFilePath); 
    if (img.empty()) {
        cout << "Error loading image " << imageFilePath << endl;
        return 0;
    }
    namedWindow("AnnotationTool", cv::WINDOW_GUI_NORMAL);
    imshow("AnnotationTool", img);
    waitKey(0);
    return 0;
}

int main(int argc, char** argv) {

    if (argc != 2) {
        cout << "Usage: " << argv[0] << " <pathToImage>" << endl;
        return 0;
    }
    string pathToImage = argv[1];
    annotate(pathToImage);
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305632 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO