iOS GPUImage research six: add image watermark to video

Foreword:

我们在前面已经做了关于、GPUImage导入方式、滤镜介绍、性能对比、图片处理、捕获照片处理、实时滤镜以及一个比较完整地Demo。

today:

我们来给摄像头添加一个实时视频水印,很简单,大概有60行代码。

For how to import GPUImage, please see here:
http://blog.csdn.net/xoxo_x/article/details/60323297


Effect picture:

使用一张美女图片作为图片水印,然后获取摄像头数据。将二者组合,可以看到颜色的叠加,但又似乎不是简单地叠加。

write picture description here


An overview of the code is as follows:

write picture description here


The principle is as follows:

GPUImagePicture、GPUImageVideoCamera均可作为纹理来源,我们将两个纹理来源交给混合滤镜,混合滤镜将两种纹理按相乘颜色照矩阵的方式组合成新的纹理。

GPUImageView can be used as an output source, presenting textures to us.

First we need to understand the filters provided by GPUImage:
http://blog.csdn.net/xoxo_x/article/details/57082804

The video watermark uses a blending filter

    1Color adjustments: 31 filters, 颜色处理相关
    2、Image processing: 40 filters, 图像处理相关.
    3、Blending modes: 29 filters, 混合模式相关.
    4、Visual effects: 25 filters, 视觉效果相关.

Schematic:

write picture description here


Then, in another case: add a picture watermark to the existing video A

使用的是GPUImageMovie作为输入源,来代替GPUImageVideoCamera,其余不变。

So, another case: use existing video A as live video watermark

GPUImageVideoCamera不变,通过改变纹理来源,即通过使用GPUImageVideoFile来获取视频水印,作为纹理,代替使用GPUImagePicture。这样,我们就可以制作关于视频的视频水印了。

So, another case: use the existing video A as the watermark of the existing video B

二者均使用的是GPUImageMovie作为输入源

Then, another case: use the existing picture A as the watermark of the existing picture B

二者均使用的是GPUImagePicture作为输入源
不过,这个似乎有些奇怪,实验结果,就是两张照片融合到了一起,有点像换场动画。

Welcome to tip – you can add friends after tipping O(∩_∩)O haha~

write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324803158&siteId=291194637