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

Conversation

sxjscience
Copy link
Member

@sxjscience sxjscience commented Nov 21, 2017

Description

Starting from OpenCV3.3 the imdecode function will automatically rotate the image based on the EXIF' orientation flag.

Mat imdecode( InputArray _buf, int flags )
{
    CV_TRACE_FUNCTION();

    Mat buf = _buf.getMat(), img;
    imdecode_( buf, flags, LOAD_MAT, &img );

    /// optionally rotate the data if EXIF' orientation flag says so
    if( !img.empty() && (flags & IMREAD_IGNORE_ORIENTATION) == 0 && flags != IMREAD_UNCHANGED )
    {
        ApplyExifOrientation(buf, img);
    }

    return img;
}

This can be disabled by setting the cv::IMREAD_IGNORE_ORIENTATION flag.

Checklist

Essentials

  • Passed code style checking (make lint)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • For user-facing API changes, API doc string has been updated. For new C++ functions in header files, their functionalities and arguments are well-documented.
  • To my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • add IMREAD_IGNORE_ORIENTATION flag when opencv 3.3 is used.

Comments

@@ -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 > 2 && CV_MINOR_VERSION >= 3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition won't work for opencv 4.1
you should use CV_MAJOR_VERSION > 3 || (CV_MAJOR_VERSION == 3 && CV_MINOR_VERSION >=3)

@piiswrong piiswrong merged commit 1f6d586 into apache:master Nov 22, 2017
eric-haibin-lin pushed a commit to eric-haibin-lin/mxnet that referenced this pull request Dec 3, 2017
* fix image io for opencv3.3

* update function in cv_api

* fix bug

* fix lint
KellenSunderland pushed a commit to KellenSunderland/incubator-mxnet that referenced this pull request Dec 3, 2017
* fix image io for opencv3.3

* update function in cv_api

* fix bug

* fix lint
zhreshold pushed a commit to zhreshold/mxnet that referenced this pull request Dec 14, 2017
* fix image io for opencv3.3

* update function in cv_api

* fix bug

* fix lint
szha pushed a commit that referenced this pull request Dec 14, 2017
* fix image io for opencv3.3

* update function in cv_api

* fix bug

* fix lint
rahul003 pushed a commit to rahul003/mxnet that referenced this pull request Jun 4, 2018
* fix image io for opencv3.3

* update function in cv_api

* fix bug

* fix lint
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants