gpt4 book ai didi

ios - 像原生相机应用一样使用 AVCam 对焦

转载 作者:行者123 更新时间:2023-11-29 03:19:47 27 4
gpt4 key购买 nike

我想创建焦点功能,就像使用 AVCam 的 native 相机应用程序一样,但无法创建相同的功能。我正在使用上面的代码:

if ([[[captureManager videoInput] device] isFocusPointOfInterestSupported]) {
CGPoint tapPoint = [tgr locationInView:[self videoPreviewView]];
CGPoint convertedFocusPoint = [self convertToPointOfInterestFromViewCoordinates:tapPoint];
[self addLayoutsOfAutoFocus:tapPoint];
[USERDEFAULTS setValue:[NSString stringWithFormat:@"%f",convertedFocusPoint.x] forKey:x_value];
[USERDEFAULTS setValue:[NSString stringWithFormat:@"%f",convertedFocusPoint.y] forKey:y_value];
[USERDEFAULTS synchronize];
[captureManager continuousFocusAtPoint:convertedFocusPoint];
[captureManager continuousExpousureAtPoint:convertedFocusPoint];

}

我正在尝试保存焦点,但下次重新加载相机时焦点会丢失。

请帮忙。

最佳答案

我已经找到了解决方案。我在这里张贴以供将来引用。我使用的技巧是使用用户点击的新点再次设置 session 。这是代码;

- (void)tapToContinouslyAutoFocus:(UIGestureRecognizer *)tgr
{
if ([[[captureManager videoInput] device] isFocusPointOfInterestSupported]) {
CGPoint tapPoint = [tgr locationInView:[self videoPreviewView]];
CGPoint convertedFocus = [self convertToPointOfInterestFromViewCoordinates:tapPoint];
CGPoint convertedFocusPoint=CGPointMake(convertedFocus.y, convertedFocus.x);
[self addLayoutsOfAutoFocus:tapPoint];
[USERDEFAULTS setValue:[NSString stringWithFormat:@"%f",convertedFocusPoint.x] forKey:x_value];
[USERDEFAULTS setValue:[NSString stringWithFormat:@"%f",convertedFocusPoint.y] forKey:y_value];
[USERDEFAULTS synchronize];

[[self captureManager] setSession:nil];
[[self captureManager] setupSession];
[captureManager autoFocusAtPoint:convertedFocusPoint];
[captureManager autoExposureAtPoint:convertedFocusPoint];

}


}

当用户双击屏幕聚焦时调用上述方法。

关于ios - 像原生相机应用一样使用 AVCam 对焦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21235412/

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