Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
AgriTech
Mobile Autonomous Cart with guided Vision for Agriculture
Commits
0562bb7c
Commit
0562bb7c
authored
Jul 19, 2021
by
Roshan Singh
Browse files
QR Code python
parent
44f99d08
Changes
1
Hide whitespace changes
Inline
Side-by-side
qrprocess.py
0 → 100644
View file @
0562bb7c
import
cv2
# set up camera object
cap
=
cv2
.
VideoCapture
(
0
)
# QR code detection object
detector
=
cv2
.
QRCodeDetector
()
while
True
:
# get the image
_
,
img
=
cap
.
read
()
# get bounding box coords and data
data
,
bbox
,
_
=
detector
.
detectAndDecode
(
img
)
# if there is a bounding box, draw one, along with the data
if
(
bbox
is
not
None
):
for
i
in
range
(
len
(
bbox
)):
cv2
.
line
(
img
,
tuple
(
bbox
[
i
][
0
]),
tuple
(
bbox
[(
i
+
1
)
%
len
(
bbox
)][
0
]),
color
=
(
255
,
0
,
255
),
thickness
=
2
)
cv2
.
putText
(
img
,
data
,
(
int
(
bbox
[
0
][
0
][
0
]),
int
(
bbox
[
0
][
0
][
1
])
-
10
),
cv2
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
(
0
,
255
,
0
),
2
)
if
data
:
print
(
"data found: "
,
data
)
# display the image preview
cv2
.
imshow
(
"code detector"
,
img
)
if
(
cv2
.
waitKey
(
1
)
==
ord
(
"q"
)):
break
# free camera object and exit
cap
.
release
()
cv2
.
destroyAllWindows
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment