mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Added python branch to stitching tutorial.
This commit is contained in:
parent
aa133cd899
commit
cb72a2131f
@ -23,18 +23,36 @@ In this tutorial you will learn how to:
|
|||||||
|
|
||||||
Code
|
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
|
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.
|
||||||
[here](https://github.com/opencv/opencv/tree/4.x/samples/cpp/stitching.cpp).
|
|
||||||
|
|
||||||
@include samples/cpp/stitching.cpp
|
@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
|
Explanation
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
The most important code part is:
|
The most important code part is:
|
||||||
|
|
||||||
|
@add_toggle_cpp
|
||||||
@snippet cpp/stitching.cpp stitching
|
@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
|
A new instance of stitcher is created and the @ref cv::Stitcher::stitch will
|
||||||
do all the hard work.
|
do all the hard work.
|
||||||
|
@ -43,12 +43,14 @@ def main():
|
|||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
imgs.append(img)
|
imgs.append(img)
|
||||||
|
|
||||||
|
#![stitching]
|
||||||
stitcher = cv.Stitcher.create(args.mode)
|
stitcher = cv.Stitcher.create(args.mode)
|
||||||
status, pano = stitcher.stitch(imgs)
|
status, pano = stitcher.stitch(imgs)
|
||||||
|
|
||||||
if status != cv.Stitcher_OK:
|
if status != cv.Stitcher_OK:
|
||||||
print("Can't stitch images, error code = %d" % status)
|
print("Can't stitch images, error code = %d" % status)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
#![stitching]
|
||||||
|
|
||||||
cv.imwrite(args.output, pano)
|
cv.imwrite(args.output, pano)
|
||||||
print("stitching completed successfully. %s saved!" % args.output)
|
print("stitching completed successfully. %s saved!" % args.output)
|
||||||
|
Loading…
Reference in New Issue
Block a user