Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support applying orientation in Convert #4219

Merged
merged 9 commits into from
Sep 20, 2022

Conversation

szkarpinski
Copy link
Collaborator

@szkarpinski szkarpinski commented Sep 1, 2022

Category:

New feature (non-breaking change which adds functionality)

Description:

Images may be stored in an orientation other than the actual one and contain a tag (see EXIF orientation) indicating that the image should be transformed (for example rotated) after decoding.

In this PR I extend Convert function with an ability to rectify an image according to the orientation information.

Additional information:

The implemented solution is not the fastest one, but is definetely the simplest: I adjust the strides, sizes and pointer of the output tensor in such a way, that the data is stored there in appropriate order. A function responsible for that is ApplyOrientation.

Not all decoders use the high-level Convert, some (such as TIFF) use lower-level version. In this
case ApplyOrientation can be used directly in order to modify the strides, sizes and pointer.

Affected modules and functionalities:

imgcodec/util/convert*. Another (optional) parameter orientation was added to Convert

Key points relevant for the review:

Tests:

  • Existing tests apply
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

Checklist

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: DALI-2995

Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
@@ -25,8 +25,8 @@ namespace imgcodec {

void Convert(SampleView<CPUBackend> out, TensorLayout out_layout, DALIImageType out_format,
ConstSampleView<CPUBackend> in, TensorLayout in_layout, DALIImageType in_format,
TensorShape<> roi_start, TensorShape<> roi_end) {
const auto &out_shape = out.shape();
TensorShape<> roi_start, TensorShape<> roi_end, Orientation orientation) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
TensorShape<> roi_start, TensorShape<> roi_end, Orientation orientation) {
const ROI &roi, Orientation orientation) {

Adjusting this now that we have the ROI type would be nice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea. Done!

Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
@jantonguirao jantonguirao assigned jantonguirao and unassigned mzient Sep 20, 2022
@jantonguirao
Copy link
Contributor

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5958642]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5958656]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5958642]: BUILD FAILED

Signed-off-by: Joaquin Anton <janton@nvidia.com>
@jantonguirao
Copy link
Contributor

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5958656]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5958717]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [5958717]: BUILD PASSED

@jantonguirao jantonguirao merged commit 41c1d53 into NVIDIA:main Sep 20, 2022
staniewzki pushed a commit to staniewzki/DALI that referenced this pull request Sep 21, 2022
Images may be stored in an orientation other than the actual one and contain a tag (see EXIF orientation) indicating that the image should be transformed (for example rotated) after decoding.

In this PR I extend Convert function with an ability to rectify an image according to the orientation information.

Additional information:

The implemented solution is not the fastest one, but is definitely the simplest: I adjust the strides, sizes and pointer of the output tensor in such a way, that the data is stored there in appropriate order. A function responsible for that is `ApplyOrientation`.

Not all decoders use the high-level Convert, some (such as TIFF) use lower-level version. In this
case `ApplyOrientation` can be used directly in order to modify the strides, sizes and pointer.

Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants