欢迎来到天天文库
浏览记录
ID:12987531
大小:28.00 KB
页数:6页
时间:2018-07-20
《一个窗口显示多个视频》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#include#include#include#includevoidcvShowManyImages(char*title,intnArgs,...){//img-UsedforgettingtheargumentsIplImage*img;//DispImage-theimageinwhichinputimagesaretobecopiedIplImage*DispImage;intsize;inti;intm,n
2、;intx,y;//w-Maximumnumberofimagesinarow//h-Maximumnumberofimagesinacolumnintw,h;//scale-Howmuchwehavetoresizetheimagefloatscale;intmax;//Ifthenumberofargumentsislesserthan0orgreaterthan12//returnwithoutdisplayingif(nArgs<=0){printf("Numberofargumentstoosmall....
3、");return;}elseif(nArgs>12){printf("Numberofargumentstoolarge....");return;}//Determinethesizeoftheimage,//andthenumberofrows/cols//fromnumberofargumentselseif(nArgs==1){w=h=1;size=300;}elseif(nArgs==2){w=2;h=1;size=300;}elseif(nArgs==3
4、
5、nArgs==4){w=2;h=2;size=3
6、00;}elseif(nArgs==5
7、
8、nArgs==6){w=3;h=2;size=200;}elseif(nArgs==7
9、
10、nArgs==8){w=4;h=2;size=200;}else{w=4;h=3;size=150;}//Createanew3channelimageDispImage=cvCreateImage(cvSize(100+size*w,60+size*h),8,3);//Usedtogettheargumentspassedva_listargs;va_start(args,nArgs);//
11、LoopfornArgsnumberofargumentsfor(i=0,m=20,n=20;i12、;}//Findthewidthandheightoftheimagex=img->width;y=img->height;//Findwhetherheightorwidthisgreaterinordertoresizetheimagemax=(x>y)?x:y;//Findthescalingfactortoresizetheimagescale=(float)((float)max/size);//UsedtoAligntheimagesif(i%w==0&&m!=20){m=20;n+=20+size;}//Se13、ttheimageROItodisplaythecurrentimagecvSetImageROI(DispImage,cvRect(m,n,(int)(x/scale),(int)(y/scale)));//ResizetheinputimageandcopytheittotheSingleBigImagecvResize(img,DispImage);//ResettheROIinordertodisplaythenextimagecvResetImageROI(DispImage);}//Createanewwind14、ow,andshowtheSingleBigImage//cvNamedWindow(title,1);cvShowImage(title,DispImage);/*cvWaitKey(0);*///cvDestroyWindow(title);//Endthenumberofargumentsva_e
12、;}//Findthewidthandheightoftheimagex=img->width;y=img->height;//Findwhetherheightorwidthisgreaterinordertoresizetheimagemax=(x>y)?x:y;//Findthescalingfactortoresizetheimagescale=(float)((float)max/size);//UsedtoAligntheimagesif(i%w==0&&m!=20){m=20;n+=20+size;}//Se
13、ttheimageROItodisplaythecurrentimagecvSetImageROI(DispImage,cvRect(m,n,(int)(x/scale),(int)(y/scale)));//ResizetheinputimageandcopytheittotheSingleBigImagecvResize(img,DispImage);//ResettheROIinordertodisplaythenextimagecvResetImageROI(DispImage);}//Createanewwind
14、ow,andshowtheSingleBigImage//cvNamedWindow(title,1);cvShowImage(title,DispImage);/*cvWaitKey(0);*///cvDestroyWindow(title);//Endthenumberofargumentsva_e
此文档下载收益归作者所有