在一个窗口中显示多个视频,并在每个子窗口左上角显示系统时间,函数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,复制以下内容,执行 '******************************************** ...
随机推荐
- java.lang.SecurityException: class "javax.servlet.FilterRegistration"(spark下maven)
今天写spark例子用到maven,但是自己maven又不熟悉.遇到错误找了半天知道是(sevlet-api2.5 3.0)包冲突需要解决包之间依赖问题却不知道怎么下手.但是最终慢慢了解还是找到新手的 ...
- ExtJS常用的正则表达式
正则表达式用于字符串处理.表单验证等场合,实用高效.现将一些常用的表达式收集于此,以备不时之需. Ext.onReady(function(){ Ext.QuickTips.init(); }); E ...
- 学习ARM7、ARM9的操作系统选择经验! [转]
一 首先说说ARM的发展 可以用一片大好来形容,翻开各个公司的网站,招聘里面嵌入式占据了大半工程师职位.广义的嵌入式无非几种:传统的什么51.AVR.PIC称做嵌入式微控制器:ARM是嵌 ...
- 机器学习&人工智能书籍
Introduction to Machine Learning https://www.amazon.cn/Introduction-to-Machine-Learning-Alpaydin-Eth ...
- C++ vector和list的区别
1.vector数据结构vector和数组类似,拥有一段连续的内存空间,并且起始地址不变.因此能高效的进行随机存取,时间复杂度为o(1);但因为内存空间是连续的,所以在进行插入和删除操作时,会造成内存 ...
- c# 图片XML序列化与反序列化
var xmlDoc = new XmlDocument(); xmlDoc.Load(@"C:\Users\*\Desktop\*.xml"); ].ChildNodes[]; ...
- Postfix 发送邮件流程简析
PostFix接受和转发邮件的说明 来源ip符合inet_interfaces,收件人域符合mydestination, Postfix将接收到本地. 来源ip符合inet_interfaces, ...
- OpenJudge计算概论-单词倒排【把句子内单词的顺序翻转】
/*================================================== 单词倒排 总时间限制: 1000ms 内存限制: 65536kB 描述 编写程序,读入一段英文 ...
- 【Swift】读取文本文件字符串
var str:NSString = NSString.stringWithContentsOfFile(_srcouceFilePath,encoding:NSUTF8StringEncoding, ...
- ASP.NET MVC在服务端把异步上传的图片裁剪成不同尺寸分别保存,并设置上传目录的尺寸限制
我曾经试过使用JSAjaxFileUploader插件来把文件.照片以异步的方式上传,就像"MVC文件图片ajax上传轻量级解决方案,使用客户端JSAjaxFileUploader插件01- ...