在一个窗口中显示多个视频,并在每个子窗口左上角显示系统时间,函数cvShowManyImages是改写的
#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是改写的的更多相关文章
- .NET/C# 在代码中测量代码执行耗时的建议(比较系统性能计数器和系统时间)
我们有很多种方法评估一个方法的执行耗时,比如使用性能分析工具,使用基准性能测试.不过传统的在代码中编写计时的方式依然有效,因为它可以生产环境或用户端得到真实环境下的执行耗时. 如果你希望在 .NET/ ...
- 通过使用浏览器对象模型,输出当前浏览器窗口中打开的文档的URL信息,并将显示在窗口中。
<script type="text/javascript">window.document.write("这个网页文件来自:".bold());w ...
- 透明窗口(窗口上面文字图片等内容不透明)的实现(使用SetLayeredWindowAttributes API函数)
透明窗口(窗口上面文字图片等内容不透明)的实现 本文讨论通过SetLayeredWindowAttributes来实现本文的目的. SetLayeredWindowAttributes的实现必须将窗口 ...
- 【推荐】PHP中格式化时间函数date与gmdate的区别 | 修改PHP的默认时区
PHP中的时间有2个格式化函数:date()和gmdate(),在官方的文档中的描述为: date -- 格式化一个本地时间/日期 gmdate -- 格式化一个 GMT/UTC 日期/时间,返回的是 ...
- Talend 将Oracle中数据导入到hive中,根据系统时间设置hive分区字段
首先,概览下任务图: 流程是,先用tHDFSDelete将hdfs上的文件删除掉,然后将oracle中的机构表中的数据导入到HDFS中:建立hive连接->hive建表->tJava获取系 ...
- 从视频文件中读入数据-->将数据转换为灰度图-->对图像做canny边缘检测-->将这三个结构显示在一个图像中
//从视频文件中读入数据-->将数据转换为灰度图-->对图像做canny边缘检测-->将这三个结构显示在一个图像中 //作者:sandy //时间:2015-10-10 #inclu ...
- 将图片在指定窗口中显示-OpenCV应用学习笔记一
1.OpenCV模块划分 OpenCV其实就是一堆用C和C++语言来实现计算机视觉算法的源代码文件:例如C接口函数cvCany()实现了Canny边缘提取算法,我们可以直接将这些源代码添加到自己的软件 ...
- SharePoint Iframe 报错“此内容不能显示在一个框架中”
问题描述 我们SharePoint站点用Excel Service发布的Excel,需要Iframe到其他系统中,但是,Iframe的时候发现报错“此内容不能显示在一个框架中”. 后来,尝试在其他系统 ...
- mysql数据库导出模型到powerdesigner,PDM图形窗口中显示数据列的中文注释
1,mysql数据库导出模型到powerdesigner 2,CRL+Shift+X 3,复制以下内容,执行 '******************************************** ...
随机推荐
- HDU5889 Barricade(最短路)(网络流)
Barricade Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total S ...
- hdu5441(2015长春赛区网络赛1005)类最小生成树、并查集
题意:有一张无向图,一些点之间有有权边,某条路径的值等于路径上所有边的边权的最大值,而某个点对的值为这两点间所有路径的值的最小值,给出多个询问,每个询问有一个值,询问有多少点对满足其值小于等于询问值. ...
- hdu3342 拓扑序
题意:一个QQ群里面有一群大神,他们互相帮助解决问题,然后互相膜拜,于是有些人就称别人是他师父,现在给出很多师徒关系,问是否有矛盾 拓扑序,按师徒关系建边直接拓扑序就行了. #include<s ...
- 这个代码怎么改??Help快速排序 quicksort
#include<stdio.h>int a[101],n;void quicksort(int left,int right){ int i,j,t,temp; if(l ...
- IE6 7 8BUG锦集
1.浮动元素的双倍margin 说明:这是IE6及其以下版本的一个经典的BUG,触发这个BUG产生的条件是给元素设置了浮动并且同一方向设置了margin值.来看以下代码: <style type ...
- 【usaco】patrol
很长时间都没想出来的简单题,看了题解才写出来,还是naive 原题: FJ有个农场,其中有n块土地,由m条边连起来.FJ的养牛场在土地1,在土地n有个新开张的雪糕店.Bessie经常偷偷溜到雪糕店,当 ...
- 查找字符串的 KMP 算法
查找字符串是我们平常编程过程中经常遇到的,现在介绍一种查找字符串算法,增加程序的执行速度. 通常我们是这么写的: /* content: search a string in a othor stri ...
- win7win8一键取得超级管理员权限
win7win8有时会出现删除不了文件的情况,弹窗提示需要某某权限,下面为解决办法: 在普通帐户中快速获得最高的权限: 新建一个.txt文本,将下面的代码复制粘贴到文件中,另存为或重命名为.reg文件 ...
- Java Language and Virtual Machine Specifications
The Java Language Specification, Java SE 8 Edition HTML | PDF The Java Virtual Machine Specification ...
- audition输出参数设置