开发者

Camera video stream inside CAOpenGLLayer

What I'm trying to achieve is to get the uncompressed camera video stream and to convert it into an OpenGL texture, to show it inside an CAOpenGLLayer. Is it the right flow?

I thought to use a tecnique similar to the one proposed here to show movie video frames, but the following snippet is not working, at the end the tex coords are all zero.

Is there some example out there to point me in the right direction?

- (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];
  开发者_C百科  [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);
}


Better check out the sample code from Xcode, there have a project called LiveVideoMixer might can help you out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜