I'm trying to grab video with an AVCaptureSession, process the video in the callback (eventually), then render the results into my GLKView. The code below works but the image in my GLKView is rotated 90 degrees and shrunk by 50%.
The glContext is created with [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
My coreImageContext is created with [CIContext contextWithEAGLContext:glContext];
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
// process the image
CVPixelBufferRef pixelBuffer = (CVPixelBufferRef)CMSampleBufferGetImageBuffer(sampleBuffer);
CIImage *image = [CIImage imageWithCVPixelBuffer:pixelBuffer];
// display it (using main thread)
dispatch_async( dispatch_get_main_queue(), ^{
// running synchronously on the main thread now
[self.coreImageContext drawImage:image inRect:self.view.bounds fromRect:[image extent]];
[self.glContext presentRenderbuffer:GL_RENDERBUFFER];
});
}
Inserting code to perform and affine transform seems inefficient. Am I missing a setup call or parameter to prevent the rotation and scaling?