Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Blending more then 2 BlendFilters #597

Closed
shshalom opened this Issue · 4 comments

2 participants

@shshalom

Hey Brad,

I'm trying to blend more then two filters (With Images) on top live camera.
I've manage to blend 2 images with blendFilters but when I chained the third filter I get black screen.

Is it possible? and if so what is the right way to do this.

Thanks,
Shalom.

@BradLarson
Owner

Could you provide the code you're using to blend these three filters? That might help to figure out what's going wrong.

@shshalom
videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;

GPUImageView *filterView = (GPUImageView *)self.view;

GPUImageScreenBlendFilter *screen = [[GPUImageScreenBlendFilter alloc] init];
 [videoCamera addTarget:screen];

 UIImage *layer1 = [UIImage imageNamed:@"f12_03_screen.png"];
 sourcePicture = [[GPUImagePicture alloc] initWithImage:layer1 smoothlyScaleOutput:YES];
 [sourcePicture processImage];
 [sourcePicture addTarget:screen];

 GPUImageMultiplyBlendFilter *multiply2 = [[GPUImageMultiplyBlendFilter alloc] init];
 [screen addTarget:multiply2];

 UIImage *layer2 = [UIImage imageNamed:@"f12_04_multiply.png"];
 sourcePicture = [[GPUImagePicture alloc] initWithImage:layer2 smoothlyScaleOutput:YES];
 [sourcePicture processImage];
 [sourcePicture addTarget:multiply2];

GPUImageOverlayBlendFilter *overlay3 = [[GPUImageOverlayBlendFilter alloc] init];
[multiply2 addTarget:overlay3];

UIImage *layer3 = [UIImage imageNamed:@"f12_08_overlay.jpg"];
 sourcePicture = [[GPUImagePicture alloc] initWithImage:layer3 smoothlyScaleOutput:YES];
 [sourcePicture processImage];
 [sourcePicture addTarget:overlay3];

 [overlay3 addTarget:filterView];


 [videoCamera startCameraCapture];




@BradLarson
Owner

Is this ARC-enabled code? If so, you're deallocating your source images. You need to hold on to them as instance variables, or they will go away as soon as you leave this method. This can cause bizarre behavior, including black images and crashes.

@shshalom

Yes, that was my mistake.

Thank you!!!

@BradLarson BradLarson closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.