fix samples
authorAPrigarina <ann73617@gmail.com>
Tue, 29 Jun 2021 19:15:37 +0000 (22:15 +0300)
committerAPrigarina <ann73617@gmail.com>
Thu, 1 Jul 2021 15:26:17 +0000 (18:26 +0300)
samples/python/gaussian_mix.py
samples/python/hist.py
samples/python/morphology.py

index 6a656647ddcfc3bb39cb00b3b41bdb7540f7ea3f..4c1f86794cd66920d8eaa30c7fa0b635d289979e 100755 (executable)
@@ -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
index 157d5ff0ba3e59482e5966e82bb61504bdb62700..8c1f4546a817458fdf19d5d6b85b65d6f91dc8b4 100755 (executable)
@@ -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)
index 9ecf5b0682e7c8d6c8bafcfdc8d60c956bd99cd0..183f5e82881587d3b5a483ae81d892fc50e94a0e 100755 (executable)
@@ -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