当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - GPUImageAlphaBlendFilter - Incomplete filter FBO: 36054

问题描述:

I am trying to use the GPUImageChromaKeyFilter according to the FilterShowcase app from GPUImage examples, but obviously I am missing something because it crashes.

Here is my code:

 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];

When I run it, it just tells this:

2013-06-24 15:24:45.369 GPUImage Test[1284:1703] * Assertion failure

in -[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] * Terminating app

due to uncaught exception 'NSInternalInconsistencyException', reason:

'Incomplete filter FBO: 36054'

* First throw call stack:

(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: terminate called throwing an exception

Does anybody see what I do wrong?

Thanks in advance.

网友答案:

-processImage is asynchronous. It won't run to completion when you call it, so you need to maintain the filter structure until it finishes processing.

This means that you can't call -removeTarget: right afterwards, and also means that you'll need for your sourcePicture instance to hang around as an instance variable until the processing is completed. Otherwise, it will be deallocated at the end of this method and will tear down its outputs as a result.

You want to set up your filter chain and run -processImage when everything's configured properly. You need to maintain the source picture for as long as you need the filtered result.

分享给朋友:
您可能感兴趣的文章:
随机阅读: