问题
I am trying to detect and decode barcodes from a library of images. In most cases pyzbar simply works (see code here).
However, in some cases, my iPhone can decode the QR code but zbar
fails. As I am on a mac, I can make use of the same Vision
framework that the iPhone uses and there are even python wrappers to the macOS ObjC frameworks.
I tried using Quartz.CGImageSourceCreateWithURL
but that returns a None
no matter what I pass it.
def read_image(path):
imageSrc = Quartz.CGImageSourceCreateWithURL(path, None)
image = Quartz.CGImageSourceCreateImageAtIndex(imageSrc, 0, None)
return imageSrc, image
print(read_image(path))
Out: (None, None)
I have tried relative and absolute paths, I've tried internet URLs. Nothing.
Can someone help me get started with this?
来源:https://stackoverflow.com/questions/65089059/how-do-i-read-an-image-from-file-for-use-with-the-pyobjc-vision-framework