Merge pull request #21501 from sturkmen72:update_samples

pull/21512/head
Alexander Alekhin 3 years ago
commit 92af03579c
  1. 15
      samples/python/camera_calibration_show_extrinsics.py
  2. 2
      samples/python/common.py
  3. 1
      samples/python/digits.py
  4. 2
      samples/python/digits_video.py
  5. 6
      samples/python/facedetect.py
  6. 2
      samples/python/qrcode.py
  7. 10
      samples/python/text_skewness_correction.py

@ -1,5 +1,18 @@
#!/usr/bin/env python #!/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 # Python 2/3 compatibility
from __future__ import print_function from __future__ import print_function

@ -222,7 +222,7 @@ def mosaic(w, imgs):
pad = np.zeros_like(img0) pad = np.zeros_like(img0)
imgs = it.chain([img0], imgs) imgs = it.chain([img0], imgs)
rows = grouper(w, imgs, pad) rows = grouper(w, imgs, pad)
return np.vstack(map(np.hstack, rows)) return np.vstack(list(map(np.hstack, rows)))
def getsize(img): def getsize(img):
h, w = img.shape[:2] h, w = img.shape[:2]

@ -191,3 +191,4 @@ if __name__ == '__main__':
model.save('digits_svm.dat') model.save('digits_svm.dat')
cv.waitKey(0) cv.waitKey(0)
cv.destroyAllWindows()

@ -29,7 +29,7 @@ def main():
src = sys.argv[1] src = sys.argv[1]
except: except:
src = 0 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' classifier_fn = 'digits_svm.dat'
if not os.path.exists(classifier_fn): if not os.path.exists(classifier_fn):

@ -39,13 +39,13 @@ def main():
except: except:
video_src = 0 video_src = 0
args = dict(args) args = dict(args)
cascade_fn = args.get('--cascade', "data/haarcascades/haarcascade_frontalface_alt.xml") cascade_fn = args.get('--cascade', "haarcascades/haarcascade_frontalface_alt.xml")
nested_fn = args.get('--nested-cascade', "data/haarcascades/haarcascade_eye.xml") nested_fn = args.get('--nested-cascade', "haarcascades/haarcascade_eye.xml")
cascade = cv.CascadeClassifier(cv.samples.findFile(cascade_fn)) cascade = cv.CascadeClassifier(cv.samples.findFile(cascade_fn))
nested = cv.CascadeClassifier(cv.samples.findFile(nested_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: while True:
_ret, img = cam.read() _ret, img = cam.read()

@ -245,4 +245,6 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
print(__doc__)
main() main()
cv.destroyAllWindows()

@ -15,7 +15,7 @@ import argparse
def main(): def main():
parser = argparse.ArgumentParser() 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()) args = vars(parser.parse_args())
# load the image from disk # load the image from disk
@ -37,9 +37,9 @@ def main():
coords = cv.findNonZero(thresh) coords = cv.findNonZero(thresh)
angle = cv.minAreaRect(coords)[-1] angle = cv.minAreaRect(coords)[-1]
# the `cv.minAreaRect` function returns values in the # 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 # range [0, 90) if the angle is more than 45 we need to subtract 90 from it
if angle < -45: if angle > 45:
angle = (90 + angle) angle = (angle - 90)
(h, w) = image.shape[:2] (h, w) = image.shape[:2]
center = (w // 2, h // 2) center = (w // 2, h // 2)
@ -55,4 +55,6 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
print(__doc__)
main() main()
cv.destroyAllWindows()

Loading…
Cancel
Save