What are the settings of AVCoundure AVCaptureDevice for camera application on iphone?

I was wondering what AVCaptureDevice options are for the camera app on iPhone. In particular, AVCaptureExposureMode, AVCaptureFocusMode and AVCaptureWhiteBalanceMode. I am trying to create a custom camera, and for some reason I cannot correctly change the lighting of the photo when focusing. I set ExposurePointOfInterest and FocusPointOfInterest for my camera, but for some reason it seems that the camera focuses correctly, but the lighting does not focus where I click. When I click on a dark area, it does not lighten, as in the camera application. Are there any settings that I forget to set? Here is my code for focusing the camera.

CGPoint touchPoint = [gesture locationInView:collectView];
float focus_x = touchPoint.x / collectView.frame.size.width;
float focus_y = touchPoint.y / collectView.frame.size.height;
NSError *tError = nil;
NSLog(@"previous: %.2f, %.2f", backCamera.focusPointOfInterest.x, backCamera.focusPointOfInterest.y);
if (isFrontCamera) {
    focus_x = collectView.frame.size.width - focus_x; //the view is mirrored for the front camera
    if ([frontCamera lockForConfiguration:&tError]) {
        if ([frontCamera isExposurePointOfInterestSupported]) {
            [frontCamera setExposurePointOfInterest:CGPointMake(focus_x, focus_y)];
            if ([frontCamera isExposureModeSupported:AVCaptureExposureModeAutoExpose]) {
                [frontCamera setExposureMode:AVCaptureExposureModeAutoExpose];
            }
        }
        if ([frontCamera isFocusPointOfInterestSupported]) {
            [frontCamera setFocusPointOfInterest:CGPointMake(focus_x, focus_y)];
            if ([frontCamera isExposureModeSupported:AVCaptureExposureModeAutoExpose]) {
                [frontCamera setExposureMode:AVCaptureExposureModeAutoExpose];
            }
        }
        if ([frontCamera isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeAutoWhiteBalance]) {
            [frontCamera setWhiteBalanceMode:AVCaptureWhiteBalanceModeAutoWhiteBalance];
        }
        [frontCamera unlockForConfiguration];
    }
    else {
        NSLog(@"Couldn't change focus point:%@",tError);
    }
}
else {
    if ([backCamera lockForConfiguration:&tError]) {
        if ([backCamera isExposurePointOfInterestSupported]) {
            [backCamera setExposurePointOfInterest:CGPointMake(focus_x, focus_y)];
            if ([backCamera isExposureModeSupported:AVCaptureExposureModeAutoExpose]) {
                [backCamera setExposureMode:AVCaptureExposureModeAutoExpose];
            }
        }
        if ([backCamera isFocusPointOfInterestSupported]) {
            [backCamera setFocusPointOfInterest:CGPointMake(focus_x, focus_y)];
            if ([backCamera isFocusModeSupported:AVCaptureFocusModeAutoFocus]) {
                [backCamera setFocusMode:AVCaptureFocusModeAutoFocus];
            }
        }
        if ([backCamera isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeAutoWhiteBalance]) {
            [backCamera setWhiteBalanceMode:AVCaptureWhiteBalanceModeAutoWhiteBalance];
        }
        [backCamera unlockForConfiguration];
    }
    else {
        NSLog(@"Couldn't change focus point:%@",tError);
    }
}
+4
1

.

, , Camera.

0

Source: https://habr.com/ru/post/1545525/


All Articles