【问题标题】:Show camera stream while AVCaptureSession's running在 AVCaptureSession 运行时显示相机流
【发布时间】:2010-08-02 01:58:16
【问题描述】:

根据http://developer.apple.com/iphone/library/qa/qa2010/qa1702.html,我能够使用 AVCaptureSession 从摄像头捕获视频帧。但是,似乎 AVCaptureScreen 从相机捕获帧而不在屏幕上显示相机流。我还想像在 UIImagePicker 中一样显示相机流,以便用户知道相机正在打开并看到相机指向的内容。任何帮助或指针将不胜感激!

【问题讨论】:

    标签: iphone avfoundation avcapturedevice avcapturesession


    【解决方案1】:

    AVCaptureVideoPreviewLayer 正是您要找的。​​p>

    Apple 用来演示如何使用它的代码片段是:

    AVCaptureSession *captureSession = <#Get a capture session#>;
    AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:captureSession];
    UIView *aView = <#The view in which to present the layer#>;
    previewLayer.frame = aView.bounds; // Assume you want the preview layer to fill the view.
    [aView.layer addSublayer:previewLayer];
    

    【讨论】:

    • 谢谢,我一直在寻找一种显示图像的方法,终于找到了一个正确且有效的答案:)
    猜你喜欢
    • 1970-01-01
    • 2016-09-22
    • 1970-01-01
    • 1970-01-01
    • 2012-10-17
    • 1970-01-01
    • 2012-10-23
    • 1970-01-01
    • 2018-02-09
    相关资源
    最近更新 更多