代码之家  ›  专栏  ›  技术社区  ›  Andrea Girardi

从网络摄像头捕捉可可帧

  •  7
  • Andrea Girardi  · 技术社区  · 16 年前

    - (IBAction)addFrame:(id)sender
    {
        CVImageBufferRef imageBuffer;
        @synchronized (self) {
            imageBuffer = CVBufferRetain(mCurrentImageBuffer);
        }
        if (imageBuffer) { 
        [ bla bla bla ]     
        }
    }
    

    但是mCurrentImageBuffer总是空的。我如何从网络摄像头中获取当前帧并打开mCurrentImageBuffer?

    我试着用

    (void)captureOutput:(QTCaptureOutput *)captureOutput 
                        didOutputVideoFrame:(CVImageBufferRef)videoFrame 
                        withSampleBuffer:(QTSampleBuffer *)sampleBuffer 
                        fromConnection:(QTCaptureConnection *)connection
    {
        CVImageBufferRef imageBufferToRelease;
    
        CVBufferRetain(videoFrame);
    
        @synchronized (self) {
            imageBufferToRelease = mCurrentImageBuffer;
            mCurrentImageBuffer = videoFrame;
        }
        CVBufferRelease(imageBufferToRelease);  
    } 
    

    知道吗?

    2 回复  |  直到 16 年前
        1
  •  3
  •   Brad Larson    16 年前

    -awakeFromNib MyRecorderController中的方法。如果不这样做,就不会捕获任何视频。

    就你试图使用的方法而言, -captureOutput:didOutputVideoFrame:withSampleBuffer:fromConnection: 是一种委托方法 QTCaptureDecompressedVideoOutput QTCaptureSession 使用 -addOutput:error: ,并为设置代理

    QTKit Capture QTKit Application Programming Guide .

        2
  •  3
  •   Peter Hosey    16 年前

    - (void)captureOutput:(QTCaptureOutput *)captureOutput 
                                    didOutputVideoFrame:(CVImageBufferRef)videoFrame 
                                    withSampleBuffer:(QTSampleBuffer *)sampleBuffer 
                                    fromConnection:(QTCaptureConnection *)connection
    

    但它从未被调用。

    实现此方法的对象是捕获输出对象的委托吗?