From 0f24d4d2a14d8f79eaa4ca0710d7770aeeb833f2 Mon Sep 17 00:00:00 2001 From: APrigarina Date: Tue, 29 Jun 2021 22:15:37 +0300 Subject: [PATCH] fix samples --- samples/python/gaussian_mix.py | 2 +- samples/python/hist.py | 2 +- samples/python/morphology.py | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/samples/python/gaussian_mix.py b/samples/python/gaussian_mix.py index 6a656647dd..4c1f86794c 100755 --- a/samples/python/gaussian_mix.py +++ b/samples/python/gaussian_mix.py @@ -28,7 +28,7 @@ def make_gaussians(cluster_n, img_size): return points, ref_distrs def draw_gaussain(img, mean, cov, color): - x, y = np.int32(mean) + x, y = mean w, u, _vt = cv.SVDecomp(cov) ang = np.arctan2(u[1, 0], u[0, 0])*(180/np.pi) s1, s2 = np.sqrt(w)*3.0 diff --git a/samples/python/hist.py b/samples/python/hist.py index 157d5ff0ba..8c1f4546a8 100755 --- a/samples/python/hist.py +++ b/samples/python/hist.py @@ -46,7 +46,7 @@ def hist_lines(im): im = cv.cvtColor(im,cv.COLOR_BGR2GRAY) hist_item = cv.calcHist([im],[0],None,[256],[0,256]) cv.normalize(hist_item,hist_item,0,255,cv.NORM_MINMAX) - hist=np.int32(np.around(hist_item)) + hist = np.int32(np.around(hist_item)) for x,y in enumerate(hist): cv.line(h,(x,0),(x,y[0]),(255,255,255)) y = np.flipud(h) diff --git a/samples/python/morphology.py b/samples/python/morphology.py index 9ecf5b0682..183f5e8288 100755 --- a/samples/python/morphology.py +++ b/samples/python/morphology.py @@ -50,8 +50,11 @@ def main(): cur_str_mode = str_modes.next() def update(dummy=None): - sz = cv.getTrackbarPos('op/size', 'morphology') - iters = cv.getTrackbarPos('iters', 'morphology') + try: # do not get trackbar position while trackbar is not created + sz = cv.getTrackbarPos('op/size', 'morphology') + iters = cv.getTrackbarPos('iters', 'morphology') + except: + return opers = cur_mode.split('/') if len(opers) > 1: sz = sz - 10