remirobert / CameraEngine

:monkey::camera: Camera engine for iOS, written in Swift, above AVFoundation. :monkey:
https://github.com/remirobert/CameraEngine
MIT License
583 stars 106 forks source link

Cant get barcode detection to wok #84

Open multinerd opened 7 years ago

multinerd commented 7 years ago

Using the example provided, ive added the following lines to viewDidLoad()

        self.cameraEngine.metadataDetection = .barcode

        self.cameraEngine.blockCompletionCodeDetection = { codeObject in
            print(codeObject.stringValue)
            let valueCode = codeObject.stringValue
            let frameCode = (codeObject as AVMetadataObject).bounds
            print(frameCode)
//            self.displayLayerDetection(frame: frameCode)
        }

and am unable to detect ean13 codes. is there something else i need to do?

multinerd commented 7 years ago

after a few hours of tinkering, i've figured out the problem...

inside CameraEngineMetadataOutput.swift the method

func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [AnyObject]!, from connection: AVCaptureConnection!)

was replaced with

func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection)