Skip to content

Commit

Permalink
Merge pull request #3264 from sturkmen72:update_python_samples
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed May 27, 2022
2 parents 9c4738b + a590a59 commit 84f8ea8
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion modules/stereo/samples/sample_quasi_dense.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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)
Expand Down
12 changes: 6 additions & 6 deletions modules/tracking/samples/multitracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

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()
Expand All @@ -25,17 +25,17 @@
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]))
Expand Down
4 changes: 2 additions & 2 deletions modules/tracking/samples/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
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.init(image, bbox)
init_once = True

ok, newbox = tracker.update(image)
print ok, newbox
print(ok, newbox)

if ok:
p1 = (int(newbox[0]), int(newbox[1]))
Expand Down
2 changes: 1 addition & 1 deletion modules/wechat_qrcode/samples/qrcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
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:
Expand Down
1 change: 0 additions & 1 deletion modules/ximgproc/samples/dericheSample.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def DericheFilter(self):
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)
Expand Down
2 changes: 1 addition & 1 deletion modules/ximgproc/samples/radon_transform_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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 changes: 2 additions & 5 deletions samples/python2/seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@
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]
Expand All @@ -41,7 +38,7 @@ def nothing(*arg):
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)
Expand Down

0 comments on commit 84f8ea8

Please sign in to comment.