I get an error if I insert this function -imageFromCurrentFramebufferWithOrientation - (GPUImageLookupFilter)

StackOverflow https://stackoverflow.com/questions/23173213

  •  06-07-2023
  •  | 
  •  

Вопрос

I have problems with implementing the GPUImageLookupFilter. I get an error in this line of code:UIImage *adjustedImage = [lookupFilter imageFromCurrentFramebufferWithOrientation];

It says (error): "No visible @interface for 'GPUImageLookupFilter' declares the selector 'imageFromCurrentFramebufferWithOrientation'"

This is my code:

- (IBAction)filter1:(id)sender;
{
GPUImageLookupFilter *lookup = [[GPUImageLookupFilter alloc] init];
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:imgView];

GPUImagePicture *lookupImageSource = [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:@"lookup_Invert.png"]];
GPUImageLookupFilter *lookupFilter = [[GPUImageLookupFilter alloc] init];
[stillImageSource addTarget:lookupFilter];
[lookupImageSource addTarget:lookupFilter];


[stillImageSource processImage];
[lookupFilter useNextFrameForImageCapture];
[lookupImageSource processImage];

UIImage *adjustedImage = [lookupFilter imageFromCurrentFramebufferWithOrientation];
}
Это было полезно?

Решение

First, please read through the documentation I've written on the very first page of the project. You'll save yourself a lot of headaches by reading that before progressing further. Blindly copying code from the Internet is not a great way to build an application.

As I explained in my answer that I pointed you to in your previous question, the way that the framework handles framebuffers has changed, so a lot of the sample code you find out there is now obsolete. For processing still images using a lookup filter, you need to send -useNextFrameForImageCapture to your lookup filter right before you trigger -processImage in the above. -processImage causes the initial image to cascade through the chained filter operations, and you need to tell your end filter that you'll be pulling an image from it before you trigger that processing.

Once that is done, you can then extract your image using -imageFromCurrentFramebuffer or -imageFromCurrentFramebufferWithOrientation: (note the parameter in the latter, because your code above won't compile).

Again, please read the resources I have linked to on the front page of GPUImage's GitHub repository and from my previous answer before proceeding further. You really should understand how this operates, which is why I'm not spoon-feeding you the code you need here.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top