1

GPUImageStillCamera を使用して写真を撮り、その写真を GPUImageView に読み込みます

静止画の GPUImageView にフィルターを適用するにはどうすればよいですか?

私がオンラインで見た唯一の例は、最初に GPUImagePicture を作成することです (これには UIImage が必要です) が、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
4

1 に答える 1

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.
}];

少なくとも、これは私がリアルタイムの写真フィルタリング アプリで行う方法であり、完全に機能します。

于 2015-01-23T18:17:08.547 に答える