Skip to content

Refactor stitching detailed python#20723

Closed
lukasalexanderweber wants to merge 71 commits intoopencv:masterfrom
lukasalexanderweber:refactor_stitching_detailed_python
Closed

Refactor stitching detailed python#20723
lukasalexanderweber wants to merge 71 commits intoopencv:masterfrom
lukasalexanderweber:refactor_stitching_detailed_python

Conversation

@lukasalexanderweber
Copy link
Copy Markdown
Contributor

The advanced stitching example stitching_detailed.py is a big script with awesome functionality. It is, however, very long and a bit unstructured to grasp what's going on. It's by far the most complex script in the python samples folder:

samples_line_distribution

There is, however, a very clear pipeline description:

pipeline

I changed the stitching_detailed.py so that it only contains the argument parser. At the end, the functionality of the stitcher class is called. The stitcher class follows precisely the stitching pipeline of the image. Unlike in the original program, the intermediate results can be obtained and analysed easily.

I didn't changed much of the functionality, the most work was done in structuring the functionality. I added the possibility to specify the number of features (default 500) in the Feature Detection step, since 500 features are not enough for my REALY big plans (see this issue/question).

Additionally, I added functionality to subset the matches and cameras, which was not done in the original file. If there are noise images at the beginning, this leads to significant artefacts:

python stitching_detailed.py s1.jpg s2.jpg boat5.jpg boat2.jpg boat3.jpg boat4.jpg boat1.jpg boat6.jpg --compose_megapix 3 --output boat_default_with_noise_original.jpg --save_graph boat_default_with_noise_original.txt

boat_default_with_noise_original

With the proposed changes, this is not an issue anymore. The performance speed is the same as before the restructuring, the RAM needed reduced for the boat example from 130MB to 95MB. See test_performance.py. The tests can be found here. With a view to the tutorial, I tested different settings for the boat example as well as the affine example of the budapest map within test_stitcher.py

Background: I need to stitch >10000 plans of waterway-infrastructure buildings. During digitalization, the scanner was too small for the whole plan. There are overlaps that allow the use of the stitching algorithm and I'm thankful that OpenCV contains the stitcher module. For documentation purposes for my work I wanted to structure the code and now hope to discuss if the changes might could merged into the opencv master branch.

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 other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to 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

Lukas Weber added 30 commits July 29, 2021 10:19
…s to move warped_image_scale declaration in composition part
@lukasalexanderweber
Copy link
Copy Markdown
Contributor Author

If accepted, we can squash the commits when merging the pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants