Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit a5553f6

Browse files
committed
Add support for inverted-color QR codes
1 parent 1181fb5 commit a5553f6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

seedqreader.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
FORMAT_SPECTER = 'Specter'
5757
FORMAT_BBQR = 'BBQR'
5858

59+
PYZBAR_SYMBOLS = (pyzbar.ZBarSymbol.QRCODE, pyzbar.ZBarSymbol.SQCODE)
60+
5961
# helper obj to handle bbqr encoding and file_type
6062
bbqr_obj = None
6163

@@ -596,8 +598,14 @@ def run(self):
596598
# Set the pixmap to the label
597599
self.video_stream.emit(scaled_pixmap)
598600

599-
data = pyzbar.decode(frame)
601+
data = pyzbar.decode(frame, PYZBAR_SYMBOLS)
600602
str_data = ""
603+
604+
# Try to invert colors
605+
if not data:
606+
frame = cv2.bitwise_not(frame)
607+
data = pyzbar.decode(frame, PYZBAR_SYMBOLS)
608+
601609
if data:
602610
# print("try to_str(data[0].data)", data)
603611
try:

0 commit comments

Comments
 (0)