Skip to content

Commit

Permalink
fix im2rec resize bug
Browse files Browse the repository at this point in the history
  • Loading branch information
winstywang committed May 16, 2015
1 parent a79ef04 commit b0671d7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/im2rec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit b0671d7

Please sign in to comment.