0

I am new to iOS development. I am trying to build an application with live video input with torch and maximum zoom turned on. This app will be used to scan small 2D data matrix barcodes from physical parts. The code I am using is the following:

if ([input.device lockForConfiguration:nil]) {
        CGFloat zoomFactor = input.device.activeFormat.videoMaxZoomFactor;
        [input.device rampToVideoZoomFactor:zoomFactor withRate:4.0];
        [input.device unlockForConfiguration];

    }

This isn't working at all for some reason. When I try to debug the lock works, so it runs through the zooming code but nothing actually happens in the application.

Any advices?

  • What device are you testing on? And what's the value coming back for videoMaxZoomFactor? I believe only iPhone 5 and newer support anything other than "1" here. – Dan Mar 28 '14 at 16:48

1 Answers1

0

I've found that something like the following works for me:

dispatch_async(self.sessionQueue, ^{
    NSError *error = nil;
    if ([input.device lockForConfiguration:&error])
    {
        [input.device rampToVideoZoomFactor:2 withRate:1];

        [input.device unlockForConfiguration];
    }
    else
    {
        NSLog(@"%@", error);
    }
});

But from your code above, I cannot tell what "device" actually is (is it the active device obtained from your AVCaptureSession?). I think you'll need to provide some more context.

joelg
  • 1,094
  • 9
  • 19