我使用 GPUImageStillCamera 拍照并将图片加载到 GPUImageView
现在如何将过滤器应用于静止的 GPUImageView?
我在网上看到的唯一示例是首先创建一个 GPUImagePicture(需要 UIImage),但是当我可以直接将过滤器应用于 GPUImageView 时,必须从 GPUImageView 创建一个 UIImage 然后将其加载到 GPUImagePicture 中似乎相当浪费。但我不知道如何
我试过了:
GPUImageFilter *sepiaFilter [[GPUImageSepiaFilter alloc]init];
[sepiaFilter addTarget:gpuImageView];
//and then tried these in a bunch of different orders
[filter useNextFrameForImageCapture];
[currentFilter endProcessing];
[currentFilter imageFromCurrentFramebuffer];
编辑:这是我将图像加载到 GPUImageView 中的方式
self.stillCamera = [[GPUImageStillCamera alloc]
initWithSessionPreset:AVCaptureSessionPresetPhoto
cameraPosition:AVCaptureDevicePositionFront];
self.stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
self.filterEmpty = [[GPUImageGammaFilter alloc] init];
[self.stillCamera addTarget:self.filterEmpty];
[self.filterEmpty addTarget:self.capturedImageView];
[self.stillCamera startCameraCapture];
[self.stillCamera capturePhotoAsJPEGProcessedUpToFilter:self.filterEmpty withCompletionHandler:^(NSData *processedJPEG, NSError *error){
[self.stillCamera stopCameraCapture];
//and then from here the gpuimageview is loaded with the taken picture