我正在尝试使用AVCaptureSession获取视频,在回调中处理视频(最终),然后将结果渲染到我的GLKView中。以下代码可以工作,但是我GLKView中的图像旋转了90度且缩小了50%。
glContext是使用[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];创建的。
我的coreImageContext是通过[CIContext contextWithEAGLContext:glContext]; 创建的。
glContext是使用[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];创建的。
我的coreImageContext是通过[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];
});
}
插入代码以执行仿射变换似乎效率低下。我是否错过了一个设置调用或参数来防止旋转和缩放?