Camera video stream inside CAOpenGLLayer

What I am trying to achieve is to get an uncompressed camera video stream and convert it to an OpenGL texture to show it inside CAOpenGLLayer. Is this the correct flow?

I thought to use tecnique like the one suggested here to show the frames of the video, but the following snippet doesn't work, at the end of the tex coords is zero.

Is there any example 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];
    [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);
}

      

+2


a source to share


1 answer


Better to check the example code with Xcode, there might be a project called LiveVideoMixer.



0


a source







All Articles