0

现在我正在开发一个应用程序,通过使用带有 AVFoundation 和 Core - 图像框架的前置摄像头来检测用户面部和设备之间的距离。

对于人脸检测,我从苹果网站 https://developer.apple.com/LIBRARY/IOS/samplecode/SquareCam/Introduction/Intro.html获得了一个示例代码(squarecam)

在这个例子中,他们使用 AvFoundation 来控制相机和核心 - 图像以使用相机 UI 检测人脸。但我需要这些没有相机 UI 的过程。是否可以使用 AVFoundation 框架隐藏相机 UI。

4

2 回答 2

0

如果我理解正确,您想隐藏摄像头预览,同时仍从摄像头获取视频源?

在这种情况下,我相信您可以继续使用 squarecam 中的代码并简单地隐藏 PreviewLayer。

你仍然会得到

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

所以你可以得到图像。

但是,我建议您找到 Stachecam 的示例代码并查看实时人脸检测的 AVMetaDataOutput 实现

于 2013-11-25T18:17:08.053 回答
0

您可以使用UIImagePickerViewController并将showsCameraControls属性设置为NO并提供您自己的用户界面cameraOverlayView。这是示例https://developer.apple.com/LIBRARY/IOS/samplecode/PhotoPicker/Introduction/Intro.html

或者可以使用AVFoundation类,referAVCamCaptureManagerAVCamRecorderclasses。这是苹果的演示https://developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010112

于 2013-11-25T07:40:50.717 回答