我使用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
答案 0 :(得分:0)
在GPUImageView上有一个常规的图像视图。
让我们称之为UIImageVIew imageView
。
[self.stillCamera capturePhotoAsImageProcessedUpToFilter:self.filterEmpty
withCompletionHandler:^(UIImage *processedImage, NSError *error) {
imageView.image = processedImage;
//stop, dispose of, or just continue with the camera,
//depending on what you want with your app.
}];
至少,这就是我在实时照片过滤应用上的表现方式,而且效果很好。