Harsh Chitrala
Harsh Chitrala

Reputation: 67

barcode scan is not working for full AVCaptureVideoPreviewLayer

I have added AVCaptureVideoPreviewLayer to my whole view still when I'm trying to scan the barcode , it scans if i place the barcode at the centre of view. Please help me with the solution

Upvotes: 1

Views: 801

Answers (1)

wj2061
wj2061

Reputation: 6885

When AVCapture scan for QRCode,there are there squares in the corners to help locate the QRCode.So you can scan for QRCode anywhere in the AVCaptureVideoPreviewLayer,and scan for more than one QRCode a time.
But there is no square to help locate barcode,instead, AVCapture scan for multiple lines which cross over the center of RectOfInterest.When a line cross over all of the lines of a Barcode,the AVCapture recognize this BarCode.So , if your barcode is in the corner of AVCaptureVideoPreviewLayer, and you don't change the default set of RectOfInterest,then you can't scan this barcode.

To fix this problem :

  1. you can draw a Rect in the center of AVCaptureVideoPreviewLayer to hint user put barcode in the center.

  2. set RectOfInterest at corner of AVCaptureVideoPreviewLayer,so you can only scan the barcode in the corder.

Upvotes: 4

Related Questions