How do I read an image from file for use with the `PyObjC Vision` framework?

孤者浪人 提交于 2020-12-14 23:40:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!