mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #25268 from gursimarsingh:samples_cleanup_python
Removed obsolete python samples #25268 Clean Samples #25006 This PR removes 36 obsolete python samples from the project, as part of an effort to keep the codebase clean and focused on current best practices. Some of these samples will be updated with latest algorithms or will be combined with other existing samples. Removed Samples: > browse.py camshift.py coherence.py color_histogram.py contours.py deconvolution.py dft.py dis_opt_flow.py distrans.py edge.py feature_homography.py find_obj.py fitline.py gabor_threads.py hist.py houghcircles.py houghlines.py inpaint.py kalman.py kmeans.py laplace.py lk_homography.py lk_track.py logpolar.py mosse.py mser.py opt_flow.py plane_ar.py squares.py stitching.py text_skewness_correction.py texture_flow.py turing.py video_threaded.py video_v4l2.py watershed.py These changes aim to improve the repository's clarity and usability by removing examples that are no longer relevant or have been superseded by more up-to-date techniques.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
'''
|
||||
Stitching sample
|
||||
================
|
||||
|
||||
Show how to use Stitcher API from python in a simple way to stitch panoramas
|
||||
or scans.
|
||||
'''
|
||||
|
||||
# Python 2/3 compatibility
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import cv2 as cv
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
modes = (cv.Stitcher_PANORAMA, cv.Stitcher_SCANS)
|
||||
|
||||
parser = argparse.ArgumentParser(prog='stitching.py', description='Stitching sample.')
|
||||
parser.add_argument('--mode',
|
||||
type = int, choices = modes, default = cv.Stitcher_PANORAMA,
|
||||
help = 'Determines configuration of stitcher. The default is `PANORAMA` (%d), '
|
||||
'mode suitable for creating photo panoramas. Option `SCANS` (%d) is suitable '
|
||||
'for stitching materials under affine transformation, such as scans.' % modes)
|
||||
parser.add_argument('--output', default = 'result.jpg',
|
||||
help = 'Resulting image. The default is `result.jpg`.')
|
||||
parser.add_argument('img', nargs='+', help = 'input images')
|
||||
|
||||
__doc__ += '\n' + parser.format_help()
|
||||
|
||||
def main():
|
||||
args = parser.parse_args()
|
||||
|
||||
# read input images
|
||||
imgs = []
|
||||
for img_name in args.img:
|
||||
img = cv.imread(cv.samples.findFile(img_name))
|
||||
if img is None:
|
||||
print("can't read image " + img_name)
|
||||
sys.exit(-1)
|
||||
imgs.append(img)
|
||||
|
||||
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)
|
||||
|
||||
cv.imwrite(args.output, pano)
|
||||
print("stitching completed successfully. %s saved!" % args.output)
|
||||
|
||||
print('Done')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__)
|
||||
main()
|
||||
cv.destroyAllWindows()
|
||||
Reference in New Issue
Block a user