2010-05-03 1244 views
2

我想要实现的是获取未压缩的摄像头视频流并将其转换为OpenGL纹理,以在CAOpenGLLayer中显示它。这是正确的流程?CAOpenGLLayer中的摄像头视频流

我以为使用类似于here提出的技术来显示电影视频帧,但下面的代码片段不工作,最后tex坐标全部为零。

那里有一些例子可以指出我正确的方向吗?

- (void) awakeFromNib { 

    QTCaptureSession *session = [[QTCaptureSession alloc] init]; 
    QTCaptureDevice *iSight = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeVideo]; 
    [iSight open:nil]; 

    QTCaptureDeviceInput *myInput = [QTCaptureDeviceInput deviceInputWithDevice:iSight]; 
    QTCaptureDecompressedVideoOutput *mCaptureDecompressedVideoOutput = [[QTCaptureDecompressedVideoOutput alloc] init]; 
    [mCaptureDecompressedVideoOutput setDelegate:self]; 

    [session addInput:myInput error:nil]; 
    [session addOutput:mCaptureDecompressedVideoOutput error:nil]; 
    [session startRunning]; 
} 

- (void)captureOutput:(QTCaptureOutput *)captureOutput didOutputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection 
{ 
    GLfloat     lowerLeft[2]; 
    GLfloat     lowerRight[2]; 
    GLfloat     upperRight[2]; 
    GLfloat     upperLeft[2]; 

    CVOpenGLTextureGetCleanTexCoords(imageBuffer, lowerLeft, lowerRight, upperRight, upperLeft); 
} 

回答

0

更好地检查Xcode的示例代码,有一个名为LiveVideoMixer的项目可能可以帮助你。

+0

所有这些例子都只有32位。这个问题涉及64位AVFoundation或QTKit框架。 – spudwaffle 2011-12-28 19:58:40