我想要实现的是获取未压缩的相机视频流并将其转换为OpenGL纹理,以在CAOpenGLLayer中显示它。这是正确的流程吗?
我想使用与提议的here类似的tecnique来显示电影视频帧,但下面的片段不起作用,最后tex的coords都为零。
是否有一些例子指出我正确的方向?
- (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 :(得分:0)
更好地查看来自Xcode的示例代码,有一个名为LiveVideoMixer的项目可能可以帮助你。