mirror of
https://github.com/lltcggie/waifu2x-caffe.git
synced 2025-06-26 21:52:49 +00:00
Bitmapの読み込みはSTBIを優先させるようにした(32ビットBitmapをOpenCVで読み込むと画像がおかしくなるから) #35
This commit is contained in:
parent
a0c29c671b
commit
26cd687a65
@ -228,6 +228,9 @@ Waifu2x::eWaifu2xError stImage::LoadMat(cv::Mat &im, const boost::filesystem::pa
|
|||||||
if (!readFile(input_file, img_data))
|
if (!readFile(input_file, img_data))
|
||||||
return Waifu2x::eWaifu2xError_FailedOpenInputFile;
|
return Waifu2x::eWaifu2xError_FailedOpenInputFile;
|
||||||
|
|
||||||
|
const boost::filesystem::path ipext(input_file.extension());
|
||||||
|
if (!boost::iequals(ipext.string(), ".bmp")) // 特定のファイル形式の場合OpenCVで読むとバグることがあるのでSTBIを優先させる
|
||||||
|
{
|
||||||
cv::Mat im(img_data.size(), 1, CV_8U, img_data.data());
|
cv::Mat im(img_data.size(), 1, CV_8U, img_data.data());
|
||||||
original_image = cv::imdecode(im, cv::IMREAD_UNCHANGED);
|
original_image = cv::imdecode(im, cv::IMREAD_UNCHANGED);
|
||||||
|
|
||||||
@ -238,6 +241,18 @@ Waifu2x::eWaifu2xError stImage::LoadMat(cv::Mat &im, const boost::filesystem::pa
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const Waifu2x::eWaifu2xError ret = LoadMatBySTBI(original_image, img_data);
|
||||||
|
if (ret != Waifu2x::eWaifu2xError_OK)
|
||||||
|
{
|
||||||
|
cv::Mat im(img_data.size(), 1, CV_8U, img_data.data());
|
||||||
|
original_image = cv::imdecode(im, cv::IMREAD_UNCHANGED);
|
||||||
|
if (original_image.empty())
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
im = original_image;
|
im = original_image;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user