How can I extract an AVMetadataObject from a UIImage?

随声附和 提交于 2019-11-30 12:13:22

问题


I'd like to use iOS 7's new barcode scanning functionality with a UIImage instead of live capture from one of the device's camera. I already have the detection working fine with an AVCaptureDeviceInput.

The best way I think to do this would be to create a concrete subclass of AVCaptureInput that provides media data to an AVCaptureSession from a UIImage. However, I can't find any documentation or examples on how to subclass AVCaptureInput, so I'm at a loss.

An alternative would be to override the media stream from an existing AVCaptureDeviceInput, but since those API's are private and I'd like to publish my app on the App Store, this isn't ideal.

Ultimately, I'll likely end up doing this using a 3rd party barcode library like ZXing or ZBar, but it seems like a waste to not be able to use Apple's built-in functionality here.


回答1:


life is easy. You can use CIDetector instead. Convert an image into CIImage to be decoded by CIDetector.



来源:https://stackoverflow.com/questions/19480466/how-can-i-extract-an-avmetadataobject-from-a-uiimage

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