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

Robust image I/O #6765

Merged
merged 7 commits into from
May 12, 2024
Merged

Robust image I/O #6765

merged 7 commits into from
May 12, 2024

Conversation

ssheorey
Copy link
Member

@ssheorey ssheorey commented Apr 23, 2024

  • Use file signatures (beginning bytes) instead of filename extension (png/jpg) to select decoder. jpg files with png extension and vice versa are read correctly.
  • Catch libjpeg errors and report as normal Open3D exceptions. Change Open3D warnings to errors (exceptions) on jpeg I/O error.

Output if a corrupt file is given to jpeglib:

>>> im=o3d.io.read_image("texture1_corrupt.jpg") 
Corrupt JPEG data: 67 extraneous bytes before marker 0xc0
[Open3D WARNING] libjpeg error: Quantization table 0x01 was not defined
>>> im=o3d.t.io.read_image("texture1_corrupt.jpg") 
Corrupt JPEG data: 67 extraneous bytes before marker 0xc0
[Open3D WARNING] libjpeg error: Quantization table 0x01 was not defined

Earlier, this used to crash the program (python or user C++ app, or Open3D viewer app) since libjpeg would immediately exit() with this error message.

Breaking change: Image read errors now Clear() the image to ensure an older image cannot be used in error. This is in addition to a WARNING message and returning false. We do not throw exceptions for Image IO, to be consistent with OpenCV.

References:

Type

  • Bug fix (non-breaking change which fixes an issue): Fixes Error loading ShapeNet meshes with texture #4362
  • New feature (non-breaking change which adds functionality). Resolves #
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) Resolves #

Motivation and Context

Checklist:

  • I have run python util/check_style.py --apply to apply Open3D code style
    to my code.
  • This PR changes Open3D behavior or adds new functionality.
    • Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is
      updated accordingly.
    • I have added or updated C++ and / or Python unit tests OR included test
      results
      (e.g. screenshots or numbers) here.
  • I will follow up and update the code if CI fails.
  • For fork PRs, I have selected Allow edits from maintainers.

Description

Catch libjpeg errors and report as normal Open3D exceptions.
Change Open3D warnings to errors (exceptions) on jpeg  I/O error.
Copy link

update-docs bot commented Apr 23, 2024

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

@ssheorey ssheorey requested review from errissa and kxgao April 23, 2024 20:09
@ssheorey ssheorey changed the title Robust jpeg image I/O Robust image I/O Apr 23, 2024
@ssheorey ssheorey added the io label Apr 28, 2024
@ssheorey ssheorey added this to the v0.19 milestone Apr 29, 2024
@ssheorey ssheorey merged commit bf48b45 into main May 12, 2024
35 of 37 checks passed
@ssheorey ssheorey deleted the ss/robust-image-io branch May 12, 2024 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error loading ShapeNet meshes with texture
1 participant