私はAVCaptureSessionでビデオを取り込み、コールバックでビデオを処理してから、結果を自分のGLKViewにレンダリングしようとしています。以下のコードは動作しますが、GLKViewの画像は90度回転して50%縮小します。CVPixelBufferRefから作成されたCIImageが回転し、GLKViewで縮小します。
glContextは[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]で作成されます。
My 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];
});
}
実行してアフィン変換するコードを挿入するのは効率が悪いようです。回転とスケーリングを防ぐためにセットアップコールやパラメータがないのですか?
ここで同じ問題が発生します。私はあなたの場合とほとんど同じコードを使用しました。私はあきらめて、アフィン変換を使って回転を補正し、画面全体を満たすように画像のサイズを変更しました。 –