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];
[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);
}