opencv代码
#include <iostream>
#include<opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat temImage;
cv::Mat img = cv::imread("/media/minivision/Win10/xg/image/2002/07/20/big/img_663.jpg",CV_LOAD_IMAGE_UNCHANGED);
imshow("img", img);
int w = img.cols;
int h = img.rows;
float t = 1.;
float len = t * std::max(w, h);
int dst_w = 224, dst_h = 224;
cv::Mat dst = cv::Mat(cv::Size(dst_w, dst_h), CV_8UC3, cv::Scalar(255,255,255));
Mat imageROI;
if(len==w)
{
float ratio = (float)h/(float)w;
resize(img,temImage,Size(224,224*ratio),0,0,INTER_LINEAR);
imageROI = dst(Rect(0, ((dst_h-224*ratio)/2), temImage.cols, temImage.rows));
temImage.co