資源描述:
《一個(gè)窗口顯示多個(gè)視頻》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
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;}//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