Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[ImageIO] Fix image io for opencv3.3 #8757

Merged
merged 4 commits into from
Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions plugin/opencv/cv_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ MXNET_DLL int MXCVImdecode(const unsigned char *img, const mx_uint len,
ndout.CheckAndAlloc();
cv::Mat buf(1, len, CV_8U, img_cpy);
cv::Mat dst(dims[0], dims[1], flag == 0 ? CV_8U : CV_8UC3, ndout.data().dptr_);
#if (CV_MAJOR_VERSION > 3 || (CV_MAJOR_VERSION == 3 && CV_MINOR_VERSION >= 3))
cv::imdecode(buf, flag | cv::IMREAD_IGNORE_ORIENTATION, &dst);
#else
cv::imdecode(buf, flag, &dst);
#endif
CHECK(!dst.empty());
delete[] img_cpy;
}, ndout.ctx(), {}, {ndout.var()});
Expand Down
5 changes: 4 additions & 1 deletion src/io/image_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ void ImdecodeImpl(int flag, bool to_rgb, void* data, size_t size,
} else {
dst = cv::Mat(out->shape()[0], out->shape()[1], flag == 0 ? CV_8U : CV_8UC3,
out->data().dptr_);
#if (CV_MAJOR_VERSION > 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >=4))
#if (CV_MAJOR_VERSION > 3 || (CV_MAJOR_VERSION == 3 && CV_MINOR_VERSION >= 3))
cv::imdecode(buf, flag | cv::IMREAD_IGNORE_ORIENTATION, &dst);
CHECK(!dst.empty()) << "Decoding failed. Invalid image file.";
#elif(CV_MAJOR_VERSION > 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4))
cv::imdecode(buf, flag, &dst);
CHECK(!dst.empty()) << "Decoding failed. Invalid image file.";
#else
Expand Down