initial commit

This commit is contained in:
Caleb
2026-03-01 15:59:27 +08:00
commit a9e97d56cb
1426 changed files with 172367 additions and 0 deletions

View File

@@ -0,0 +1,138 @@
//
// FUManager.m
// FULiveDemo
//
// Created by on 2017/8/18.
// Copyright © 2017 . All rights reserved.
//
#import "FUManager.h"
#import "FUBeautyComponentManager.h"
#import "authpack.h"
#import <FURenderKit/FUGLDisplayView.h>
static FUManager *shareManager = NULL;
@interface FUManager ()
@property (nonatomic, assign) FUDevicePerformanceLevel devicePerformanceLevel;
@end
@implementation FUManager
+ (FUManager *)shareManager
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
shareManager = [[FUManager alloc] init];
});
return shareManager;
}
- (instancetype)init
{
if (self = [super init]) {
CFAbsoluteTime startTime = CFAbsoluteTimeGetCurrent();
NSString *controllerPath = [[NSBundle mainBundle] pathForResource:@"controller_cpp" ofType:@"bundle"];
NSString *controllerConfigPath = [[NSBundle mainBundle] pathForResource:@"controller_config" ofType:@"bundle"];
FUSetupConfig *setupConfig = [[FUSetupConfig alloc] init];
setupConfig.authPack = FUAuthPackMake(g_auth_package, sizeof(g_auth_package));
setupConfig.controllerPath = controllerPath;
setupConfig.controllerConfigPath = controllerConfigPath;
// FURenderKit
[FURenderKit setupWithSetupConfig:setupConfig];
[FURenderKit setLogLevel:FU_LOG_LEVEL_INFO];
self.devicePerformanceLevel = [FURenderKit devicePerformanceLevel];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
// AI
NSString *faceAIPath = [[NSBundle mainBundle] pathForResource:@"ai_face_processor" ofType:@"bundle"];
[FUAIKit loadAIModeWithAIType:FUAITYPE_FACEPROCESSOR dataPath:faceAIPath];
// AI ai_human_processor_gpu.bundle
NSString *humanBundleName = self.devicePerformanceLevel == FUDevicePerformanceLevelHigh ? @"ai_human_processor_gpu" : @"ai_human_processor";
NSString *bodyAIPath = [[NSBundle mainBundle] pathForResource:humanBundleName ofType:@"bundle"];
[FUAIKit loadAIModeWithAIType:FUAITYPE_HUMAN_PROCESSOR dataPath:bodyAIPath];
CFAbsoluteTime endTime = (CFAbsoluteTimeGetCurrent() - startTime);
NSString *path = [[NSBundle mainBundle] pathForResource:@"tongue" ofType:@"bundle"];
[FUAIKit loadTongueMode:path];
//TODO: todo
/* = 0*/ //
float flexible = 0.5;
[FUAIKit setFaceTrackParam:@"mouth_expression_more_flexible" value:flexible];
NSLog(@"---%lf",endTime);
//
[FUAIKit shareKit].faceProcessorFaceLandmarkQuality = self.devicePerformanceLevel == FUDevicePerformanceLevelHigh ? FUFaceProcessorFaceLandmarkQualityHigh : FUFaceProcessorFaceLandmarkQualityMedium;
//
[FUAIKit shareKit].faceProcessorDetectSmallFace = self.devicePerformanceLevel == FUDevicePerformanceLevelHigh;
});
[FURenderKit shareRenderKit].beauty = [self defaultBeauty];
[FUBeautyComponentManager.sharedManager beautyStyleSetAllDefaultValues];
[FUAIKit shareKit].maxTrackFaces = 4;
FUBeauty *beauty = [FURenderKit shareRenderKit].beauty;
beauty.colorLevel = 1;
beauty.redLevel = 1;
beauty.cheekThinning = 1;
}
return self;
}
- (void)destoryItems {
[FURenderKit shareRenderKit].beauty = nil;
[FURenderKit shareRenderKit].bodyBeauty = nil;
[FURenderKit shareRenderKit].makeup = nil;
[[FURenderKit shareRenderKit].stickerContainer removeAllSticks];
}
- (void)onCameraChange {
[FUAIKit resetTrackedResult];
}
- (FUBeauty *)defaultBeauty {
NSString *path = [[NSBundle mainBundle] pathForResource:@"face_beautification" ofType:@"bundle"];
FUBeauty *beauty = [[FUBeauty alloc] initWithPath:path name:@"FUBeauty"];
beauty.colorLevel = 1;
beauty.redLevel = 1;
beauty.cheekThinning = 1;
return beauty;
}
#pragma mark - VideoFilterDelegate
- (CVPixelBufferRef)renderItemsToPixelBuffer:(CVPixelBufferRef)frame {
if (UIApplication.sharedApplication.applicationState == UIApplicationStateBackground) {
return frame;
} else {
// FURenderKit
FURenderInput *input = [[FURenderInput alloc] init];
input.pixelBuffer = frame;
//
input.renderConfig.imageOrientation = FUImageOrientationUP;
//fuSetDefaultRotationMode
input.renderConfig.gravityEnable = YES;
//
input.renderConfig.isFromFrontCamera = YES;
//:
input.renderConfig.isFromMirroredCamera = YES;
FURenderOutput *output = [[FURenderKit shareRenderKit] renderWithInput:input];
return output.pixelBuffer;
}
}
@end