gpt4 book ai didi

iphone - 如何在 AVCaptureSession 中放置增加相机亮度的 slider

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:22:46 26 4
gpt4 key购买 nike

到目前为止,我已经介绍了相机将一个 slider 放在现在可以缩放相机的 slider 中,但现在我想放置另一个 slider 来增加和降低相机的亮度我已经搜索过这个并且我需要使用 AVCaptureVideoDataOutput 并拍摄单帧我可以使用委托(delegate)方法并处理它,然后用那个框架做你想做的事我在下面发布我的代码并解释其中的其他事情

    AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
// AVCaptureVideoDataOutput
if (videoDevice) {
NSError *error;
AVCaptureDeviceInput *videoIn = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
if (!error) {
if ([[self captureSession] canAddInput:videoIn])
[[self captureSession] addInput:videoIn];
else
NSLog(@"Couldn't add video input");
}
else
NSLog(@"Couldn't create video input");
}
else
NSLog(@"Couldn't create video capture device");

AVCaptureVideoDataOutput *videoOut = [[AVCaptureVideoDataOutput alloc] init];
/*
RosyWriter prefers to discard late video frames early in the capture pipeline, since its
processing can take longer than real-time on some platforms (such as iPhone 3GS).
Clients whose image processing is faster than real-time should consider setting AVCaptureVideoDataOutput's
alwaysDiscardsLateVideoFrames property to NO.
*/
[videoOut setAlwaysDiscardsLateVideoFrames:YES];
[videoOut setVideoSettings:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey]];
dispatch_queue_t videoCaptureQueue = dispatch_queue_create("Video Capture Queue", DISPATCH_QUEUE_SERIAL);
[videoOut setSampleBufferDelegate:self queue:videoCaptureQueue];
dispatch_release(videoCaptureQueue);
if ([captureSession canAddOutput:videoOut])
[captureSession addOutput:videoOut];
}

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
{

I HAVE READ THAT NEED TO PROCESS FRAME AND THEN SEND IT BACK TO SESSION BUT HOW I DONT KNOW
THIS IS THE DELEGATE METHOD WHERE I GET FRAME NOW I DONT UNDERSTAND HOW TO PROCESS THIS
FRAME WHAT SHOULD I DO SO I CAN INCREASE AND DECREASE BRIGHTNESS OF CAMERA PLEASE HELP ME IF YOU KNOW
}

最佳答案

为此只需使用以下代码设置主屏幕的亮度..

[[UIScreen mainScreen] setBrightness:sliderValue];

在 slider 值中设置值从 0 到 1,如下所示。

yourSlider.minimumValue = 0.f;
yourSlider.maximumValue = 1.0f;

及其 UIControlEventValueChanged 调用任何类似下面的方法并更改值,请参见下面的示例..

- (void)Brightness_Changed:(UISlider *)sender
{
[[UIScreen mainScreen] setBrightness:sender.value];
}

关于iphone - 如何在 AVCaptureSession 中放置增加相机亮度的 slider ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17945348/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com