Skip to content
Open
Show file tree
Hide file tree
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
36 changes: 36 additions & 0 deletions Python/QR_reader/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

import cv2
from pyzbar import pyzbar


def read_code(frame):
codes = pyzbar.decode(frame)
for code in codes:
x, y, w, h = code.rect
code_info = code.data.decode('utf-8')
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)

font = cv2.FONT_HERSHEY_DUPLEX
cv2.putText(frame, code_info, (x + 6, y - 6), font, 2.0, (255, 255, 255), 1)
with open("qr_code_result.txt", mode='w') as file:
file.write("Recognized code:" + code_info)
return frame


def readQR():
camera = cv2.VideoCapture(0)
ret, frame = camera.read()
while ret:
ret, frame = camera.read()
frame = read_code(frame)
cv2.imshow('QR code reader', frame)
if cv2.waitKey(1) & 0xFF == 27:
break
camera.release()
cv2.destroyAllWindows()


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
readQR()

2 changes: 2 additions & 0 deletions Python/QR_reader/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pyzbar==0.1.8
opencv-python==4.5.3.56
2 changes: 1 addition & 1 deletion contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@
* [Siddhant Srivastava](https://github.com/sidsrivastavasks)
* [Vijay Thkaur](https://github.com/Tiro-rex)
* [Alankar Singh](https://github.com/alankarartist)

* [Praveen Yadav](https://github.com/pky99)