显示在OpenCV的不同窗口的多个图像 [英] show multiple images in different window in OpenCV

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

问题描述

我想在不同的窗口中分别在OpenCV中与C API显示多个图像。以下是我的code,在那里我做了一个循环多次显示相同的画面,直到循环旋转。谁能告诉我为什么我的code是只显示第一张图像后崩溃?以下是我的code for循环:

 为(X = 0; X< = 5; X ++)
{     * IplImage的DST = cvCreateImage(cvSize(src->宽度,src->高度),src->深度上,3);
     的IplImage * dstRGB [3];     的for(int i = 0;我3;;我++)
     {
         RGB [I] = cvCreateImage(cvSize(src->宽度,src->高度),src->深度,1);
         dstRGB [I] = cvCreateImage(cvSize(src->宽度,src->高度),src->深度,1);
     }     cvSplit(源,RGB [0],RGB [1],RGB [2],NULL);     的for(int i = 0;我3;;我++)
     {
         cvFilter2D(RGB [I],dstRGB [I],RGB2);
     }     cvReleaseMat(安培; RGB2);
     cvMerge(dstRGB [0],dstRGB [1],dstRGB [2],NULL,DST);     cvNamedWindow(DST,1);
     cvShowImage(DST,DST);     //cvSaveImage(\"output.png,DST);     cvReleaseImage(安培; DST);     的for(int i = 0;我3;;我++)
     {
         cvReleaseImage(安培; RGB [I]);
         cvReleaseImage(安培; dstRGB [I]);
     }     cvWaitKey(0);
     } // for循环结束     cvReleaseImage(放大器; SRC);     cvDestroyWindow(的argv [5]);
     cvDestroyWindow(DST);

以下是它显示在显示第一图像后的误差

  OpenCV的错误:断言失败(anchor.inside(矩形(0,0,ksize.width,ksize.height)))在normalizeAnchor,文件/home/Documents/opencv-2.4 0.5 /发行/模块/ imgproc / precomp.hpp,行90投'简历::异常'是什么()的一个实例后终止叫:/home/ocuments/opencv-2.4.5/release/modules/ imgproc / precomp.hpp:90:错误:(-215)anchor.inside(矩形(0,0,ksize.width,ksize.height))的函数normalizeAnchor中止(核心转储)


解决方案

您可能要开始修理你的主循环

 为(X = 0; X = 5; X ++)

可能成

 为(X = 0;!x = 5; X ++)

由于它是,它是一个无端环

I want to display multiple images in different windows separately in OpenCV with C API. Following is my code, where I have done a for loop to show the same image multiple times until the loop rotates. Can anybody tell me why my code is crashing after showing only the first image? Following is my code for loop:

for(x = 0; x <= 5;x++)
{ 

     IplImage* dst = cvCreateImage(cvSize(src->width, src->height), src->depth, 3);
     IplImage* dstRGB[3];

     for (int i = 0; i < 3; i++)
     {
         rgb[i] = cvCreateImage(cvSize(src->width, src->height), src->depth, 1);
         dstRGB[i] = cvCreateImage(cvSize(src->width, src->height), src->depth, 1);
     }

     cvSplit(src, rgb[0], rgb[1], rgb[2], NULL);

     for (int i = 0; i < 3; i++)
     {
         cvFilter2D(rgb[i], dstRGB[i], rgb2);
     }

     cvReleaseMat(&rgb2);
     cvMerge(dstRGB[0], dstRGB[1], dstRGB[2], NULL, dst);

     cvNamedWindow("dst", 1);
     cvShowImage("dst", dst);

     //cvSaveImage("output.png", dst); 

     cvReleaseImage(&dst);

     for (int i = 0; i < 3; i++)
     {
         cvReleaseImage(&rgb[i]);
         cvReleaseImage(&dstRGB[i]);
     }

     cvWaitKey(0);
     } // for loop ends

     cvReleaseImage(&src);

     cvDestroyWindow(argv[5]);
     cvDestroyWindow("dst");

Following is the error it shows after displaying the first image

   OpenCV Error: Assertion failed (anchor.inside(Rect(0, 0, ksize.width, ksize.height))) in normalizeAnchor, file /home/Documents/opencv-2.4.5/release/modules/imgproc/precomp.hpp, line 90 terminate called after throwing an instance of 'cv::Exception' what():  /home/ocuments/opencv-2.4.5/release/modules/imgproc/precomp.hpp:90: error: (-215) anchor.inside(Rect(0, 0, ksize.width, ksize.height)) in function normalizeAnchor Aborted (core dumped)

解决方案

You may want to start fixing your main loop

for(x = 0; x = 5;x++)

possibly into

for(x = 0; x != 5; x++)

As it is, it is an endless loop

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

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