Skip to content

Sourcery refactored master branch #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jul 21, 2023

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from schild July 21, 2023 06:17
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

self.windows = dict()
self.windows = {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function opencv_windows_management.__init__ refactored with the following changes:

@@ -12,6 +12,7 @@

"""

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 39-46 refactored with the following changes:

This removes the following comments ( why? ):

#TODO 分辨率太大,需要缩放
# if t.any():
# if temp == img:
# t = temp == img
# if t.all():

cv2.imshow('frame_no'+str(frame_no), frame)
cv2.imshow(f'frame_no{frame_no}', frame)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 27-27 refactored with the following changes:

Comment on lines -21 to +29
if ret is True:

frame = cv2.resize(frame, (640, 480))
if ret is not True:
break

# write the flipped frame
out.write(frame)
frame = cv2.resize(frame, (640, 480))

cv2.imshow('frame', frame)
# write the flipped frame
out.write(frame)

else:
break
cv2.imshow('frame', frame)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 21-31 refactored with the following changes:

cv2.imwrite(id_generator() + '.jpg', frame)
cv2.imwrite(f'{id_generator()}.jpg', frame)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 32-32 refactored with the following changes:

y = np.flipud(h)
return y
return np.flipud(h)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function hist_curve refactored with the following changes:

plt.suptitle('method: ' + meth)
plt.suptitle(f'method: {meth}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 56-56 refactored with the following changes:

Comment on lines -53 to +62
cv2.imwrite(id_generator() + '.jpg', frame2)
cv2.imwrite(f'{id_generator()}.jpg', frame2)

# Capture frame-by-frame
ret, frame = cap.read()
m = mse(cv2.cvtColor(temp, cv2.COLOR_BGR2GRAY), cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY))
print('mse', m, '----\n')
if abs(m - tm) < 2: # 静止画面,不用重复计算
if abs(m - tm) < 2:
continue
else:
temp = frame.copy()
tm = m
temp = frame.copy()
tm = m
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 53-63 refactored with the following changes:

This removes the following comments ( why? ):

# 静止画面,不用重复计算

Comment on lines -18 to +23
txt = 'black'
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ret, threshold = cv2.threshold(gray, 100, 255, cv2.THRESH_BINARY)

c = Counter(list(threshold.flatten()))
print(c.most_common())
if c.most_common()[0][0] != 0:
txt = 'white'
txt = 'white' if c.most_common()[0][0] != 0 else 'black'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function detect_weiqi refactored with the following changes:

# Apply ratio test
# 比值测试,首先获取与 A距离最近的点 B (最近)和 C (次近),
# 只有当 B/C 小于阀值时(0.75)才被认为是匹配,
# 因为假设匹配是一一对应的,真正的匹配的理想距离为0
good = []
for m, n in matches:
if m.distance < 0.75 * n.distance:
good.append([m])

good = [[m] for m, n in matches if m.distance < 0.75 * n.distance]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 28-36 refactored with the following changes:

This removes the following comments ( why? ):

# Apply ratio test
# 比值测试,首先获取与 A距离最近的点 B (最近)和 C (次近),
# 因为假设匹配是一一对应的,真正的匹配的理想距离为0
# 只有当 B/C 小于阀值时(0.75)才被认为是匹配,

@@ -15,6 +15,7 @@

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 41-41 refactored with the following changes:

@@ -8,6 +8,7 @@
findHomography.py:联合使用特征提取和 calib3d 模块中的 findHomography 在复杂图像中查找已知对象
"""

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 31-35 refactored with the following changes:

This removes the following comments ( why? ):

# store all the good matches as per Lowe's ratio test.

cv2.imwrite(fname[:6] + '.png', img)
cv2.imwrite(f'{fname[:6]}.png', img)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 75-75 refactored with the following changes:

for i, (m, n) in enumerate(matches):
for m, n in matches:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 67-67 refactored with the following changes:

hist = np.hstack(hists) # hist is a 64 bit vector
return hist
return np.hstack(hists)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function hog refactored with the following changes:

This removes the following comments ( why? ):

# hist is a 64 bit vector

print("[INFO] processing image {}/{}".format(i + 1, len(captcha_image_files)))
print(f"[INFO] processing image {i + 1}/{len(captcha_image_files)}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 18-88 refactored with the following changes:

Comment on lines -60 to +62
letter_image_regions.append((x, y, half_width, h))
letter_image_regions.append((x + half_width, y, half_width, h))
letter_image_regions.extend(
((x, y, half_width, h), (x + half_width, y, half_width, h))
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 60-108 refactored with the following changes:

# taking only 10% of histogram diff, since it's less accurate than template method
commutative_image_diff = (img_hist_diff / 10) + img_template_diff
return commutative_image_diff
return (img_hist_diff / 10) + img_template_diff
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_image_difference refactored with the following changes:

This removes the following comments ( why? ):

# taking only 10% of histogram diff, since it's less accurate than template method

Comment on lines -45 to +50
text = "{} ({})".format(barcodeData, barcodeType)
text = f"{barcodeData} ({barcodeType})"
cv2.putText(image, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (0, 0, 255), 2)

# print the barcode type and data to the terminal
print("[INFO] Found {} barcode: {}".format(barcodeType, barcodeData))
print(f"[INFO] Found {barcodeType} barcode: {barcodeData}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

@@ -4,6 +4,7 @@
Utility for measuring python opencv API coverage by samples.
'''

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 15-15 refactored with the following changes:

if pool is None:
ires = it.imap(f, params)
else:
ires = pool.imap(f, params)

ires = it.imap(f, params) if pool is None else pool.imap(f, params)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function affine_detect refactored with the following changes:

@@ -13,6 +13,7 @@
<image mask> defaults to ../data/left*.jpg
'''

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 37-109 refactored with the following changes:

This removes the following comments ( why? ):

# default

M = np.float64([[ cx, 0, tx],
[ 0, cy, ty],
[ 0, 0, 1]])
return M
return np.float64([[cx, 0, tx], [0, cy, ty], [0, 0, 1]])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function rect2rect_mtx refactored with the following changes:

Comment on lines -205 to +206
if PY3:
output = it.zip_longest(fillvalue=fillvalue, *args)
else:
output = it.izip_longest(fillvalue=fillvalue, *args)
return output
return (
it.zip_longest(fillvalue=fillvalue, *args)
if PY3
else it.izip_longest(fillvalue=fillvalue, *args)
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function grouper refactored with the following changes:

Comment on lines -218 to +215
if PY3:
img0 = next(imgs)
else:
img0 = imgs.next()
img0 = next(imgs) if PY3 else imgs.next()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function mosaic refactored with the following changes:

if PY3:
cur_func_name = next(dist_func_names)
else:
cur_func_name = dist_func_names.next()
cur_func_name = next(dist_func_names) if PY3 else dist_func_names.next()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 52-55 refactored with the following changes:

Comment on lines -93 to +90
if PY3:
cur_func_name = next(dist_func_names)
else:
cur_func_name = dist_func_names.next()
cur_func_name = next(dist_func_names) if PY3 else dist_func_names.next()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 93-96 refactored with the following changes:

for i in xrange(cluster_n):
for _ in xrange(cluster_n):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function make_gaussians refactored with the following changes:

y=np.flipud(h)
return y
return np.flipud(h)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function hist_curve refactored with the following changes:

@@ -8,6 +8,7 @@
image argument defaults to ../data/pic1.png
'''

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 31-51 refactored with the following changes:

This removes the following comments ( why? ):

# HoughLines
# HoughLinesP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants