我不是用的系统照相机,我想做系统照相机一样可以调正焦距。
代码如下:-(void) focus:(UIGestureRecognizer *)gesture
{
CGPoint point = [gesture locationInView:self.videoCamera.gpuImageView];
point.x /= self.videoCamera.gpuImageView.frame.size.width;
point.y /= self.videoCamera.gpuImageView.frame.size.height; originPoint = point; if ([self.videoCamera.inputCamera isFocusPointOfInterestSupported] && [self.videoCamera.inputCamera isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus])
{
NSError *error;
[self.videoCamera.inputCamera lockForConfiguration:&error];
NSLog(@"orign:%f,%f",self.videoCamera.inputCamera.focusPointOfInterest.x,self.videoCamera.inputCamera.focusPointOfInterest.y);
if (self.videoCamera.inputCamera.adjustingFocus)
{
NSLog(@"YES");
[self.videoCamera.inputCamera setFocusPointOfInterest:point];
[self.videoCamera.inputCamera setFocusMode:AVCaptureFocusModeContinuousAutoFocus];
NSLog(@"new:%f,%f",self.videoCamera.inputCamera.focusPointOfInterest.x,self.videoCamera.inputCamera.focusPointOfInterest.y);
}
else
{
NSLog(@"NO");
}
[self.videoCamera.inputCamera unlockForConfiguration];
} _focusProgress.hidden = NO;
}.focusPointOfInterest变了,但是为什么没有效果呢?还是说,还有其它什么需要设置的?
各位大侠,帮忙看下,谢啦!
ios相机聚焦
代码如下:-(void) focus:(UIGestureRecognizer *)gesture
{
CGPoint point = [gesture locationInView:self.videoCamera.gpuImageView];
point.x /= self.videoCamera.gpuImageView.frame.size.width;
point.y /= self.videoCamera.gpuImageView.frame.size.height; originPoint = point; if ([self.videoCamera.inputCamera isFocusPointOfInterestSupported] && [self.videoCamera.inputCamera isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus])
{
NSError *error;
[self.videoCamera.inputCamera lockForConfiguration:&error];
NSLog(@"orign:%f,%f",self.videoCamera.inputCamera.focusPointOfInterest.x,self.videoCamera.inputCamera.focusPointOfInterest.y);
if (self.videoCamera.inputCamera.adjustingFocus)
{
NSLog(@"YES");
[self.videoCamera.inputCamera setFocusPointOfInterest:point];
[self.videoCamera.inputCamera setFocusMode:AVCaptureFocusModeContinuousAutoFocus];
NSLog(@"new:%f,%f",self.videoCamera.inputCamera.focusPointOfInterest.x,self.videoCamera.inputCamera.focusPointOfInterest.y);
}
else
{
NSLog(@"NO");
}
[self.videoCamera.inputCamera unlockForConfiguration];
} _focusProgress.hidden = NO;
}.focusPointOfInterest变了,但是为什么没有效果呢?还是说,还有其它什么需要设置的?
各位大侠,帮忙看下,谢啦!
ios相机聚焦
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货