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.