vs2010 + opencv2.3.1
#include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
using namespace std;
int main()
{
Mat colorImage;
//Mat depthImage;
///////////////////////////////////////////////////////////////////
///由于需要调用sprintf函数,定义colorImageSrc时必须使用数组的形式
///////////////////////////////////////////////////////////////////
//char *colorImageSrc = "I:\\The Graduation Design\\Material\\DepthImage\\rgb\\seq0_0000_1.ppm";
char colorImageSrc[100] = "I:\\The Graduation Design\\Material\\DepthImage\\rgb\\seq0_0000_1.ppm";
//char *depthImageSrc;
int i = 1;
//int j = 0;
//char *dest = "I:\\The Graduation Design\\Material\\DepthImage\\rgb\\seq0_0000_1.ppm";
char *dest = "I:\\The Graduation Design\\Material\\DepthImage\\rgb\\seq0_%04d_1.ppm";
while(colorImageSrc)//直到显示完所有图片
{
colorImage = imread(colorImageSrc,1);
if(!colorImage.data)
{
cout<<"error"<<endl;
return -1;
}
imshow("colorImage",colorImage);
/////////////////////////////////////////////
///使用sprintf函数
/////////////////////////////////////////////
sprintf(colorImageSrc,dest,i);
cout<<colorImageSrc<<endl;
i++;
//此处需要waiKey()
waitKey(1);
}
return 0;
}
int sprintf( char *buffer, const char *format, [ argument] … );
openCV学习笔记(5):使用sprintf函数实现在窗口连续显示同一文件夹下的图片
原文地址:http://blog.csdn.net/chentravelling/article/details/44901223