opencv实现多图像读取并显示,sprintf_s函数,static_cast

基于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 &
  • 8
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值