Reputation: 4692
spent some time and can't really understand where is a problem.
I'm using GPUImage 0.1.3 (from CocoaPods) and have very straightforward code:
GPUImageiOSBlurFilter *iosBlur = [[GPUImageiOSBlurFilter alloc] init];
UIImage *splashScreenImage = [UIImage imageNamed:@"Splash"];
UIImage *bluredImage = [iosBlur imageByFilteringImage:splashScreenImage];
bluredImage is nil. I stepped through the code, iosBlur isn't nil, splashScreenImage isn't nil and contains proper image (checked in debugger's quick view). So I don't have any idea where is a problem.
Upvotes: 2
Views: 952
Reputation: 2021
From the GPUImageOutput.h
// Platform-specific image output methods
// If you're trying to use these methods, remember that you need to set -useNextFrameForImageCapture
// before running -processImage or running video and calling any of these methods,
// or you will get a nil image
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
- (UIImage *)imageByFilteringImage:(UIImage *)imageToFilter;
Upvotes: 0
Reputation: 2827
This is how I worked around it - crude, but works. BTW - this still happens with the latest code of GPUImage, although I mostly see the issue in the simulator.
int errorCount = 0;
UIImage *blurImage;
//Loop workaround for some unknown GPUImage issue where sometimes the result is nil.
while (! (blurImage = [imageFilter imageByFilteringImage:image]) ) {
++errorCount;
}
if (errorCount > 0) {
NSLog(@"GPUImageiOSBlurFilter imageByFilteringImage error count: %i", errorCount);
}
Upvotes: 1