I want this code to detect qr code in the image from top to bottom, it looks it's random…
- User
I want this code to detect qr code in the image from top to bottom, it looks it's random currently : def screenshot_detect_qr_code_texts(self): screenshot = pyautogui.screenshot() # Convert PIL image (screenshot) to a NumPy array img = np.array(screenshot)
# Convert to grayscale since color information is not needed img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # Using OpenCV’s built-in QR code detector detector = cv2.QRCodeDetector() # Detect and decode the QR code try: detector = cv2.wechat_qrcode.WeChatQRCode("detect.prototxt", "detect.caffemodel", "sr.prototxt", "sr.caffemodel") except: print("---------------------------------------------------------------") print("Failed to initialize WeChatQRCode.") print("Please, download 'detector.*' and 'sr.*' from") print("https://github.com/WeChatCV/opencv_3rdparty/tree/wechat_qrcode") print("and put them into the current directory.") print("---------------------------------------------------------------") exit(0) res, points = detector.detectAndDecode(img) # Check if any QR codes were detected if res: return res else: # If no QR codes were detected return None - Assistant
The QR code detection procedure using the WeChatQRCode detector doesn't inherently guarantee a top-to-bottom processing order in images. It will detect all QR codes in the image without considering their position.