首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GPUImage对GPUImageView应用筛选器

GPUImage对GPUImageView应用筛选器
EN

Stack Overflow用户
提问于 2015-01-23 10:14:54
回答 1查看 1K关注 0票数 1

我使用GPUImageStillCamera拍摄照片并将其加载到GPUImageView中

现在,我如何将过滤器应用于静态GPUImageView?

我在网上看到的唯一例子是首先创建一个GPUImagePicture (这需要一个UIImage),但是如果必须从GPUImageView创建一个UIImage,然后将它加载到GPUImagePicture中,而我可以直接将过滤器应用到GPUImageView中,这似乎是相当浪费的。但我不知道如何

我试过了:

代码语言:javascript
复制
  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中

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2015-01-24 02:17:09

在GPUImageView上有一个常规的图像视图。

让我们称其为UIImageVIew imageView

代码语言:javascript
复制
[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.
}];

至少,这是我在一个实时照片过滤应用上做的,而且它工作得很完美。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28102016

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档