質問

I'm having issues with the latest refactor. Every time I try to get the processed UIImage from the filter, it is nil. I have used useNextFrameForImageCapture but it still doesn't work. Here is a snippet from my code:

self.imageView = [[GPUImageView alloc] initWithFrame:CGRectMake(0,
                                            0,
                                            self.view.frame.size.width,
                                            self.view.frame.size.height)];
staticPicture = [[GPUImagePicture alloc] initWithImage:img
                                   smoothlyScaleOutput:YES];
filter = [[GPUImageToneCurveFilter alloc] initWithACV:@"cool"];
[staticPicture addTarget:filter];
[filter addTarget:self.imageView];

GPUImageRotationMode imageViewRotationMode = kGPUImageNoRotation;
switch (staticPictureOriginalOrientation) {
    case UIImageOrientationLeft:
        imageViewRotationMode = kGPUImageRotateLeft;
        break;
    case UIImageOrientationRight:
        imageViewRotationMode = kGPUImageRotateRight;
        break;
    case UIImageOrientationDown:
        imageViewRotationMode = kGPUImageRotate180;
        break;
    default:
        imageViewRotationMode = kGPUImageNoRotation;
        break;
}

// seems like atIndex is ignored by GPUImageView...
[self.imageView setInputRotation:imageViewRotationMode atIndex:0];

[staticPicture useNextFrameForImageCapture];
[staticPicture processImage];
UIImage *processedImage = [filter imageFromCurrentFramebufferWithOrientation:staticPictureOriginalOrientation];

processedImage is always nil. Would appreciate any help!

役に立ちましたか?

解決

@BradLarson answered my question: You need to use -useNextFrameForImageCapture on the filter you want to capture from, not the input image. It has to tell the filter to hold on to its framebuffer. In your case, you need to call [filter useNextFrameForImageCapture].

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top