Skip to content

Conversation

Atari2
Copy link

@Atari2 Atari2 commented Sep 1, 2025

This PR aims to greatly improve performance of the GreyCodePattern algorithm in the StructuredLight module. It does so by caching and pre-calculating a bunch of stuff needed for the computation and instead of doing manual looping and indexing over the matrices it leverages built-in opencv functions to automatically parallelize work (as well as doing some manual parallelization). Additionally, thanks to the fact that it is using opencv functions, it gains the ability to correctly process 16-bit images, which is a plus.

Work done in more detail:

  • Vastly improve performance of the GreyCodePattern structured light algorithm by leveraging built-in OpenCV functions and parallel code instead of raw loops, at the cost of a bit more memory (decoding a set of 96 5320x4600 images acquired using stereo cameras goes from taking ~100 seconds to taking ~2.5 seconds, in release mode)
  • Automatically gain the ability to decode 16-bit images (switching from raw loops and uchar-indexing to OpenCV functions gives this for free)

Manual testing was done to ensure that the calculated results are correct, both for generation of the patterns and for decoding, in both Debug and Release mode, using real world data.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@Atari2 Atari2 force-pushed the greycodepattern_improvement_pr branch from b2c445a to bff58b8 Compare September 1, 2025 14:57
…ovements

- Vastly improve performance of the GreyCodePattern structured light algorithm by leveraging built-in OpenCV functions and parallel code instead of raw loops, at the cost of a bit more memory (decoding a set of 96 5320x4600 images acquired using stereo cameras goes from taking ~100 seconds to taking ~2.5 seconds, in release mode)
- Automatically gain the ability to decode 16-bit images (switching from raw loops and uchar-indexing to OpenCV functions gives this for free)

Manual testing was done to ensure that the calculated results are correct, both for generation of the patterns and for decoding, in both Debug and Release mode, using real world data.
@Atari2 Atari2 force-pushed the greycodepattern_improvement_pr branch from bff58b8 to 441c955 Compare September 1, 2025 15:19
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.

1 participant