主要功能
读取文件夹中批量不同格式不同大小图片,将其转化为JPG格式,并更改为统一大小,然后保存至指定文件夹。
本程序保存的图片大小为608*608,为了保持原图的长和宽的比例,将多余的部分用黑色部分做了填充。
代码如下:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <fstream>
using namespace std;
using namespace cv;
int a = 1;
//更改图片大小
Mat changeImg(Mat input,Mat output)
{
float Img_width = input.cols;
float Img_hight = input.rows;
float scale = Img_hight / Img_width;
float width ;
float hight;//设置更改后的图片的宽度和高度
if (scale