我需要显示实时摄像机源。我使用了 GPUImage,当我执行代码时出现此错误。我参考了一些文档,并在 viewDidLoad 中编写了代码。当我打开应用程序时,它崩溃了。
- (void)viewDidLoad
{
[super viewDidLoad];
GPUImageVideoCamera *videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
GPUImageFilter *customFilter = [[GPUImageFilter alloc] initWithFragmentShaderFromFile:@"CustomShader"];
GPUImageView *filteredVideoView = [[GPUImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height)];
// Add the view somewhere so it's visible
[videoCamera addTarget:customFilter];
[customFilter addTarget:filteredVideoView];
[videoCamera startCameraCapture];
}
日志:
Failed to load vertex shader
Failed to compile fragment shader
Program link log: ERROR: OpenGL ES 2.0 requires exactly one vertex and one fragment shader to validly link.
Fragment shader compile log: (null)
Vertex shader compile log: (null)
*** Assertion failure in -[GPUImageFilter initWithVertexShaderFromString:fragmentShaderFromString:], /Users/ranganathagv/Projects/MobileApp/test/iOS/View/28May_GPU/BradLarson-GPUImage-f67cbd9/framework/Source/GPUImageFilter.m:76
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Filter shader link failed'