imaginary-cloud / CameraManager

Simple Swift class to provide all the configurations you need to create custom camera view in your app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

QR Detection Only Works Once Per Session

Yrban opened this issue · comments

commented

When I trigger the QR detection via the following code, it will only read one QR code. My code:

    fileprivate func startQRCodeDetection() {
        cameraManager.startQRCodeDetection { (result) in
            switch result {
            case .success(let value):
                qrString = value
            case .failure(let error):
                NSLog("\ncameraManager.startQRCodeDetection failed with error %@", error.localizedDescription)
            }
        }
        qrScannerIsActive = true
    }
    
    fileprivate func stopQRCodeDetection() {
        cameraManager.stopQRCodeDetection()
        qrScannerIsActive = false
        qrString = nil
    }

I think I traced one issue to stopQRCodeDetection() in CameraManager. Line 821 fails and I otherwise can't see where qrOutput is ever set to anything from nil, therefore, line 822, captureSession?.removeOutput(output) is not called. I am not sure that that is the root of my problem that I am seeing, but it may need addressing. Thanks.