mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 11:10:21 +08:00
Merge pull request #21501 from sturkmen72:update_samples
This commit is contained in:
commit
92af03579c
@ -1,5 +1,18 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
'''
|
||||
Plot camera calibration extrinsics.
|
||||
|
||||
usage:
|
||||
camera_calibration_show_extrinsics.py [--calibration <input path>] [--cam_width] [--cam_height] [--scale_focal] [--patternCentric ]
|
||||
|
||||
default values:
|
||||
--calibration : left_intrinsics.yml
|
||||
--cam_width : 0.064/2
|
||||
--cam_height : 0.048/2
|
||||
--scale_focal : 40
|
||||
--patternCentric : True
|
||||
'''
|
||||
|
||||
# Python 2/3 compatibility
|
||||
from __future__ import print_function
|
||||
|
@ -222,7 +222,7 @@ def mosaic(w, imgs):
|
||||
pad = np.zeros_like(img0)
|
||||
imgs = it.chain([img0], imgs)
|
||||
rows = grouper(w, imgs, pad)
|
||||
return np.vstack(map(np.hstack, rows))
|
||||
return np.vstack(list(map(np.hstack, rows)))
|
||||
|
||||
def getsize(img):
|
||||
h, w = img.shape[:2]
|
||||
|
@ -191,3 +191,4 @@ if __name__ == '__main__':
|
||||
model.save('digits_svm.dat')
|
||||
|
||||
cv.waitKey(0)
|
||||
cv.destroyAllWindows()
|
||||
|
@ -29,7 +29,7 @@ def main():
|
||||
src = sys.argv[1]
|
||||
except:
|
||||
src = 0
|
||||
cap = video.create_capture(src)
|
||||
cap = video.create_capture(src, fallback='synth:bg={}:noise=0.05'.format(cv.samples.findFile('sudoku.png')))
|
||||
|
||||
classifier_fn = 'digits_svm.dat'
|
||||
if not os.path.exists(classifier_fn):
|
||||
|
@ -39,13 +39,13 @@ def main():
|
||||
except:
|
||||
video_src = 0
|
||||
args = dict(args)
|
||||
cascade_fn = args.get('--cascade', "data/haarcascades/haarcascade_frontalface_alt.xml")
|
||||
nested_fn = args.get('--nested-cascade', "data/haarcascades/haarcascade_eye.xml")
|
||||
cascade_fn = args.get('--cascade', "haarcascades/haarcascade_frontalface_alt.xml")
|
||||
nested_fn = args.get('--nested-cascade', "haarcascades/haarcascade_eye.xml")
|
||||
|
||||
cascade = cv.CascadeClassifier(cv.samples.findFile(cascade_fn))
|
||||
nested = cv.CascadeClassifier(cv.samples.findFile(nested_fn))
|
||||
|
||||
cam = create_capture(video_src, fallback='synth:bg={}:noise=0.05'.format(cv.samples.findFile('samples/data/lena.jpg')))
|
||||
cam = create_capture(video_src, fallback='synth:bg={}:noise=0.05'.format(cv.samples.findFile('lena.jpg')))
|
||||
|
||||
while True:
|
||||
_ret, img = cam.read()
|
||||
|
@ -245,4 +245,6 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__)
|
||||
main()
|
||||
cv.destroyAllWindows()
|
||||
|
@ -15,7 +15,7 @@ import argparse
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-i", "--image", required=True, help="path to input image file")
|
||||
parser.add_argument("-i", "--image", default="imageTextR.png", help="path to input image file")
|
||||
args = vars(parser.parse_args())
|
||||
|
||||
# load the image from disk
|
||||
@ -37,9 +37,9 @@ def main():
|
||||
coords = cv.findNonZero(thresh)
|
||||
angle = cv.minAreaRect(coords)[-1]
|
||||
# the `cv.minAreaRect` function returns values in the
|
||||
# range [-90, 0) if the angle is less than -45 we need to add 90 to it
|
||||
if angle < -45:
|
||||
angle = (90 + angle)
|
||||
# range [0, 90) if the angle is more than 45 we need to subtract 90 from it
|
||||
if angle > 45:
|
||||
angle = (angle - 90)
|
||||
|
||||
(h, w) = image.shape[:2]
|
||||
center = (w // 2, h // 2)
|
||||
@ -55,4 +55,6 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(__doc__)
|
||||
main()
|
||||
cv.destroyAllWindows()
|
||||
|
Loading…
Reference in New Issue
Block a user