waifu2x()でコールバック関数を設定しないとエラーになるバグを修正

This commit is contained in:
lltcggie 2015-06-01 01:23:13 +09:00
parent 91c3d4c4b1
commit b930ecfaa2

View File

@ -465,9 +465,10 @@ eWaifu2xError waifu2x(int argc, char** argv, const std::vector<InputOutputPathPa
int fileCount = 0; int fileCount = 0;
for (const auto &p : file_paths) for (const auto &p : file_paths)
{ {
progress_func(file_paths.size(), fileCount); if (progress_func)
progress_func(file_paths.size(), fileCount);
if (cancel_func()) if (cancel_func && cancel_func())
return eWaifu2xError_Cancel; return eWaifu2xError_Cancel;
const auto &input_file = p.first; const auto &input_file = p.first;
@ -509,7 +510,7 @@ eWaifu2xError waifu2x(int argc, char** argv, const std::vector<InputOutputPathPa
im = im(cv::Rect(offset, offset, image_size.width, image_size.height)); im = im(cv::Rect(offset, offset, image_size.width, image_size.height));
} }
if (cancel_func()) if (cancel_func && cancel_func())
return eWaifu2xError_Cancel; return eWaifu2xError_Cancel;
const int scale2 = ceil(log2(scale_ratio)); const int scale2 = ceil(log2(scale_ratio));
@ -538,7 +539,7 @@ eWaifu2xError waifu2x(int argc, char** argv, const std::vector<InputOutputPathPa
continue; continue;
} }
if (cancel_func()) if (cancel_func && cancel_func())
return eWaifu2xError_Cancel; return eWaifu2xError_Cancel;
// 再構築した輝度画像とCreateZoomColorImage()で作成した色情報をマージして通常の画像に変換し、書き込む // 再構築した輝度画像とCreateZoomColorImage()で作成した色情報をマージして通常の画像に変換し、書き込む
@ -577,7 +578,8 @@ eWaifu2xError waifu2x(int argc, char** argv, const std::vector<InputOutputPathPa
fileCount++; fileCount++;
} }
progress_func(file_paths.size(), fileCount); if (progress_func)
progress_func(file_paths.size(), fileCount);
return eWaifu2xError_OK; return eWaifu2xError_OK;
} }