diff --git a/Python/QR_reader/main.py b/Python/QR_reader/main.py new file mode 100644 index 00000000..6949cc9d --- /dev/null +++ b/Python/QR_reader/main.py @@ -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() + diff --git a/Python/QR_reader/requirements.txt b/Python/QR_reader/requirements.txt new file mode 100644 index 00000000..b632ee1b --- /dev/null +++ b/Python/QR_reader/requirements.txt @@ -0,0 +1,2 @@ +pyzbar==0.1.8 +opencv-python==4.5.3.56 \ No newline at end of file diff --git a/contributors.md b/contributors.md index 3a7c089c..c6e972ed 100644 --- a/contributors.md +++ b/contributors.md @@ -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)