gpt4 book ai didi

c++ - 无法同时显示五个 Mat 图像(C++、OpenCV)

转载 作者:行者123 更新时间:2023-11-28 00:29:44 24 4
gpt4 key购买 nike

在下面的代码中,使用了一种方法来输入一个Mat图像并输出一个编辑好的Mat图像。代码工作正常,虽然我无法同时在屏幕上显示所有五个图像,因为运行代码时,只显示最后一个输出图像。理想情况下,代码应在同一窗口中显示每个输出图像的更小、按比例缩小的版本。

void method (Mat input)
{
...

imshow("Output", output);
}

int main()
{
img_1 = imread("img1.jpg");
img_2 = imread("img2.jpg");
img_3 = imread("img3.jpg");
img_4 = imread("img4.jpg");
img_5 = imread("img5.jpg");

method(img_1);
method(img_2);
method(img_3);
method(img_4);
method(img_5);

}

最佳答案

如果你想要多个 highgui 窗口,每个窗口都需要一个不同的名称:

void method (Mat input, const string & name)
{
...

imshow(name, output);
}

method(img_1, "image 1");
method(img_2, "image 2");
method(img_3, "image 3");
// ...

关于c++ - 无法同时显示五个 Mat 图像(C++、OpenCV),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23414148/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com