Browse Source

update python samples

pull/3264/head
Suleyman TURKMEN 3 years ago
parent
commit
a590a59055
  1. 2
      modules/stereo/samples/sample_quasi_dense.py
  2. 12
      modules/tracking/samples/multitracker.py
  3. 4
      modules/tracking/samples/tracker.py
  4. 2
      modules/wechat_qrcode/samples/qrcode.py
  5. 1
      modules/ximgproc/samples/dericheSample.py
  6. 2
      modules/ximgproc/samples/radon_transform_demo.py
  7. 7
      samples/python2/seeds.py

2
modules/stereo/samples/sample_quasi_dense.py

@ -4,7 +4,7 @@ import cv2 as cv @@ -4,7 +4,7 @@ import cv2 as cv
left_img = cv.imread(cv.samples.findFile("aloeL.jpg"), cv.IMREAD_COLOR)
right_img = cv.imread(cv.samples.findFile("aloeR.jpg"), cv.IMREAD_COLOR)
frame_size = leftImg.shape[0:2];
frame_size = left_img.shape[0:2];
stereo = cv.stereo.QuasiDenseStereo_create(frame_size[::-1])
stereo.process(left_img, right_img)

12
modules/tracking/samples/multitracker.py

@ -10,7 +10,7 @@ print('Select 3 tracking targets') @@ -10,7 +10,7 @@ print('Select 3 tracking targets')
cv.namedWindow("tracking")
camera = cv.VideoCapture(sys.argv[1])
tracker = cv.MultiTracker_create()
tracker = cv.legacy.MultiTracker_create()
init_once = False
ok, image=camera.read()
@ -25,17 +25,17 @@ bbox3 = cv.selectROI('tracking', image) @@ -25,17 +25,17 @@ bbox3 = cv.selectROI('tracking', image)
while camera.isOpened():
ok, image=camera.read()
if not ok:
print 'no image to read'
print('no image to read')
break
if not init_once:
ok = tracker.add(cv.TrackerMIL_create(), image, bbox1)
ok = tracker.add(cv.TrackerMIL_create(), image, bbox2)
ok = tracker.add(cv.TrackerMIL_create(), image, bbox3)
ok = tracker.add(cv.legacy.TrackerMIL_create(), image, bbox1)
ok = tracker.add(cv.legacy.TrackerMIL_create(), image, bbox2)
ok = tracker.add(cv.legacy.TrackerMIL_create(), image, bbox3)
init_once = True
ok, boxes = tracker.update(image)
print ok, boxes
print(ok, boxes)
for newbox in boxes:
p1 = (int(newbox[0]), int(newbox[1]))

4
modules/tracking/samples/tracker.py

@ -19,7 +19,7 @@ init_once = False @@ -19,7 +19,7 @@ init_once = False
while camera.isOpened():
ok, image=camera.read()
if not ok:
print 'no image to read'
print('no image to read')
break
if not init_once:
@ -27,7 +27,7 @@ while camera.isOpened(): @@ -27,7 +27,7 @@ while camera.isOpened():
init_once = True
ok, newbox = tracker.update(image)
print ok, newbox
print(ok, newbox)
if ok:
p1 = (int(newbox[0]), int(newbox[1]))

2
modules/wechat_qrcode/samples/qrcode.py

@ -37,7 +37,7 @@ else: @@ -37,7 +37,7 @@ else:
cap = cv2.VideoCapture(camIdx)
while True:
res, img = cap.read()
if img.empty():
if img is None:
break
res, points = detector.detectAndDecode(img)
for t in res:

1
modules/ximgproc/samples/dericheSample.py

@ -28,7 +28,6 @@ class Filtrage: @@ -28,7 +28,6 @@ class Filtrage:
self.module = np.sqrt(dx2+dy2)
cv.normalize(src=self.module,dst=self.module,norm_type=cv.NORM_MINMAX)
def SlideBarDeriche(self):
cv.destroyWindow(self.filename)
cv.namedWindow(self.filename)
AddSlider("alpha",self.filename,1,400,self.alpha,self.UpdateAlpha)
AddSlider("omega",self.filename,1,1000,self.omega,self.UpdateOmega)

2
modules/ximgproc/samples/radon_transform_demo.py

@ -7,7 +7,7 @@ import cv2 as cv @@ -7,7 +7,7 @@ import cv2 as cv
if __name__ == "__main__":
src = cv.imread("peilin_plane.png", cv.IMREAD_GRAYSCALE)
radon = cv.ximgproc.RadonTransform(src)
radon = cv.ximgproc.RadonTransform(src).astype(np.float32)
cv.imshow("src image", src)
cv.imshow("Radon transform", radon)
cv.waitKey()

7
samples/python2/seeds.py

@ -12,15 +12,12 @@ Usage: @@ -12,15 +12,12 @@ Usage:
import numpy as np
import cv2 as cv
# relative module
import video
# built-in module
import sys
if __name__ == '__main__':
print __doc__
print(__doc__)
try:
fn = sys.argv[1]
@ -41,7 +38,7 @@ if __name__ == '__main__': @@ -41,7 +38,7 @@ if __name__ == '__main__':
num_levels = 4
num_histogram_bins = 5
cap = video.create_capture(fn)
cap = cv.VideoCapture(fn)
while True:
flag, img = cap.read()
converted_img = cv.cvtColor(img, cv.COLOR_BGR2HSV)

Loading…
Cancel
Save