我正在写一个iPhone应用程序,它使用OpenCV进行某种实时图像检测。什么是将CMSampleBufferRef
图像从相机(我使用AVFoundation的AVCaptureVideoDataOutputSampleBufferDelegate
)转换为OpenCV能够理解的IplImage
的最佳方法?转换需要足够快,以便它可以实时运行。将CMSampleBufferRef转换为OpenCV IplImage的最佳/最快方法是什么?
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// Convert CMSampleBufferRef into IplImage
IplImage *openCVImage = ???(sampleBuffer);
// Do OpenCV computations realtime
// ...
[pool release];
}
在此先感谢。
这种运作良好,640x480的图像转换时间为0.00020秒正负0.00004我的iPhone 4 – cduck 2011-03-04 04:06:55
@cduck:是的,即使在3GS上,我使用此解决方案实现了30 fps。 – 2011-03-04 08:12:12