cool hit counter Python has a house of gold, OpenCV has a face, and the face fusion algorithm is open source and comparable to a facelift!_Intefrankly

Python has a house of gold, OpenCV has a face, and the face fusion algorithm is open source and comparable to a facelift!

python & opencv Build the latest face fusion feature of current cameras。


Most of the current IT big business on the face technology are research, face recognition, face detection, etc., to our daily P map software, just say a daily P map software APP I know can be achieved, Face++ has created a face technology API, but it is charged and a little expensive, so this time the face fusion algorithm directly open source for everyone to use. (Python source code to the end of the article)

Let's first look at the difference between the major software and what we achieved with Python_OpenCV.

The left side is the fused figure, the right side is the figure to be fused

Hands on with face fusion technology.

Zero, fusion function

Program entry function

Parameter meaning.

Detection and critical positioning

There are various methods for face detection and key point localization

Detection using the open source Dlib library locates and locates 68 key points

Face recognition and APIs using Tencent's platform can locate and locate 90 key points

Face recognition and APIs using the Face++ platform can locate 106 key points

We went with the Face++ api, which as mentioned earlier is fee-based, and as you can see here is much more powerful!

Aligning face angles

Provided that the face figure to be fused is not a side face, by adjusting the plane position and angle to make it face overlap with the figure that will be fused.

src_points already dst_points The input parameter is the face key point matrix obtained in the first step

Alignment using "conventional Procrustes analysis"


Take the key points again and then blend the face

Again, take the key points of the converted image to be blended and triangulate them with the key points of the model image to make a new image


Processing of fused images

Take the keypoints of the above result image and use triangular affine to deform the face outline and keypoints of the blended image to the face keypoints obtained above

Disposal outcome.

The final step is to attach the blended face to the model image

Paste onto the model image using Poisson fusion algorithm. Poisson fusion can be done using the functions provided by opencv


End result.

If you're not satisfied enough, continue with the beauty, as mentioned in my last tutorial on python+OpenCV, just a few lines of Python code.

1、A chart to understand the cyber security law
2、Library Notice of Launch of Trial TVMVDB TV News Information Teaching and Research Database
3、AI to replace 77 of Chinese jobs in the next 1020 years
4、Will the little guy be ignored and folded away in the coming age of AI
5、Download and install Python 37

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送