Skip to content
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

Sourcery Starbot ⭐ refactored Luciferyzl/cv_tutorial #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions qr_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def line_cross(line1, line2):
b2 = y3 * 1.0 - x3 * k2 * 1.0

if k1 is None:
if not k2 is None:
if k2 is not None:
Copy link
Author

Choose a reason for hiding this comment

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

Function line_cross refactored with the following changes:

  • Simplify logical expression using De Morgan identities [×2] (de-morgan)

x = x1
y = k2 * x1 + b2
cross_p = [x,y]
elif k2 is None:
x = x3
y = k1 * x3 + b1
cross_p = [x,y]
elif not k2 == k1:
elif k2 != k1:
x = (b2 - b1) * 1.0 / (k1 - k2)
y = k1 * x * 1.0 + b1 * 1.0
cross_p = [x,y]
Expand All @@ -58,15 +58,15 @@ def detect(img):
l1 = (pts[0].x, pts[0].y, pts[2].x, pts[2].y)
l2 = (pts[1].x, pts[1].y, pts[3].x, pts[3].y)
cp = line_cross(l1,l2)
if not cp is None:
if cp is not None:
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 refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

qr_detect.append({'cx':cp[0],'cy':cp[1],'label':code})
return qr_detect


ports = [8080,8081]
for port in ports:
try:
resp = requests.get('http://192.168.0.88:{}/?action=snapshot'.format(port),timeout=2)
resp = requests.get(f'http://192.168.0.88:{port}/?action=snapshot', timeout=2)
Copy link
Author

Choose a reason for hiding this comment

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

Lines 69-69 refactored with the following changes:

if resp.ok:
continue
# f = open('{}.jpg'.format(port),'rb')
Expand Down