我正在实施一个软件来捕捉来自网络摄像头的视频。我在 Apple Dev 中看到了 MyRecorder 示例,它运行良好。
我尝试使用以下代码添加一个按钮以从视频中拍摄快照:
- (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);
}
但它从未被调用。如何决定何时调用 captureOutput 委托方法?任何的想法?
谢谢,安德里亚