利用OpenCV和OpenMP的多路视频融合显示
来源:互联网 发布:java 跨行字符串 编辑:程序博客网 时间:2024/06/06 19:13
#include "stdafx.h"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "omp.h"
#define CAM_NUM 16//32路太多,w32不行,x64可以
using namespace cv;
int _tmain(int argc, _TCHAR* argv[])
{
Mat img;
VideoCapture vc[CAM_NUM];
int i;
string str;
int left;
int top;
bool run = true;
TickMeter tm;
int count = 0;
#pragma omp parallel for private(str)
for(i=0; i<CAM_NUM; i++)
{
if(i < 16)
str = format("rtsp://xx:xx@1xx.xx.xx.xx/h264/ch%d/sub/av_stream", i+1);
else if(i < 32)
str = format("rtsp://xx:xx@xx.xx.xx.xx/h264/ch%d/sub/av_stream", i-15);
else if(i < 48)
str = format("rtsp://xx:xx@xx.xx.xx.xx/h264/ch%d/sub/av_stream", i-31);
else
str = format("rtsp://xx:xx@xx.xx.xx.xx/h264/ch%d/sub/av_stream", i-47);
vc[i].open(str);
printf("Cam%d opened.\n", i);
}
int width = vc[0].get(CV_CAP_PROP_FRAME_WIDTH);
int height = vc[0].get(CV_CAP_PROP_FRAME_HEIGHT);
Mat imgShow(height * 8, width * 8, CV_8UC3);
//height /= 8;
//width /= 8;
while(run)
{
#pragma omp parallel for private(img, left, top)
for(i=0; i<CAM_NUM+1; i++)
{
if(i < CAM_NUM)
{
vc[i] >> img;
//resize(img, img, Size(), 0.125, 0.125);
left = i % 8 * width;
top = i / 8 * height;
img.copyTo(imgShow(Rect(left, top, width, height)));
}
else
{
namedWindow("Image");
imshow("Image", imgShow);
if (waitKey(1) == 27)
run = false;
tm.stop();
if (count++ % 25 == 0)
printf("time cost = %.1f\n", tm.getTimeMilli());
tm.reset();
tm.start();
}
}
}
return 0;
}
- 利用OpenCV和OpenMP的多路视频融合显示
- 利用MFC和opencv读取视频显示图像方法
- OpenCV学习笔记 利用MFC的Picture控件显示图像+播放视频和捕获摄像头画面 .
- OpenCV学习 利用MFC的Picture控件显示图像+播放视频和捕获摄像头画面
- OpenCV学习笔记 利用MFC的Picture控件显示图像+播放视频和捕获摄像头画面
- 利用VS+MFC+Opencv显示图像和视频所需添加类(CvvImage.h和CvvImage.cpp的源码)。
- opencv:求视频的前n帧的融合图像
- OpenCV学习笔记(9)利用MFC的Picture控件显示图像+播放视频和捕获摄像头画面
- OpenCV学习笔记(9)利用MFC的Picture控件显示图像+播放视频和捕获摄像头画面
- OpenCV学习笔记(9)利用MFC的Picture控件显示图像+播放视频和捕获摄像头画面
- OpenCV学习笔记(9)利用MFC的Picture控件显示图像+播放视频和捕获摄像头画面
- 关于Ogre和Opencv库的融合
- 利用ffmpeg和opencv进行视频的解码播放
- 利用ffmpeg和opencv进行视频的解码播放
- 利用ffmpeg和opencv进行视频的解码播放
- 利用ffmpeg和opencv进行视频的解码播放
- 利用ffmpeg和opencv进行视频的解码播放
- OpenCV学习笔记01--图像和视频的显示
- OpenCV添加鼠标事件
- VS2010下关闭警告
- VS下Qt生成ui_xxx.h和moc_xxx.cpp的路径设置
- OpenMP中for循环使用规范
- 将博客搬至CSDN
- 利用OpenCV和OpenMP的多路视频融合显示
- URAL1519
- AJAX发送异步请求
- PB datawindow 数据窗口字段保存显示超过255个字符,要如何设置?
- SQL Server 2000中查询表名
- CocurrentHashMap和Hashtable的区别
- XCTest.framework 统计单元测试
- MySQL支持的数据类型,数值类型
- 从NDK在非Root手机上的调试原理探讨Android的安全机制