Skip to content

Commit a2f7132

Browse files
committed
Merge pull request opencv#9460 from Cartucho:pylint_samples_py
2 parents 91f680a + 7555ab1 commit a2f7132

20 files changed

+43
-45
lines changed

samples/python/asift.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def match_and_draw(win):
155155
H, status = None, None
156156
print('%d matches found, not enough for homography estimation' % len(p1))
157157

158-
vis = explore_match(win, img1, img2, kp_pairs, None, H)
158+
explore_match(win, img1, img2, kp_pairs, None, H)
159159

160160

161161
match_and_draw('affine find_obj')

samples/python/browse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
small = cv2.pyrDown(small)
5454

5555
def onmouse(event, x, y, flags, param):
56-
h, w = img.shape[:2]
57-
h1, w1 = small.shape[:2]
56+
h, _w = img.shape[:2]
57+
h1, _w1 = small.shape[:2]
5858
x, y = 1.0*x*h/h1, 1.0*y*h/h1
5959
zoom = cv2.getRectSubPix(img, (800, 600), (x+0.5, y+0.5))
6060
cv2.imshow('zoom', zoom)

samples/python/camshift.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
class App(object):
4242
def __init__(self, video_src):
4343
self.cam = video.create_capture(video_src, presets['cube'])
44-
ret, self.frame = self.cam.read()
44+
_ret, self.frame = self.cam.read()
4545
cv2.namedWindow('camshift')
4646
cv2.setMouseCallback('camshift', self.onmouse)
4747

@@ -76,7 +76,7 @@ def show_hist(self):
7676

7777
def run(self):
7878
while True:
79-
ret, self.frame = self.cam.read()
79+
_ret, self.frame = self.cam.read()
8080
vis = self.frame.copy()
8181
hsv = cv2.cvtColor(self.frame, cv2.COLOR_BGR2HSV)
8282
mask = cv2.inRange(hsv, np.array((0., 60., 32.)), np.array((180., 255., 255.)))

samples/python/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,5 @@ def mdot(*args):
233233

234234
def draw_keypoints(vis, keypoints, color = (0, 255, 255)):
235235
for kp in keypoints:
236-
x, y = kp.pt
237-
cv2.circle(vis, (int(x), int(y)), 2, color)
236+
x, y = kp.pt
237+
cv2.circle(vis, (int(x), int(y)), 2, color)

samples/python/demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __init__(self):
9999
run_btn = tk.Button(right, command=self.on_run, text='Run', width=8)
100100

101101
self.text = text = ScrolledText(right, font=('arial', 12, 'normal'), width = 30, wrap='word')
102-
self.linker = linker = LinkManager(text, self.on_link)
102+
self.linker = _linker = LinkManager(text, self.on_link)
103103
self.text.tag_config("header1", font=('arial', 14, 'bold'))
104104
self.text.tag_config("header2", font=('arial', 12, 'bold'))
105105
text.config(state='disabled')

samples/python/digits.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def train(self, samples, responses):
8484
self.model.train(samples, cv2.ml.ROW_SAMPLE, responses)
8585

8686
def predict(self, samples):
87-
retval, results, neigh_resp, dists = self.model.findNearest(samples, self.k)
87+
_retval, results, _neigh_resp, _dists = self.model.findNearest(samples, self.k)
8888
return results.ravel()
8989

9090
class SVM(StatModel):

samples/python/digits_video.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def main():
3535
model.load_(classifier_fn) #Known bug: https://github.com/opencv/opencv/issues/4969
3636

3737
while True:
38-
ret, frame = cap.read()
38+
_ret, frame = cap.read()
3939
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
4040

4141

@@ -59,12 +59,12 @@ def main():
5959
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0))
6060

6161
bin_roi = bin[y:,x:][:h,:w]
62-
gray_roi = gray[y:,x:][:h,:w]
6362

6463
m = bin_roi != 0
6564
if not 0.1 < m.mean() < 0.4:
6665
continue
6766
'''
67+
gray_roi = gray[y:,x:][:h,:w]
6868
v_in, v_out = gray_roi[m], gray_roi[~m]
6969
if v_out.std() > 10.0:
7070
continue

samples/python/find_obj.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ def explore_match(win, img1, img2, kp_pairs, status = None, H = None):
9292

9393
green = (0, 255, 0)
9494
red = (0, 0, 255)
95-
white = (255, 255, 255)
9695
kp_color = (51, 103, 236)
9796
for (x1, y1), (x2, y2), inlier in zip(p1, p2, status):
9897
if inlier:
@@ -123,12 +122,12 @@ def onmouse(event, x, y, flags, param):
123122
idxs = np.where(m)[0]
124123
kp1s, kp2s = [], []
125124
for i in idxs:
126-
(x1, y1), (x2, y2) = p1[i], p2[i]
127-
col = (red, green)[status[i]]
128-
cv2.line(cur_vis, (x1, y1), (x2, y2), col)
129-
kp1, kp2 = kp_pairs[i]
130-
kp1s.append(kp1)
131-
kp2s.append(kp2)
125+
(x1, y1), (x2, y2) = p1[i], p2[i]
126+
col = (red, green)[status[i]]
127+
cv2.line(cur_vis, (x1, y1), (x2, y2), col)
128+
kp1, kp2 = kp_pairs[i]
129+
kp1s.append(kp1)
130+
kp2s.append(kp2)
132131
cur_vis = cv2.drawKeypoints(cur_vis, kp1s, None, flags=4, color=kp_color)
133132
cur_vis[:,w1:] = cv2.drawKeypoints(cur_vis[:,w1:], kp2s, None, flags=4, color=kp_color)
134133

@@ -183,7 +182,7 @@ def match_and_draw(win):
183182
H, status = None, None
184183
print('%d matches found, not enough for homography estimation' % len(p1))
185184

186-
vis = explore_match(win, img1, img2, kp_pairs, status, H)
185+
_vis = explore_match(win, img1, img2, kp_pairs, status, H)
187186

188187
match_and_draw('find_obj')
189188
cv2.waitKey()

samples/python/gaussian_mix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
def make_gaussians(cluster_n, img_size):
1616
points = []
1717
ref_distrs = []
18-
for i in xrange(cluster_n):
18+
for _i in xrange(cluster_n):
1919
mean = (0.1 + 0.8*random.rand(2)) * img_size
2020
a = (random.rand(2, 2)-0.5)*img_size*0.1
2121
cov = np.dot(a.T, a) + img_size*0.05*np.eye(2)
@@ -28,7 +28,7 @@ def make_gaussians(cluster_n, img_size):
2828

2929
def draw_gaussain(img, mean, cov, color):
3030
x, y = np.int32(mean)
31-
w, u, vt = cv2.SVDecomp(cov)
31+
w, u, _vt = cv2.SVDecomp(cov)
3232
ang = np.arctan2(u[1, 0], u[0, 0])*(180/np.pi)
3333
s1, s2 = np.sqrt(w)*3.0
3434
cv2.ellipse(img, (x, y), (s1, s2), ang, 0, 360, color, 1, cv2.LINE_AA)

samples/python/lappyr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
def build_lappyr(img, leveln=6, dtype=np.int16):
2929
img = dtype(img)
3030
levels = []
31-
for i in xrange(leveln-1):
31+
for _i in xrange(leveln-1):
3232
next_img = cv2.pyrDown(img)
3333
img1 = cv2.pyrUp(next_img, dstsize=getsize(img))
3434
levels.append(img-img1)

0 commit comments

Comments
 (0)