Reputation: 274
According to How can I display output image with difference size of window?
I would like to display an image on window using OpenCV function. However, anytime that I tried to display image will be fit to the size of display.
If I would like to display an image with difference size of window (for example. window size 1280x960px, and an image is 600x600px at offset coordinate 100x100px) How can I make them?
However, according to previous question I would like to use cv::Mat (C++ API) How cam I create them?
Thank you for your help.
Upvotes: 1
Views: 2113
Reputation: 3988
cv::Mat smallImage = cv::imread("myimage.jpg");
cv::Mat bigWindow = cv::Mat::zeros(960,1280, smallImage.type());
cv::Rect r(0,0,smallImage.cols, smallImage.rows);
cv::Mat roi = bigWindow(r);
smallImage.copyTo(roi);
cv::namedWindow("Display"); // cv::namedWindow("Display", 0); if you want to be able to resize window
cv::imshow("Display", bigWindow);
cv::waitKey(0);
You had your answer in your previous question. Now if you want to get further with OpenCV, you have to read the Documentation!
Upvotes: 1