#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <stdarg.h>
#include <time.h> void cvShowManyImages(char* title, int nArgs, ...){
IplImage *img;
IplImage *DispImage;
int size;
int i;
int m, n; int x, y;
int w, h;
// scale - How much we have to resize the image
float scale;
int max;
// If the number of arguments is lesser than 0 or greater than 12
// return without displaying
w = ; h = ;
size = ;
/**
if(nArgs <= 0) {
printf("Number of arguments too small....\n");
return;
}
else if(nArgs > 12) {
printf("Number of arguments too small....\n");
return;
}
// Determine the size of the image,
// and the number of rows/cols
// from number of arguments
else if (nArgs == 1) {
w = h = 1;
size = 300;
}
else if (nArgs == 2) {
w = 2; h = 1;
size = 300;
}
else if (nArgs == 3 || nArgs == 4) {
w = 2; h = 2;
size = 300;
}
else if (nArgs == 5 || nArgs == 6) {
w = 3; h = 2;
size = 200;
}
else if (nArgs == 7 || nArgs == 8) {
w = 4; h = 2;
size = 200;
}
else {
w = 4; h = 3;
size = 150;
}
*/
// Create a new 3 channel image
DispImage = cvCreateImage( cvSize( + size*w, + size*h), , );
// Used to get the arguments passed
va_list args;
va_start(args, nArgs);
// Loop for nArgs number of arguments
// for (i = 0, m = 20, n = 20; i < nArgs; i++, m += (20 + size)) {
for (i = , m = , n = ; i < nArgs; i++, m += ( + size)) {
// Get the Pointer to the IplImage
img = va_arg(args, IplImage*);
// Check whether it is NULL or not
// If it is NULL, release the image, and return
if(img == ) {
printf("Invalid arguments");
cvReleaseImage(&DispImage);
return;
}
// Find the width and height of the image
x = img->width;
y = img->height;
// Find whether height or width is greater in order to resize the image
max = (x > y)? x: y;
// Find the scaling factor to resize the image
scale = (float) ( (float) max / size );
// Used to Align the images
if( i % w == && m!= ) {
m = ;
n+= + size;
}
// Set the image ROI to display the current image
cvSetImageROI(DispImage, cvRect(m, n, (int)( x/scale ), (int)( y/scale )));
// Resize the input image and copy the it to the Single Big Image
cvResize(img, DispImage);
// Reset the ROI in order to display the next image
cvResetImageROI(DispImage);
}
// Create a new window, and show the Single Big Image
//cvNamedWindow( title, 1 );
cvShowImage( title, DispImage);
/*cvWaitKey(0);*/
//cvDestroyWindow(title);
// End the number of arguments
va_end(args);
// Release the Image Memory
cvReleaseImage(&DispImage);
}
int main(int argc,char **argv)
{
CvCapture *capture;
// int i=0; capture=cvCreateFileCapture("E:\\Videos\\xx.avi"); IplImage *frame;
cvNamedWindow("video",);
cvResizeWindow("video",,);
//CvFont timeFont,timeFont1;
// cvInitFont(&timeFont,CV_FONT_HERSHEY_COMPLEX,0.5f,0.5f,0,1,8);
// cvInitFont(&timeFont1,CV_FONT_HERSHEY_COMPLEX,0.5f,0.5f,0,1,8);
// char time1[25];
// memset(time1,0,25*sizeof(char));
while ()
{
frame=cvQueryFrame( capture );
if (!frame)
{
break;
}
/**
IplImage *frame_not=cvCreateImage(cvGetSize(frame),frame->depth,frame->nChannels);
cvNot(frame,frame_not);
*/
// time_t rawtime;
// struct tm * timeinfo;
// time ( &rawtime );
// timeinfo = localtime ( &rawtime ); // char *p=asctime(timeinfo);
//数组p的第25个字符为'\n',在图像上显示时为乱码,这里取其前24个字符显示在图像上 /** for (i=0;i<24;i++)
{
time1[i]=*p;
p++;
}
p=NULL;
*/
IplImage *frame_gray=cvCreateImage(cvGetSize(frame),frame->depth,);
IplImage *frame1=cvCreateImage(cvGetSize(frame),frame->depth,frame->nChannels);
IplImage *frame_canny=cvCreateImage(cvGetSize(frame),frame->depth,);
IplImage *frame2=cvCreateImage(cvGetSize(frame),frame->depth,frame->nChannels);
cvCvtColor(frame,frame_gray,CV_RGB2GRAY);
cvCvtColor(frame_gray,frame1,CV_GRAY2BGR);
cvCanny(frame_gray,frame_canny,,,);
cvCvtColor(frame_canny,frame2,CV_GRAY2BGR);
// cvPutText(frame,time1,cvPoint(0,15),&timeFont,CV_RGB(255,0,0));
//cvPutText(frame1,time1,cvPoint(0,15),&timeFont,CV_RGB(255,0,0));
// cvPutText(frame2,time1,cvPoint(0,15),&timeFont1,CV_RGB(255,0,0));
// cvPutText(frame_not,time1,cvPoint(0,15),&timeFont1,CV_RGB(255,0,0));
// cvShowManyImages("video",4,frame,frame_not,frame1,frame2);
cvShowManyImages("video",,frame,frame1,frame2);
cvWaitKey();
// cvReleaseImage(&frame_not);
cvReleaseImage(&frame1);
cvReleaseImage(&frame_gray);
cvReleaseImage(&frame2);
cvReleaseImage(&frame_canny); }
cvDestroyWindow("video");
cvReleaseCapture(&capture);
return ;
}

转载自:http://www.opencv.org.cn/forum.php?mod=viewthread&tid=7996&extra=&page=1

在一个窗口中显示多个视频,并在每个子窗口左上角显示系统时间,函数cvShowManyImages是改写的的更多相关文章

  1. .NET/C# 在代码中测量代码执行耗时的建议(比较系统性能计数器和系统时间)

    我们有很多种方法评估一个方法的执行耗时,比如使用性能分析工具,使用基准性能测试.不过传统的在代码中编写计时的方式依然有效,因为它可以生产环境或用户端得到真实环境下的执行耗时. 如果你希望在 .NET/ ...

  2. 通过使用浏览器对象模型,输出当前浏览器窗口中打开的文档的URL信息,并将显示在窗口中。

    <script type="text/javascript">window.document.write("这个网页文件来自:".bold());w ...

  3. 透明窗口(窗口上面文字图片等内容不透明)的实现(使用SetLayeredWindowAttributes API函数)

    透明窗口(窗口上面文字图片等内容不透明)的实现 本文讨论通过SetLayeredWindowAttributes来实现本文的目的. SetLayeredWindowAttributes的实现必须将窗口 ...

  4. 【推荐】PHP中格式化时间函数date与gmdate的区别 | 修改PHP的默认时区

    PHP中的时间有2个格式化函数:date()和gmdate(),在官方的文档中的描述为: date -- 格式化一个本地时间/日期 gmdate -- 格式化一个 GMT/UTC 日期/时间,返回的是 ...

  5. Talend 将Oracle中数据导入到hive中,根据系统时间设置hive分区字段

    首先,概览下任务图: 流程是,先用tHDFSDelete将hdfs上的文件删除掉,然后将oracle中的机构表中的数据导入到HDFS中:建立hive连接->hive建表->tJava获取系 ...

  6. 从视频文件中读入数据-->将数据转换为灰度图-->对图像做canny边缘检测-->将这三个结构显示在一个图像中

    //从视频文件中读入数据-->将数据转换为灰度图-->对图像做canny边缘检测-->将这三个结构显示在一个图像中 //作者:sandy //时间:2015-10-10 #inclu ...

  7. 将图片在指定窗口中显示-OpenCV应用学习笔记一

    1.OpenCV模块划分 OpenCV其实就是一堆用C和C++语言来实现计算机视觉算法的源代码文件:例如C接口函数cvCany()实现了Canny边缘提取算法,我们可以直接将这些源代码添加到自己的软件 ...

  8. SharePoint Iframe 报错“此内容不能显示在一个框架中”

    问题描述 我们SharePoint站点用Excel Service发布的Excel,需要Iframe到其他系统中,但是,Iframe的时候发现报错“此内容不能显示在一个框架中”. 后来,尝试在其他系统 ...

  9. mysql数据库导出模型到powerdesigner,PDM图形窗口中显示数据列的中文注释

    1,mysql数据库导出模型到powerdesigner 2,CRL+Shift+X 3,复制以下内容,执行 '******************************************** ...

随机推荐

  1. IE 下加载jQuery

    转:http://www.iitshare.com/ie8-not-use-native-json.html 解决在IE8中无法使用原生JSON的问题   起因 在项目中要将页面上的js对象传给后台, ...

  2. OSPF

    Ospf OSPF(开放最短路径优先协议)是一种无类内部网关协议(IGP):是一种链路状态路由选择协议: 入门: 可以把整个网络(一个自治系统AS)看成一个王国,这个王国可以分成几个 区(area), ...

  3. 比较实用的JavaScript库

    如果你操作过cookie的接口,那么你一定会感觉这东西的规范真的是太复杂了,根本记不住啊,其实你是对的,因为cookie的接口设计的是有问题的,也就是说设计的太底层了,根本不友好,那么来试试这个js库 ...

  4. 进程kswapd0与events/0消耗大量CPU的问题

    http://www.nowamagic.net/librarys/veda/detail/2539 今天下午网站宕了两次机,发工单给阿里云,发现原因是服务器的CPU 100%了. 重启服务器后,使用 ...

  5. jQuery Ajax请求提交 后台getParameter接收不到数据

    今天遇到的问题,总结一下 jQuery的$ajax({ contentType:"application/json",  //发送信息至服务器时内容编码类型. }) 这样的方式提交 ...

  6. shell之数组

    1.从数组的下标分为索引数组.关联数组 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 /* 索引数组,即通常情况下所说的数组 */ var ary1 = [1,3,5, ...

  7. OpenJudge计算概论-简单算术表达式求值

    /*===================================== 简单算术表达式求值 总时间限制: 1000ms 内存限制: 65536kB 描述 2位正整数的简单算术运算(只考虑整数运 ...

  8. wikioi 1201 最小数和最大数

    /*==================================================== 1201 最小数和最大数 题目描述 Description 输入n个数,n<=100 ...

  9. js 触摸类库

    A javascript library for multi-touch gestures :// You can touch this  http://hammerjs.github.io     ...

  10. jQuery中怎么添加innerText、innerHtml(转)

    发现如果我在div或者其他非表单的标签中赋值,原本用普通的js就直接document.getElementById("id").innerHtml(或者其他几个)就可以了. 但是在 ...