From 73da3949962dfd72cd388dd9b5aa51b7a44acf3c Mon Sep 17 00:00:00 2001 From: lltcggie Date: Mon, 20 Mar 2017 22:09:59 +0900 Subject: [PATCH] =?UTF-8?q?CUI=E3=81=A7=E5=87=BA=E5=8A=9B=E3=81=AEwidth?= =?UTF-8?q?=E3=81=A8height=E3=82=92=E5=90=8C=E6=99=82=E3=81=AB=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- waifu2x-caffe/Source.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/waifu2x-caffe/Source.cpp b/waifu2x-caffe/Source.cpp index a769793..ce840b6 100644 --- a/waifu2x-caffe/Source.cpp +++ b/waifu2x-caffe/Source.cpp @@ -108,6 +108,9 @@ int main(int argc, char** argv) TCLAP::ValueArg cmdScaleHeight("h", "scale_height", "custom scale height", false, 0, "double", cmd); + TCLAP::ValueArg cmdScaleWidthHeight("", "scale_width_height", + "custom scale width and height", false, 0, "double", cmd); + TCLAP::ValueArg cmdModelPath("", "model_dir", "path to custom model directory (don't append last / )", false, "models/upconv_7_anime_style_art_rgb", "string", cmd); @@ -174,18 +177,6 @@ int main(int argc, char** argv) boost::optional ScaleWidth; boost::optional ScaleHeight; - int valid_num = 0; - if (cmdScaleWidth.getValue() > 0) - valid_num++; - if (cmdScaleHeight.getValue() > 0) - valid_num++; - - if (valid_num > 1) - { - printf("エラー: scale_widthとscale_heightは同時に指定できません\n"); - return 1; - } - int crop_w = cmdCropSizeFile.getValue(); int crop_h = cmdCropSizeFile.getValue(); @@ -197,9 +188,10 @@ int main(int argc, char** argv) if (cmdScaleWidth.getValue() > 0) ScaleWidth = cmdScaleWidth.getValue(); - else if (cmdScaleHeight.getValue() > 0) + if (cmdScaleHeight.getValue() > 0) ScaleHeight = cmdScaleHeight.getValue(); - else + + if (cmdScaleWidth.getValue() == 0 && cmdScaleHeight.getValue() == 0) ScaleRatio = cmdScaleRatio.getValue(); const boost::filesystem::path input_path(boost::filesystem::absolute((cmdInputFile.getValue()))); @@ -238,9 +230,11 @@ int main(int argc, char** argv) { if(ScaleRatio) addstr += "(x" + std::to_string(*ScaleRatio) + ")"; + else if (ScaleWidth && ScaleHeight) + addstr += "(" + std::to_string(*ScaleWidth) + "x" + std::to_string(*ScaleHeight) + ")"; else if (ScaleWidth) addstr += "(width " + std::to_string(*ScaleWidth) + ")"; - else + else if (ScaleHeight) addstr += "(height " + std::to_string(*ScaleHeight) + ")"; } @@ -352,6 +346,8 @@ int main(int argc, char** argv) { if (ScaleRatio) addstr += "(x" + std::to_string(*ScaleRatio) + ")"; + else if (ScaleWidth && ScaleHeight) + addstr += "(" + std::to_string(*ScaleWidth) + "x" + std::to_string(*ScaleHeight) + ")"; else if (ScaleWidth) addstr += "(width " + std::to_string(*ScaleWidth) + ")"; else