参考OpenCV中文论坛的一个帖子(http://www.opencv.org.cn/forum/viewtopic.php?f=1&t=7996&start=0)实现了在一个窗口显示多个视频子窗口,能够读入单个的视频或摄像头数据,然后在一个窗口中分别显示原始帧图像、反色图像、灰度图像以及Canny边缘检测图像。并在每个子窗口左上角显示系统时间,函数cvShowManyImages是改写的。
代码如下:
#include "stdafx.h" #include <cv.h> #include <cxcore.h> #include <highgui.h> #include <stdio.h> #include <stdarg.h> #include <time.h> // 隐藏 console 窗口 #pragma comment( linker, "/subsystem:/"windows/" /entry:/"mainCRTStartup/"" ) // 单窗口显示多幅图像的函数 void cvShowMultiImages(char* title, int nArgs, ...) { // img - Used for getting the arguments IplImage* img; // DispImage - the image in which all the input images are to be copied IplImage* DispImage; int size; // size - the size of the images in the window int ind; // ind - the index of the image shown in the window int x, y; // x,y - the coordinate of top left coner of input images int w, h; // w,h - the width and height of the image // r - Maximum number of images in a column // c - Maximum number of images in a row int r, c; // scale - How much we have to resize the image float scale; // max - Max value of the width and height of the image int max; // space - the spacing between images int space; // If the number of arguments is lesser than 0 or greater than 12 // return without displaying if(nArgs <= 0) { printf("Number of arguments too small..../n"); return; } else if(nArgs >
OpenCV 实现单窗口多视频子窗口显示

本文介绍了如何使用OpenCV在一个窗口显示多个视频子窗口,展示原始帧、反色、灰度和Canny边缘检测图像,并在每个子窗口显示系统时间。关键点包括:在while循环中及时释放内存,正确使用cvReleaseImage和cvReleaseCapture,以及理解va_list等相关参数处理。
最低0.47元/天 解锁文章
3230





