我使用GPUImageStillCamera拍摄照片并将其加载到GPUImageView中
现在,我如何将过滤器应用于静态GPUImageView?
我在网上看到的唯一例子是首先创建一个GPUImagePicture (这需要一个UIImage),但是如果必须从GPUImageView创建一个UIImage,然后将它加载到GPUImagePicture中,而我可以直接将过滤器应用到GPUImageView中,这似乎是相当浪费的。但我不知道如何
我试过了:
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发布于 2015-01-24 02:17:09
在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.
}];至少,这是我在一个实时照片过滤应用上做的,而且它工作得很完美。
https://stackoverflow.com/questions/28102016
复制相似问题