3

I am working on iOS-Cordova cross platform. I am accessing Camera API com.mbppower.camerapreview from github. I want to Zoom in and Zoom Out my camera and Want to capture image Through Native iOS Class , My Code is working for iPhone But not working for iPad.

AnyOne Please help ? My code is :-

const CGFloat pinchVelocityDeviderFactor = 1.0f;
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

if (([pinchRecognizer state] == UIGestureRecognizerStateBegan) ||
    ([pinchRecognizer state] == UIGestureRecognizerStateChanged)) {

    //Error Message.
    NSError *error = nil;
    static CGFloat vf;//MAX(1.0, MIN(desiredZoomFactor, self.videoDevice.videoZoomFactor));

    if((1.0 <= pinchRecognizer.scale) && (2.5 >= pinchRecognizer.scale))
    {
        //Setting vf.
        vf = 1.0 + pinchRecognizer.scale * pinchVelocityDeviderFactor;

        //Get Return Value of lock configuraton.
        BOOL bRet = [device lockForConfiguration:&error];

        //Lock Configuration.
        if(bRet)
        {
            //if(1.0 <= vf && vf <= 2.5)
            //Set Zoom factor.
            device.videoZoomFactor = vf;

            //Unlock Device Configuration.
             [device unlockForConfiguration];
        }
    }
}

My app become Crash for iPad.

'NSRangeException', reason: '*** -[AVCaptureVideoDevice setVideoZoomFactor:] - the passed videoZoomFactor 1.141650 out-of-range [1, activeFormat.videoMaxZoomFactor]'

Please help guys
Thanks

kishor
  • 221
  • 2
  • 14
  • Any one can help please ? – kishor Feb 11 '16 at 12:25
  • you should check that the value you pass to `device.videoZoomFactor` isn't greater than `videoMaxZoomFactor` – jcesarmobile Feb 23 '16 at 11:25
  • Yes i Checked , But device iPad mini ,the Value of VideoMaxZoomFactor is giving always 1. But Device support Zoom functionality By Default. Any other alternative solution for that ..? @jcesarmobile Please help? – kishor Feb 24 '16 at 11:33
  • If it says that VideoMaxZoomFactor is 1 I don't think you can do anything about it. – jcesarmobile Feb 24 '16 at 11:46
  • But same Code is Working For iPhone But for iPad its Crashing. – kishor Feb 24 '16 at 12:35
  • Some things work on some devices and other things don't work. You can't set videoZoomFactor with a value higher than videoMaxZoomFactor, if the iPad returns 1 for videoMaxZoomFactor then you can't zoom. That's all. – jcesarmobile Feb 24 '16 at 13:21
  • Ok ,Thanks @jcesarmobile . You are right. – kishor Feb 25 '16 at 10:51
  • For iPad Mini Is giving error – kishor Jul 20 '16 at 07:29
  • Hi Kishore Jee, Me to have the same problem... With iPAd Mini Did you find any solution for this? If yes could you please help me on this. – iOS dev Nov 06 '17 at 11:49

0 Answers0