如何显示窗口大小不同的输出图像?通过使用cv :: Mat [英] How can I Display output image with difference size of window? by using cv::Mat
问题描述
我想使用OpenCV功能在窗口上显示图像.但是,无论何时我尝试显示图像都将适合显示的大小.
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.
如果我要显示窗口大小不同的图像(例如,窗口大小1280x960px,图像在偏移坐标100x100px处为600x600px),我该如何制作它们?
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?
但是,根据上一个问题,我想使用cv :: Mat(C ++ API)我如何创建它们?
However, according to previous question I would like to use cv::Mat (C++ API) How cam I create them?
谢谢您的帮助.
推荐答案
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);
您在上一个问题中有答案.现在,如果您想进一步了解OpenCV,则必须阅读文档!
You had your answer in your previous question. Now if you want to get further with OpenCV, you have to read the Documentation!
这篇关于如何显示窗口大小不同的输出图像?通过使用cv :: Mat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!