Skip to content

Commit a590a59

Browse files
committed
update python samples
1 parent 47d476e commit a590a59

File tree

7 files changed

+13
-17
lines changed

7 files changed

+13
-17
lines changed

modules/stereo/samples/sample_quasi_dense.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
left_img = cv.imread(cv.samples.findFile("aloeL.jpg"), cv.IMREAD_COLOR)
55
right_img = cv.imread(cv.samples.findFile("aloeR.jpg"), cv.IMREAD_COLOR)
66

7-
frame_size = leftImg.shape[0:2];
7+
frame_size = left_img.shape[0:2];
88

99
stereo = cv.stereo.QuasiDenseStereo_create(frame_size[::-1])
1010
stereo.process(left_img, right_img)

modules/tracking/samples/multitracker.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
cv.namedWindow("tracking")
1212
camera = cv.VideoCapture(sys.argv[1])
13-
tracker = cv.MultiTracker_create()
13+
tracker = cv.legacy.MultiTracker_create()
1414
init_once = False
1515

1616
ok, image=camera.read()
@@ -25,17 +25,17 @@
2525
while camera.isOpened():
2626
ok, image=camera.read()
2727
if not ok:
28-
print 'no image to read'
28+
print('no image to read')
2929
break
3030

3131
if not init_once:
32-
ok = tracker.add(cv.TrackerMIL_create(), image, bbox1)
33-
ok = tracker.add(cv.TrackerMIL_create(), image, bbox2)
34-
ok = tracker.add(cv.TrackerMIL_create(), image, bbox3)
32+
ok = tracker.add(cv.legacy.TrackerMIL_create(), image, bbox1)
33+
ok = tracker.add(cv.legacy.TrackerMIL_create(), image, bbox2)
34+
ok = tracker.add(cv.legacy.TrackerMIL_create(), image, bbox3)
3535
init_once = True
3636

3737
ok, boxes = tracker.update(image)
38-
print ok, boxes
38+
print(ok, boxes)
3939

4040
for newbox in boxes:
4141
p1 = (int(newbox[0]), int(newbox[1]))

modules/tracking/samples/tracker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
while camera.isOpened():
2020
ok, image=camera.read()
2121
if not ok:
22-
print 'no image to read'
22+
print('no image to read')
2323
break
2424

2525
if not init_once:
2626
ok = tracker.init(image, bbox)
2727
init_once = True
2828

2929
ok, newbox = tracker.update(image)
30-
print ok, newbox
30+
print(ok, newbox)
3131

3232
if ok:
3333
p1 = (int(newbox[0]), int(newbox[1]))

modules/wechat_qrcode/samples/qrcode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
cap = cv2.VideoCapture(camIdx)
3838
while True:
3939
res, img = cap.read()
40-
if img.empty():
40+
if img is None:
4141
break
4242
res, points = detector.detectAndDecode(img)
4343
for t in res:

modules/ximgproc/samples/dericheSample.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def DericheFilter(self):
2828
self.module = np.sqrt(dx2+dy2)
2929
cv.normalize(src=self.module,dst=self.module,norm_type=cv.NORM_MINMAX)
3030
def SlideBarDeriche(self):
31-
cv.destroyWindow(self.filename)
3231
cv.namedWindow(self.filename)
3332
AddSlider("alpha",self.filename,1,400,self.alpha,self.UpdateAlpha)
3433
AddSlider("omega",self.filename,1,1000,self.omega,self.UpdateOmega)

modules/ximgproc/samples/radon_transform_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
if __name__ == "__main__":
99
src = cv.imread("peilin_plane.png", cv.IMREAD_GRAYSCALE)
10-
radon = cv.ximgproc.RadonTransform(src)
10+
radon = cv.ximgproc.RadonTransform(src).astype(np.float32)
1111
cv.imshow("src image", src)
1212
cv.imshow("Radon transform", radon)
1313
cv.waitKey()

samples/python2/seeds.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@
1212
import numpy as np
1313
import cv2 as cv
1414

15-
# relative module
16-
import video
17-
1815
# built-in module
1916
import sys
2017

2118

2219
if __name__ == '__main__':
23-
print __doc__
20+
print(__doc__)
2421

2522
try:
2623
fn = sys.argv[1]
@@ -41,7 +38,7 @@ def nothing(*arg):
4138
num_levels = 4
4239
num_histogram_bins = 5
4340

44-
cap = video.create_capture(fn)
41+
cap = cv.VideoCapture(fn)
4542
while True:
4643
flag, img = cap.read()
4744
converted_img = cv.cvtColor(img, cv.COLOR_BGR2HSV)

0 commit comments

Comments
 (0)