Blending Using GPUImagePoissonBlendFilter

I am trying to use the GPUImagePoissonBlendFilter of a GPUImage structure to mix two faces in my blending application. Here is my code.

- (void)applyPoissonBlendToImage:(UIImage *) rearFace withImage:(UIImage *) frontFace { GPUImagePicture* picture1 = [[GPUImagePicture alloc] initWithImage:rearFace]; GPUImagePicture* picture2 = [[GPUImagePicture alloc] initWithImage:frontFace]; GPUImagePoissonBlendFilter * poissonFilter = [[GPUImagePoissonBlendFilter alloc] init]; poissonFilter.mix = .7; poissonFilter.numIterations = 200; [picture1 addTarget:poissonFilter]; [picture1 processImage]; [picture2 addTarget:poissonFilter]; [picture2 processImage]; finalResultImage = [poissonFilter imageFromCurrentlyProcessedOutputWithOrientation:rearFace.imageOrientation]; } 

ie As you can see, I give two images (rearFace and frontFace) as input for this method. The front face of the image is a shape (a polygon shape formed by connecting the relative position of the eyes and mouth) and is the same size as the back image ie (to fit the size, I filled the space external to the polygonal shape with a transparent color when drawing) .

However, the confusion does not occur as I expected. that is, the sharp edges of the front surface do not mix with the rear surface. Here my assumption is that the PoissonBlendFilter starts mixing the second image from the upper left corner, and not from the upper left face.

Problem: I feel that the input image does not feed into the filter correctly. Do I need to apply some kind of masking to the input image? Can anyone guide me on this?

+8
ios objective-c gpuimage opengl-es face-detection
source share
1 answer

GPUImage can sometimes be difficult using two input filters. When you add a blending filter to the first source image, specify the texture location explicitly. Therefore, instead of:

[picture1 addTarget:poissonFilter];

Try the following:

[picture1 addTarget:poissonFilter atTextureLocation:0];

The rest ( picture1 or any others) do not need this, but there is a small error with two input filters, which sometimes require an explicit location of the texture.

0
source share

All Articles