diff --git a/plugin/opencv/cv_api.cc b/plugin/opencv/cv_api.cc index 1508de376d22..1ca14aa4604f 100644 --- a/plugin/opencv/cv_api.cc +++ b/plugin/opencv/cv_api.cc @@ -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()}); diff --git a/src/io/image_io.cc b/src/io/image_io.cc index d95e750e79f3..491370d9a710 100644 --- a/src/io/image_io.cc +++ b/src/io/image_io.cc @@ -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