From b0671d722c65a39e70b587843ad1cb616d85da87 Mon Sep 17 00:00:00 2001 From: winsty Date: Sat, 16 May 2015 20:18:10 +0800 Subject: [PATCH] fix im2rec resize bug --- tools/im2rec.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/im2rec.cc b/tools/im2rec.cc index c1f912e1..f8887db4 100644 --- a/tools/im2rec.cc +++ b/tools/im2rec.cc @@ -107,11 +107,11 @@ int main(int argc, char *argv[]) { CHECK(img.data != NULL) << "OpenCV decode fail:" << path; cv::Mat res; if (img.rows > img.cols) { - cv::resize(img, res, cv::Size(img.rows * new_size / img.cols, - new_size), 0, 0, CV_INTER_LINEAR); + cv::resize(img, res, cv::Size(new_size, img.rows * new_size / img.cols), + 0, 0, CV_INTER_LINEAR); } else { - cv::resize(img, res, cv::Size(new_size, new_size * img.cols - / img.rows), 0, 0, CV_INTER_LINEAR); + cv::resize(img, res, cv::Size(new_size * img.cols / img.rows, new_size), + 0, 0, CV_INTER_LINEAR); } encode_buf.clear(); CHECK(cv::imencode(".jpg", res, encode_buf, encode_params));