基于opencv和C++实现多幅图像的加载,程序中需要将文件统一命名,而且文件名最后一定是数字,还未实现对字符文件名图像的加载。
首先介绍一个函数sprintf_s,sprintf_s是sprintf函数的安全版本,是新的C++标准对sprintf函数进行的改进,通过指定缓冲区长度来避免sprintf()存在的溢出风险,其函数原型如下:
sprintf_s(
_Out_writes_z_(_BufferCount) char* const _Buffer,
_In_ size_t const _BufferCount,
_In_z_ _Printf_format_string_ char const* const _Format,
...)
其功能是将数据格式化输出到字符串。
将图像批量加载并显示程序代码如下:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
using namespace std;
using namespace cv;
int main(int argc, char **argv)
{
const int num = 200;
char fileName[250];
char windowName[250];
Mat srcImage;
int64 timeCount &