You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by zh...@apache.org on 2017/12/14 06:38:46 UTC

[incubator-mxnet] branch v1.0.0 updated: [ImageIO] Fix image io for opencv3.3 (#8757)

This is an automated email from the ASF dual-hosted git repository.

zhasheng pushed a commit to branch v1.0.0
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/v1.0.0 by this push:
     new 7c2f659  [ImageIO] Fix image io for opencv3.3 (#8757)
7c2f659 is described below

commit 7c2f659f491cd68f2fb921f339112171257ebc2b
Author: Xingjian Shi <xs...@ust.hk>
AuthorDate: Wed Nov 22 12:50:02 2017 -0800

    [ImageIO] Fix image io for opencv3.3 (#8757)
    
    * fix image io for opencv3.3
    
    * update function in cv_api
    
    * fix bug
    
    * fix lint
---
 plugin/opencv/cv_api.cc | 4 ++++
 src/io/image_io.cc      | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/plugin/opencv/cv_api.cc b/plugin/opencv/cv_api.cc
index 1508de3..1ca14aa 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 d95e750..491370d 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

-- 
To stop receiving notification emails like this one, please contact
['"commits@mxnet.apache.org" <co...@mxnet.apache.org>'].