I have a video with green background and I want to display it over live camera view and remove green background. I also want to display it in separate view so user would be able to move or resize video. Is that possible with GPUImage? Can you describe required steps to do this?
Asked
Active
Viewed 255 times
1 Answers
0
Yes, It's possible! You can design your filter chain as follow:
GPUImageVideoCamera --> your GPUImageTwoInputFilter --> live camera GPUImageView
Your GPUImageMovie --> your GPUImageTwoInputFilter
Your GPUImageMovie --> separate GPUImageView
You have to write your own GPUImageTwoInputFilter to overlay green background video (inputImageTexture2) on live camera (inputImageTexture). In glsl fragment shader, add following code in main:
texel = texture2D(inputImageTexture, textureCoordinate);
texel2 = texture2D(inputImageTexture2, textureCoordinate);
if (texel2.g > Tg && texel2.r < Tr && texel2.b < Tb) {
gFragColor = texel;
} else {
gFragColor = texel2;
}
with Tr, Tg, Tb is the threshold to determine which is green background

hoangdado
- 436
- 4
- 13