gpt4 book ai didi

ios - 由于未捕获的异常 'NSInternalInconsistencyException' 而终止应用程序,原因 : 'Filter shader link failed'

转载 作者:行者123 更新时间:2023-11-29 02:56:05 24 4
gpt4 key购买 nike

我需要显示实时摄像头画面。我使用 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'

最佳答案

确保着色器已添加到您的 Copy Bundle Resources 构建阶段。默认情况下,Xcode 会尝试将它们编译为源代码文件,而不是像它们应该的那样将它们包含在您的应用程序包中。

关于ios - 由于未捕获的异常 'NSInternalInconsistencyException' 而终止应用程序,原因 : 'Filter shader link failed' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23910440/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com