美颜sdk人像美妆是非常重要的一个功能,目前深受广大用户喜爱,本篇文章小编将为大家讲解一下美颜sdk人像美妆功能的代码以及算法实现流程。
1、人像美妆算法流程
首先进行妆容模板制作,主要由Photoshop等编辑软件制作,最终由设计完成。人脸检测,特征点识别,这一步骤主要通过人脸检测、人脸对齐等技术来获得N个特征点。接下来基于人脸特征点,将模板变形,对齐到人脸五官区域。其中,变相算法有很多,包含仿射变化,IDW变换,MLS变换,RMLS变换等。最后将模板与人脸五官图像进行融合,融合算法主要有alpha融合,Photoshop图层混合,泊松融合等。由于篇幅原因,关于变换融合,就不再一一展开了。
2、代码分析
//
// MHOpenDemoUITests.m
// MHOpenDemoUITests
//
// Created by Apple on 2021/5/31.
//
//
//
//
//
#import <XCTest/XCTest.h>
@interface MHOpenDemoUITests : XCTestCase
@end
@implementation MHOpenDemoUITests
-
(void)setUp {
// Put setup code here. This method is called before the invocation of each test method in the class.// In UI tests it is usually best to stop immediately when a failure occurs.
self.continueAfterFailure = NO;// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
} -
(void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
} -
(void)testExample {
// UI tests must launch the application that they test.
XCUIApplication *app = [[XCUIApplication alloc] init];
[app launch];// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
} -
(void)testLaunchPerformance {
if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) {
// This measures how long it takes to launch your application.
[self measureWithMetrics:@[[[XCTApplicationLaunchMetric alloc] init]] block:^{
[[[XCUIApplication alloc] init] launch];
}];
}
}
@end