Reputation: 5187
I'm trying to implement QRcode reader with AV Foundation. My plan is capturing images continuously, sending captured images to QRcode detector until a valid code is recognized. The detector needs CGImageRef
or UIImage
as input. My questiones are:
AVCaptureVideoDataOutput
or AVCaptureStillImageOutput
? Upvotes: 0
Views: 981
Reputation: 311
Create an instance of AVCaptureVideoDataOutput. Set the sampleBufferDelegate of AVCaptureDataOutput to whatever class (say x)you want to receive the sample buffer. Confirm class x to AVCaptureVideoDataOutputSampleBufferDelegate protocol. Implement– captureOutput:didOutputSampleBuffer:fromConnection: method of that protocol in class x. Add AVCaptureVideoDataOutput instance to AVCaptureSession. Then start the session. You will receive the callback with sample buffer.
Upvotes: 0
Reputation: 311
AVCaptureVideoDataOutput
gives you the Uncompressed YUV frame which you can easily send to QRCode reader if it supports uncompressed inputs. Hence you will be avoiding decoding operation.
If AVCaptureVideoDataOutput
is used you can set frame rate in AVFormatDescription
and set that to AVCaptureDevice
. Once you start the AVCaptureSession
you receive frames continuously at the specified frame rate until you stop it. Typically you can set 5 fps and make sure that this operation is asynchronous and you preferably process QRCode in a different thread so that in between two frame capture events you process the QRCode decode operation.
Upvotes: 1