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));