我正在尝试根据 GPUImage 示例中的 FilterShowcase 应用程序使用 GPUImageChromaKeyFilter,但显然我错过了一些东西,因为它崩溃了。
这是我的代码:
videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
GPUImageChromaKeyFilter *filter = [[GPUImageChromaKeyFilter alloc] init];
[filter setColorToReplaceRed:0.0 green:1.0 blue:0.0];
[filter prepareForImageCapture];
videoView = [[GPUImageView alloc] initWithFrame:CGRectMake(0, 0, 640, 480)];
[self.view addSubview:videoView];
UIImage *inputImage = [UIImage imageNamed:@"bedroom.jpeg"];
GPUImagePicture *sourcePicture = [[GPUImagePicture alloc] initWithImage:inputImage smoothlyScaleOutput:YES];
[sourcePicture processImage];
[sourcePicture addTarget:filter];
[sourcePicture removeTarget:filter];
[videoCamera removeTarget:filter];
[videoCamera addTarget:filter];
GPUImageAlphaBlendFilter *blendFilter = [[GPUImageAlphaBlendFilter alloc] init];
blendFilter.mix = 1.0;
[sourcePicture addTarget:blendFilter];
[filter addTarget:blendFilter];
[blendFilter addTarget:videoView];
[videoCamera startCameraCapture];
当我运行它时,它只是告诉这个:
2013-06-24 15:24:45.369 GPUImage 测试[1284:1703] *断言失败 -[GPUImageAlphaBlendFilter createFilterFBOofSize:], /Users/hello/Desktop/xcode/GPUImage Test/GPUImage/framework/Source/GPUImageFilter.m: 369
2013-06-24 15:24:45.383 GPUImage Test[1284:1703] *由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“过滤器 FBO 不完整:36054”
*首先抛出调用栈:
(0x3134f3e7 0x391d9963 0x3134f29d 0x31c25fa3 0xc9563 0xd608d 0xc8b3d 0xc9885 0xdaa63 0xcc11f 0xdb39f 0xca07b 0xcc153 0xd266f 0xd2dbb 0xd3f35 0x395f3793 0x395f6b3b 0x395f467d 0x395f7613 0x395f77d9 0x3961b7f1 0x3961b684)
libc++abi.dylib:终止调用抛出异常
有人看到我做错了吗?
提前致谢。