问题
I have been using GPUImage
for my project and I am getting into this problem where imageFromCurrentFramebuffer
returns nil for some of the GPUImageLookupFilter's
.
I subclassed GPUImageFilterGroup
like in the GPUImageAmatorkaFilter
my code is as follows:
-(MTLookupFilter *) initWithLookupImageName:(NSString *) lookupImageName {
self = [super init];
if (self) {
UIImage *image = [UIImage imageNamed:lookupImageName];
self.lookupImageSource = [[GPUImagePicture alloc] initWithImage:image];
GPUImageLookupFilter *lookupFilter = [[GPUImageLookupFilter alloc] init];
[self addFilter:lookupFilter];
[self.lookupImageSource addTarget:lookupFilter atTextureLocation:1];
[self.lookupImageSource processImage];
self.initialFilters = [NSArray arrayWithObjects:lookupFilter, nil];
self.terminalFilter = lookupFilter;
}
return self;
}
I have several of the objects of this class added into an array and I use:
- (IBAction)filterAction:(id)sender {
NSInteger index = arc4random()%self.filtersArray.count;
id filter = self.filtersArray[index];
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:self.fullImage];
UIImage *filteredimage = nil;
[stillImageSource addTarget:filter];
[stillImageSource processImage];
[filter useNextFrameForImageCapture];
filteredimage = [filter imageFromCurrentFramebuffer];
if (filteredimage) {
self.imageView.image = filteredimage;
} else {
NSLog(@"Filtered image is nil");
}
}
The returned image from imageFromCurrentFramebuffer
is sometimes nil and I do not understand it's cause. I would be thankful for any help. Sometimes the image is nil even for the filters, GPUImageAmatorkaFilter
, GPUImageSoftEleganceFilter
and `GPUImageMissEtikateFilter so I know it is not a problem with my subclass.
来源:https://stackoverflow.com/questions/23803436/gpuimage-imagefromcurrentframebuffer-returning-nil-sometimes-for-gpuimagelookupf