ipadOS 17.4: AVCaptureMetadataOutput delegate not called (qrscanner)

1.6k views Asked by At

I'm encountering an issue with the QR code scanner on my iPad 7th Gen running ipadOS 17.4. While the scanner seems to be functioning normally on the latest iPad 10th Gen (also on ipadOS 17.4), it's not working at all for ipad 7th gen (ipadOS 17.4) on my device.

It's possible that this problem affects other iPad models but for now I've tested just these two models.

Has anyone else experienced similar issues with the QR code scanner? Any suggestions for troubleshooting or a potential fix would be greatly appreciated.

List of tried device:

  • ipad 6Gen: KO
  • ipad 7Gen: KO
  • iPad 10Gen: OK
  • iPhone 15: OK
  • iPad 8th gen OK
  • iPad Air 4th gen OK
  • iPad Pro 12" 4th Gen OK
  • iPhone 15 Pro OK

Minor update

I tried to download AVCam project from official documentation of Apple and I confirm that is not working even in their swift project. But the face recognition is working

MetadataOutput

captureObject = [[AVCaptureMetadataOutput alloc]init];
objectQueue =       dispatch_queue_create("VideoDataOutputQueue", NULL);//dispatch_queue_create("newQueue", NULL);
[captureObject setMetadataObjectsDelegate:self queue:objectQueue];

I tried to use main_queue where creating the dispatch_queue but not delegating:

objectQueue =       dispatch_queue_create("VideoDataOutputQueue", NULL);//dispatch_queue_create("newQueue", dispatch_get_main_queue());

The problem is that is not delegating nor triggering the method:

- (void)captureOutput:(AVCaptureOutput *)output didOutputMetadataObjects:(NSArray<__kindof AVMetadataObject *> *)metadataObjects fromConnection:(AVCaptureConnection *)connection {
    
    if (metadataObjects != nil && metadataObjects.count > 0) {
        
        NSLog(@"%@", [metadataObjects objectAtIndex:0]);
         
        }
    }
}

WORKAROUND

There is no current solution up to now but i used a workaround using AVCaptureVideoDataOutputSampleBufferDelegate.

Then use the following output:

self.videoDataOutput = [[AVCaptureVideoDataOutput alloc] init];
[self.videoDataOutput setSampleBufferDelegate:self queue:dispatchQueue];
if ([_captureSession canAddOutput:self.videoDataOutput]) {
    [_captureSession addOutput:self.videoDataOutput];
}

Then using delegate method:

- (void)captureOutput:(AVCaptureOutput *)output didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
    CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
    if (imageBuffer == NULL) {
        return;
    }
    CIImage *ciImage = [CIImage imageWithCVImageBuffer:imageBuffer];
    [self detectQRCode:ciImage];
}

-(void)detectQRCode:(CIImage *)image {
    NSDictionary* options;
    CIContext* context = [CIContext context];
    options = @{ CIDetectorAccuracy : CIDetectorAccuracyHigh };
    CIDetector* qrDetector = [CIDetector detectorOfType:CIDetectorTypeQRCode
                                                context:context
                                                options:options];
//    if ([[image properties] valueForKey:(NSString*) kCGImagePropertyOrientation] == nil) {
//        options = @{ CIDetectorImageOrientation : @1};
//    } else {
//        options = @{ CIDetectorImageOrientation : [[image properties] valueForKey:(NSString*) kCGImagePropertyOrientation]};
//    }
    
    NSArray * features = [qrDetector featuresInImage:image options:options];
    
    if (features == nil || [features count] == 0) {
        return;
    }
    CIQRCodeFeature *metadataObj = [features firstObject];
    NSString *qrString = [NSString  stringWithString:metadataObj.messageString];
    NSLog(@"feature: %@",qrString);
}


UPDATE

iOS 17.4.1 fixes the AVCaptureMetadataOutputObjectsDelegate.

0

There are 0 answers