11

在 Apple 的iOS 6.0 功能页面上,它曾经说

利用内置摄像头的高级功能。新的 API 让您可以控制焦点、曝光和感兴趣区域。您还可以使用人脸检测 API 访问和显示人脸,并利用支持硬件的视频稳定功能。

此文本已被删除,我在 API 中找不到用于控制曝光的新方法。在“曝光设置”下的课堂AVCaptureDevice中,iOS 6.0 没有新的属性/方法。你知道我在哪里可以找到 API 中的新功能吗?

4

5 回答 5

23

确实有一个-exposureMode属性 on AVCaptureDevice,但这仅用于设置模式(关闭/自动/连续),而不是实际的 f-stop、SS 或 ISO。提供“曝光”控制的相机应用似乎都是通过后期处理完成的。

但是,似乎框架中有未记录的 API 可以执行此操作。查看(通过class-dump )的完整标题AVCaptureDevice.h并注意以下方法:

- (void)setManualExposureSupportEnabled:(BOOL)arg1;
- (BOOL)isManualExposureSupportEnabled;

- (void)setExposureGain:(float)arg1;
- (float)exposureGain;

- (void)setExposureDuration:(struct { long long x1; int x2; unsigned int x3; long long x4; })arg1;
- (struct { long long x1; int x2; unsigned int x3; long long x4; })exposureDuration;

- (void)setExposureMode:(int)arg1;
- (int)exposureMode;

- (BOOL)isExposureModeSupported:(int)arg1;

我的猜测是gain等效的 f-stop(固定光圈),并且duration是快门速度。我想知道这些是否用于 iPhone 5 的低光增强模式

您也可以使用otool四处寻找并尝试将符号拼凑在一起。exposureMode启用手动控制可能有一个新常量,并且exposureDuration似乎也有标志。调用这些时,请确保使用 new-isExposureModeSupported:并调用-respondsToSelector:以检查兼容性。

与往常一样,Apple 不赞成使用私有 API,这也是 App Store 拒绝的原因。可能有解决这个问题的方法,例如使用-performSelector:obc_msgsend使用 rot13 字符串或其他东西隐藏调用,因为我很确定它们只对应用程序二进制文件进行静态分析。

于 2012-10-17T17:30:09.933 回答
4

我已经设法“欺骗”相机运行更短的曝光时间,但我怀疑它只会对那些进行类似(宏观)图像采集的人有用。我首先将 AVCaptureDevice 设置为使用 AVCaptureExposureModeContinuousAutoExposure 并将闪光灯设置为 TorchMode。然后我 UnlockForConfiguration 并设置一个键值观察器来观察调整曝光的完成。然后我重新锁定设备,翻转到 AVCaptureExposureModeLocked,然后关闭 Torch。这具有蛮力设置比相机在未照明场景中选择的快门速度更短的效果。通过使用手电筒级别,我可以设置我想要的任何相对快门速度值(当然最好让手电筒保持打开状态,但在我的应用程序中它会在主体上产生眩光)。同样,这仅在您的物距非常近(小于 6 英寸)时才真正起作用,但它使我能够消除特写图像中的手抖动模糊。不利的一面是图像更暗,因为我没有办法欺骗相机增益,但在我的特定应用程序中不是问题。

于 2013-12-18T14:36:30.963 回答
3

It looks like they've updated that linked text—there's no mention of new APIs for exposure:

Use powerful new features of the built-in camera. New APIs support real-time video stabilization, an improved LED flash, and face detection and display. You can get reports of dropped frames during capture and leverage new utilities to map UI touches to focus and exposure commands. And apps that support iPhone 5 can take advantage of low light boost mode.

There is an opt-in low-light boost mode for iPhone 5, detailed here by Jim Rhoades (and in this developer forum post, log-in required).

于 2012-10-08T05:06:30.947 回答
3

作为 Michael Grinich 优秀资料的后续,我发现私有 API 中的一些调用存在顺序依赖关系。要使用“手动”曝光控制,您必须在设置模式之前启用它们,如下所示:

#define AVCaptureExposureModeManual     3
NSError*    error = nil;
if ([captureDevice lockForConfiguration:&error]) {
    captureDevice.manualExposureSupportEnabled = YES;
    if ([captureDevice isExposureModeSupported:AVCaptureExposureModeManual]) {
        captureDevice.exposureMode = AVCaptureExposureModeManual;
        captureDevice.exposureGain = ...;
        captureDevice.exposureDuration = {...};
    }
    [captureDevice unlockForConfiguration];
}

所有这些都在iOS-ManualCamera中得到了展示。

于 2014-01-29T21:33:31.447 回答
1

从 iOS 8.0 开始,这终于成为可能。

请参阅Apple 文档中的setExposureModeCustomWithDuration等。

这是一篇讨论如何使用 API 的文章。

于 2014-12-15T16:24:35.610 回答