在一个窗口中显示多张图片
来源:互联网 发布:java post 编辑:程序博客网 时间:2024/05/01 09:58
忘记了是引用那位大神的了
// showManyImage.cpp : Defines the entry point for the console application.//#include<opencv2\opencv.hpp>#include <stdio.h>#include <stdarg.h>#include <time.h>#include <iostream>using namespace std;using namespace cv;void cvShowManyImages(char* title, int nArgs, ...){ // img - Used for getting the arguments IplImage *img; // DispImage - the image in which input images are to be copied IplImage *DispImage; int size; int i; int m, n; 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 the number of arguments is lesser than 0 or greater than 12 // return without displaying if (nArgs <= 0) { printf("Number of arguments too small....\n"); return; } else if (nArgs > 12) { printf("Number of arguments too large....\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 image0 DispImage = cvCreateImage(cvSize(100 + size*w, 60 + size*h), 8, 3); // 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)) { // 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 == 0) { 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 == 0 && m != 20) { m = 20; n += 0 + size; } // Set the image ROI to display the current image //cvSetImageROI(DispImage, cvRect(m, n, (int)( x/scale ), (int)( y/scale ))); cvSetImageROI(DispImage, cvRect(m, n, (int)(x / scale), (int)(y / scale))); // cout<<"x="<<m<<"y="<<n<<endl; // 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);}
0 0
- 在一个窗口中显示多张图片
- 在一个窗口中显示两张图片
- 如何利用opencv在一个窗口显示多张图片
- opencv在一个窗口里面显示多张图片
- MATLAB 如何循环显示多张图片在一个窗口
- OpenCV一个窗口显示多张图片
- OpenCV一个窗口显示多张图片
- OpenCV一个窗口显示多张图片
- Android 自定义ListView + Gallery 组合,在ListView的一个item中显示多张图片
- opencv一个窗口显示多张图像
- 利用gallery在Ubuntu Scope中显示多张图片
- 基于OpenCV3实现一个窗口显示若干张图片
- OpenCV学习(1)--在一个窗口同时显示多张图像
- 在一个窗口中显示多个视频子窗口
- OpenCV同一窗口显示多张图片实现
- opencv3自定义窗口内显示多张图片
- Qt-Quick中设置组件风格、显示一张图片、在一行显示多张图片的方法、绘制图片方法...
- 显示多张图片
- Win7环境下STAF安装STAX遇到的问题及解决方法
- Linux内存布局
- GDB 编译--with-python unusable python问题
- AOT JIT and Interpretation
- 第六周上机实践项目4:静态成员应用
- 在一个窗口中显示多张图片
- java程序初始化的顺序
- MySQL添加分区添加索引
- 微信下拉加载
- 远程通信(RPC,Webservice,RMI,JMS、EJB、JNDI的区别)对比
- Java-继承、多态
- Mix-in 类
- OpenGL基础图形编程(二)OpenGL概念建立
- 第六周项目四-静态成员应用