//--------------------------------------------------------------------------------------//
// name: display_multi_windows
//
// input: the array of picture: _imgs[4]
// width of the video: _pic_width
// height of the video: _pic_height
// output: a big windows that display 4 small windows
// attention: this function can only display color video or black_and_white video (use: CV_8UC3 or CV_8UC1)
// author: bozi
// time: 2014.09.15
//--------------------------------------------------------------------------------------//
//#include <opencv2/opencv.hpp>
#include <opencv/cv.h>
#include <opencv2/core/core.hpp>
//#include <opencv2/imgproc/imgproc.hpp>
//#include <opencv2/highgui/highgui.hpp>
using namespace cv;
Mat imshowMany(const vector<Mat>& _imgs, int _pic_width, int _pic_height)
{
int nImg = (int)_imgs.size();
Size frameSize( (_pic_width*2 + 60), (_pic_height*2 + 60));
Mat dispImg;
//dispImg.create(Size(100 + size*w, -60 + size*h),CV_8UC1);
dispImg.create(frameSize,CV_8UC1); //CV_8UC1:显示单通道图像(黑白图像) CV_8UC3:显示3通道图像(彩色图像)
int size;
int x, y;
// w - Maximum number of images in a row
// h - Maximum number of images in a column
int w, h;
// scale - How much we have to resize the image
//float scale;
//int max;
if (nImg <= 0)
{
printf("Number of arguments too small....\n");
return Mat::zeros(100,100,CV_8UC1);
}
else if (nImg > 12)
{
printf("Number of arguments too large....\n");
return Mat::zeros(100,100,CV_8UC1);
}
else if (nImg == 1)
{
w = h = 1;
size = 300;
}
else if (nImg == 2)
{
w = 2; h = 1;
size = 300;
}
else if (nImg == 3 || nImg == 4)
{
w = 2; h = 2;
size = 300;
}
else if (nImg == 5 || nImg == 6)
{
w = 3; h = 2;
size = 200;
}
else if (nImg == 7 || nImg == 8)
{
w = 4; h = 2;
size = 200;
}
else
{
w = 4; h = 3;
size = 150;
}
for (int i= 0, m=20, n=30; i<nImg; i++, m+=(20+size+20))
{
x = _imgs[i].cols;
y = _imgs[i].rows;
if (i%w==0 && m!=20)
{
m = 20;
n += 30 + _pic_height;
}
Mat imgROI = dispImg(Rect(m, n, x, y));
resize(_imgs[i], imgROI, Size(x, y));
//每幅图片显示标题
string words = "";
switch(i)
{
case 0: words = "pic_1";
break;
case 1: words = "pic_2";
break;
case 2: words = "pic_3";
break;
case 3: words = "pic_4";
break;
default:words = "nothing";
break;
}
putText( dispImg, words, Point( m + _pic_width/3 ,n - 10),FONT_HERSHEY_COMPLEX_SMALL, 1, Scalar(255, 0, 0) ); //文本显示的位置
}
return dispImg;
//namedWindow(_winName);
//imshow(_winName, dispImg);
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
BG_dif.rar (88个子文件)
BG_dif
Debug
BG_dif.ilk 553KB
BG_dif.exe 61KB
BG_dif.pdb 1.65MB
BG_dif
output_video.avi 8.88MB
backG_dif.cpp 2KB
Debug
link.7348-cvtres.write.1.tlog 2B
link.1340-cvtres.write.1.tlog 2B
cl.command.1.tlog 1KB
link.2192.write.1.tlog 2B
link.2192-cvtres.read.1.tlog 2B
link.6640-cvtres.write.1.tlog 2B
link.7532-cvtres.write.1.tlog 2B
link.3264-cvtres.read.1.tlog 2B
link.6960-cvtres.read.1.tlog 2B
BG_dif_manifest.rc 202B
rc.command.1.tlog 570B
CL.read.1.tlog 37KB
link.7532-cvtres.read.1.tlog 2B
vc100.idb 723KB
mt.read.1.tlog 434B
link.616-cvtres.read.1.tlog 2B
link.7348.read.1.tlog 2B
link.7296-cvtres.write.1.tlog 2B
link.7348.write.1.tlog 2B
link.6960.write.1.tlog 2B
link-cvtres.read.1.tlog 2B
link.read.1.tlog 5KB
link.7276-cvtres.write.1.tlog 2B
link.3264.read.1.tlog 2B
link.1340.read.1.tlog 2B
rc.read.1.tlog 338B
link.write.1.tlog 1KB
link.7532.write.1.tlog 2B
link.7980.write.1.tlog 2B
CL.write.1.tlog 1KB
link.3544.write.1.tlog 2B
link.6640.write.1.tlog 2B
link.2192-cvtres.write.1.tlog 2B
BG_dif.exe.embed.manifest 406B
BG_dif.exe.intermediate.manifest 381B
link.6640-cvtres.read.1.tlog 2B
link.7076-cvtres.read.1.tlog 2B
vc100.pdb 1.11MB
link.7980-cvtres.write.1.tlog 2B
link.1340.write.1.tlog 2B
link.3544-cvtres.read.1.tlog 2B
link.3544-cvtres.write.1.tlog 2B
link.3264-cvtres.write.1.tlog 2B
link.616.write.1.tlog 2B
link.7296.read.1.tlog 2B
link.7076-cvtres.write.1.tlog 2B
BG_dif.log 3KB
link.command.1.tlog 2KB
link.1340-cvtres.read.1.tlog 2B
link.6960.read.1.tlog 2B
link.7276.write.1.tlog 2B
link.7076.read.1.tlog 2B
link.7296.write.1.tlog 2B
link.2192.read.1.tlog 2B
link.616.read.1.tlog 2B
mt.write.1.tlog 366B
link.3544.read.1.tlog 2B
MultiWindows_Display.obj 164KB
link.7296-cvtres.read.1.tlog 2B
BG_dif.lastbuildstate 86B
BG_dif.exe.embed.manifest.res 472B
link.7980-cvtres.read.1.tlog 2B
link.616-cvtres.write.1.tlog 2B
link.7276.read.1.tlog 2B
link.3264.write.1.tlog 2B
mt.command.1.tlog 404B
link.6960-cvtres.write.1.tlog 2B
link.7348-cvtres.read.1.tlog 2B
link.7076.write.1.tlog 2B
backG_dif.obj 128KB
link.7532.read.1.tlog 2B
link.6640.read.1.tlog 2B
rc.write.1.tlog 346B
link.7980.read.1.tlog 2B
link-cvtres.write.1.tlog 2B
link.7276-cvtres.read.1.tlog 2B
MultiWindows_Display.cpp 3KB
BG_dif.vcxproj.filters 1KB
BG_dif.vcxproj 4KB
MultiWindows_Display.h 159B
BG_dif.vcxproj.user 143B
BG_dif.sln 885B
BG_dif.suo 19KB
共 88 条
- 1
gurgle_bz
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页