【问题标题】:Tap To Focus Not Working Properly with Cropped GPUImage Camera使用裁剪的 GPUImage 相机点击对焦无法正常工作
【发布时间】:2014-12-12 19:41:32
【问题描述】:

我有一个GPUImageStillCamera,我正在用它来构建一个相机,然后我将它裁剪成一个正方形

    stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPreset1280x720 cameraPosition:AVCaptureDevicePositionBack];
stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait;

//Creating a square crop filter
cropFilter = [[GPUImageCropFilter alloc] initWithCropRegion:CGRectMake(0.f, (720.0f/1280.0f)/2.0f, 1.f, (720.0f/1280.0f))];

我想让用户点击来调整焦点和曝光控制,而当我点击时,相机确实会尝试调整焦点和曝光,但只有大约 30% 的时间是正确的。我想也许我需要发送未裁剪相机的焦点(因为相对点会有所不同),但我得到了相同的体验。用户单击焦点和曝光调整,但它没有在触摸点上聚焦或设置适当的曝光。有什么想法吗?

-(void)imageTouch:(UITapGestureRecognizer *)recognizer{

//Focus point relative to the square
//CGPoint translation = [recognizer locationInView:cameraImagePreview];
//CGPoint focusPoint = CGPointMake(translation.x/cameraHolder.frame.size.width, translation.y/cameraHolder.frame.size.height);

//Focus point relative to the uncropped camera
CGPoint translation = [recognizer locationInView:fullCameraFocusPoint];
CGPoint focusPoint = CGPointMake(translation.x/fullCameraFocusPoint.frame.size.width, translation.y/fullCameraFocusPoint.frame.size.height);


//Set the focus point of the camera
if (stillCamera.inputCamera.isFocusPointOfInterestSupported && [stillCamera.inputCamera isFocusModeSupported:AVCaptureFocusModeAutoFocus]) {

    [stillCamera.inputCamera lockForConfiguration:nil];
    stillCamera.inputCamera.focusPointOfInterest = focusPoint;
    stillCamera.inputCamera.focusMode = AVCaptureFocusModeAutoFocus;

    if (stillCamera.inputCamera.exposurePointOfInterestSupported && [stillCamera.inputCamera isExposureModeSupported:AVCaptureExposureModeAutoExpose]) {
        stillCamera.inputCamera.exposurePointOfInterest = focusPoint;
        stillCamera.inputCamera.exposureMode = AVCaptureExposureModeAutoExpose;
    }

    [stillCamera.inputCamera unlockForConfiguration];
}

【问题讨论】:

    标签: avfoundation gpuimage avcapturesession avcapturedevice


    【解决方案1】:

    (不是答案,但是评论太长了,抱歉)

    我也有同样的问题。我尝试计算相对于裁剪预览图层的焦点,但焦点已关闭。然后我尝试使用captureDevicePointOfInterestForPoint。在你的情况下,我猜这将是(迅速):

    let focusPoint = cameraHolder.layer.captureDevicePointOfInterestForPoint(translation)
    

    我注意到它只在点击同一位置两次后才关注正确的位置。此外,Apple 文档建议曝光点和焦点是互斥的:

    Note: Focus point of interest and exposure point of interest are mutually exclusive, as are focus mode and exposure mode.
    

    在本文档中有更多关于重点应该是什么的解释:https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/04_MediaCapture.html

    如果你解决了请告诉我:)

    【讨论】:

    • 我最终转而直接从 Apple API 调用相机,所有点击对焦功能都运行良好。
    猜你喜欢
    • 2016-01-11
    • 2012-03-24
    • 2012-07-04
    • 2015-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-22
    • 1970-01-01
    相关资源
    最近更新 更多