iOS - GPUImage искажен

Я использую GPUImage, чтобы применять живые фильтры к изображениям с камер. проблема заключается в том, что как только я получаю изображение, оно становится пиксельным. Вот мой код:

в viewDidLoad:

imageCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPresetPhoto cameraPosition:AVCaptureDevicePositionBack];
imageCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
normalImgView = [[GPUImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height-100)];
[normalImgView setFillMode:kGPUImageFillModePreserveAspectRatioAndFill];

И вот как я снимаю изображение:

[imageCamera capturePhotoAsImageProcessedUpToFilter:selectedFilter withCompletionHandler:^(UIImage *processedImage, NSError *error){
    NSLog(@"processedImage %@", processedImage);

    NSData *dataForPNGFile = UIImageJPEGRepresentation(processedImage, 1.0);

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];

    NSError *error2 = nil;
    if (![dataForPNGFile writeToFile:[documentsDirectory stringByAppendingPathComponent:@"FilteredPhoto.jpg"] options:NSAtomicWrite error:&error2])
    {
        return;
    }

    if (processedImage) {
        //Display it in an image view
    }
}];

Я добавил точки останова, чтобы отслеживать выполнение и видеть, в какой части именно изображение становится пиксельным. Это был imageFromCurrentFramebufferWithOrientation объекта GPUImageOutput: в этой строке:

CGImageRef cgImageFromBytes = [self newCGImageFromCurrentlyProcessedOutput];

newCGImageFromCurrentlyProcessedOutput всегда возвращает ноль

- (CGImageRef)newCGImageFromCurrentlyProcessedOutput;
{
    return nil;
}

Как я могу это исправить?

0 ответов

Другие вопросы по тегам