我想在OpenCV的不同窗口中显示输出图像 [英] I want to display output image in different windows in OpenCV

查看:85
本文介绍了我想在OpenCV的不同窗口中显示输出图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在不同的窗口中多次显示相同的图像,为此我使用了for循环,但仅获得一个窗口显示.有人可以给我关于如何在多个窗口中显示输出图像的任何建议吗?以下是带有C API的OpenCV中的代码.在这里,我只是从argv [1]加载图像并尝试在4个不同的窗口中显示它.

I want to display the same image multiple times in different windows, for which I have used a for loop but I am getting only one window display. Can anybody provide me any suggestion on how to display output images in multiple windows? Following is the code in OpenCV with C API. Here, I am simply loading an image from argv[1] and trying to display it in 4 different windows.

#include "cv.h"
#include "highgui.h"
#include <stdlib.h>
#include <stdio.h>

int main( int argc, char** argv ) {
int i;
IplImage* img = cvLoadImage( argv[1],1);
cvMoveWindow("Example1", 100, 100);
cvNamedWindow( "Example1", 1);
for(i =0; i<=4;i++) // for loop to display the same image in 4 different windows
{
 cvShowImage( "Example1", img );
}
cvWaitKey(0);
cvReleaseImage( &img );
cvDestroyWindow( "Example1" );
}

P.S.我问过类似的问题在OpenCV的不同窗口中显示多个图像在此之前还没有解决,并且代码难以理解,所以我正在尝试使用更简单的代码来解决这个问题.

P.S. I have asked a similar question show multiple images in different window in OpenCV before which was not solved and the code was difficult to understand so I am trying this question with a simpler code.

推荐答案

去这里

int i;
IplImage* img = cvLoadImage("/home/khashayar/Downloads/bug14.png", 1);
cvMoveWindow("Example1", 100, 100);
cvNamedWindow("Example1", 1);
for (i = 0; i <= 4; i++) 
{
    char str[5] = "test";
    str[4] = i+48;
    cvShowImage(str, img);
}
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("Example1");

这篇关于我想在OpenCV的不同窗口中显示输出图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆