简体   繁体   中英

Is it possible to auto-adjust the image brightness in iPhone?

I use iPhone camera to capture images in my iOS APP. AVCaptureVideoDataOutputSampleBufferDelegate is used to get images from iPhone camera. A part of the program is shown below.

        AVCaptureDevice *videoDevice = [AVCamViewController deviceWithMediaType:AVMediaTypeVideo preferringPosition:AVCaptureDevicePositionBack];


        AVCaptureDeviceInput *videoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];

        if (error)
        {
            NSLog(@"%@", error);
        }

        if ([session canAddInput:videoDeviceInput])
        {
            [session addInput:videoDeviceInput];
            [self setVideoDeviceInput:videoDeviceInput];

            dispatch_async(dispatch_get_main_queue(), ^{
                // Why are we dispatching this to the main queue?
                // Because AVCaptureVideoPreviewLayer is the backing layer for AVCamPreviewView and UIView can only be manipulated on main thread.
                // Note: As an exception to the above rule, it is not necessary to serialize video orientation changes on the AVCaptureVideoPreviewLayer’s connection with other session manipulation.
                //[self previewView] layer
                [[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] setVideoOrientation:(AVCaptureVideoOrientation)[self interfaceOrientation]];
            });
        }

Sometimes, the environment is dark a bit. In the iPhone camera app, it can brighten the image by tapping the iPhone screen on the darker part. But I don't like such suer's involvement. I check RGB intensity, once I realise the brightness is not enough, I like to brighten the image by adjusting the camera parameters (such as camera exposure, etc) in my program. Is it possible in iPhone programming? Thanks

I haven't work on AVFoundation much but you can find more details here . I hope this will be useful for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM