opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.46k stars 5.77k forks source link

WeChat QR code cannot detect and decode the QR code cropped from the image #3104

Open donalduk opened 3 years ago

donalduk commented 3 years ago
System information (version)
Detailed description

I have built OpenCV 4.5.4 with WeChat QR code from the source code. Then I am trying to detect QR code with two sample QR codes. The 2dbarcode.jpeg is one QR code I downloaded from internet while the cropped-barcode.jpg is the QR code I cropped from one image. WeChat QR detector can detect and decode the QR code in 2dbarcode.jpeg. But it cannot detect the QR code in cropped-barcode.jpg. However If I use one QR Code app in my mobile to scan the cropped-barcode.jpg and the QR code mobile app can correctly detect and decode the QR Code in the cropped-barcode.jpg.

What should I need to do in order to detect and decode the cropped QR code from one image?

Steps to reproduce

import cv2 detector = cv2.wechat_qrcode_WeChatQRCode("./detect.prototxt", "./detect.caffemodel", "./sr.prototxt", "./sr.caffemodel") img=cv2.imread('./2dbarcode.jpeg') res, points = detector.detectAndDecode(img) print(res, points) img=cv2.imread('./cropped-barcode.jpg') res, points = detector.detectAndDecode(img) print(res, points)

Issue submission checklist

cropped-barcode

2dbarcode

ghost commented 2 years ago

The code with the three bullseyes at the corners is a QR code. The other code (with the black L on the left and bottom) is a data matrix code. It is not readable by QR code readers.