From cb72a2131f04934b22538a25a7d37e809c1d7826 Mon Sep 17 00:00:00 2001 From: ericmariasis Date: Thu, 1 Aug 2024 16:32:27 -0400 Subject: [PATCH] Added python branch to stitching tutorial. --- doc/tutorials/others/stitcher.markdown | 22 ++++++++++++++++++++-- samples/python/stitching.py | 2 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/doc/tutorials/others/stitcher.markdown b/doc/tutorials/others/stitcher.markdown index d1ea5af312..5f22beacd7 100644 --- a/doc/tutorials/others/stitcher.markdown +++ b/doc/tutorials/others/stitcher.markdown @@ -23,18 +23,36 @@ In this tutorial you will learn how to: Code ---- +@add_toggle_cpp +This tutorial's code is shown in the lines below. You can download it from [here](https://github.com/opencv/opencv/tree/4.x/samples/cpp/stitching.cpp). -This tutorial code's is shown lines below. You can also download it from -[here](https://github.com/opencv/opencv/tree/4.x/samples/cpp/stitching.cpp). +Note: The C++ version includes additional options such as image division (--d3) and more detailed error handling, which are not present in the Python example. @include samples/cpp/stitching.cpp +@end_toggle + +@add_toggle_python +This tutorial's code is shown in the lines below. You can download it from [here](https://github.com/opencv/opencv/blob/4.x/samples/python/stitching.py). + +Note: The C++ version includes additional options such as image division (--d3) and more detailed error handling, which are not present in the Python example. + +@include samples/python/stitching.py + +@end_toggle + Explanation ----------- The most important code part is: +@add_toggle_cpp @snippet cpp/stitching.cpp stitching +@end_toggle + +@add_toggle_python +@snippet python/stitching.py stitching +@end_toggle A new instance of stitcher is created and the @ref cv::Stitcher::stitch will do all the hard work. diff --git a/samples/python/stitching.py b/samples/python/stitching.py index 18a160ec5b..b0c7d05f8a 100644 --- a/samples/python/stitching.py +++ b/samples/python/stitching.py @@ -43,12 +43,14 @@ def main(): sys.exit(-1) imgs.append(img) + #![stitching] stitcher = cv.Stitcher.create(args.mode) status, pano = stitcher.stitch(imgs) if status != cv.Stitcher_OK: print("Can't stitch images, error code = %d" % status) sys.exit(-1) + #![stitching] cv.imwrite(args.output, pano) print("stitching completed successfully. %s saved!" % args.output)