-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QR codes recognition failures #119
Comments
@Sami32 you can use dilation and color invert to detect the second one. from dbr import *
import imageio
import cv2 as cv
import numpy as np
import dbr
BarcodeReader.init_license("DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==")
reader = BarcodeReader()
def detect(windowName, image, pixel_format):
try:
buffer = image.tobytes()
height = image.shape[0]
width = image.shape[1]
stride = image.strides[0]
start = time.time()
results = reader.decode_buffer_manually(buffer, width, height, stride, pixel_format, "")
end = time.time()
print("Time taken: {:.3f}".format(end - start) + " seconds")
cv.putText(image, "Time taken: {:.3f}".format(end - start) + " seconds", (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
if results != None:
for result in results:
print("Barcode Format : ")
print(result.barcode_format_string)
print("Barcode Text : ")
print(result.barcode_text)
points = result.localization_result.localization_points
data = np.array([[points[0][0], points[0][1]], [points[1][0], points[1][1]], [points[2][0], points[2][1]], [points[3][0], points[3][1]]])
cv.drawContours(image=image, contours=[data], contourIdx=-1, color=(0, 255, 0), thickness=2, lineType=cv.LINE_AA)
x = min(points[0][0], points[1][0], points[2][0], points[3][0])
y = min(points[0][1], points[1][1], points[2][1], points[3][1])
cv.putText(image, result.barcode_text, (x, y), cv.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
cv.imshow(windowName, image)
except BarcodeReaderError as bre:
print(bre)
image = cv.imread("test.jpg")
cv.imshow("original", image)
grayscale = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
binary = cv.threshold(grayscale, 0, 255, cv.THRESH_BINARY_INV + cv.THRESH_OTSU)[1]
kernel = np.ones((7,7), np.uint8)
dilate = cv.dilate(binary, kernel, iterations=1)
cv.bitwise_not(dilate, dilate)
detect('Binary', dilate, dbr.EnumImagePixelFormat.IPF_GRAYSCALED)
cv.waitKey(0) Time taken: 0.016 seconds
Barcode Format :
QR_CODE
Barcode Text :
http://qrc.im/iJ |
We have some simple means to deal with the first two. But the third is the hardest to code. You can contact our technical support about your order details. And bring the collection of images you need to support. If the offer is right, we'll try to work it out. |
Oh i see. I was surprise of this result because the first example is easily recognized by the others SDK libraries that i've tested, and the second remember me a bad printing with a dirty/damaged head ink printer. Yes, i admit than the third example will probably only be found in the artist's website or in a art museum ;) Thank you for your help and teaching me that all the available settings are not in your online demo +1 |
My pleasure. Personally, I would like to know, if you want to hold a QR code art exhibition, or work on QR code art. Seems fantastic~😎 |
Hehehe...no exhibition. Here come my code scanner libraries testing adventure ;-) |
In order to distinguish different QRs, there will be some distance between QRs. It is called |
@Keillion Thank you very much for this tip and your knowledge sharing +1 |
There may be an algorithmic logic error in this. I'm looking into it. |
These 3 artistic QR codes failed to be recognized, at least i wasn't able to do it.
That's said your SDK isn't targeting these use cases just yet but QR codes are spreading in our everyday life more and more.
Feel free to close this issue if it doesn't meet your roadmap.
The text was updated successfully, but these errors were encountered: