This commit is contained in:
Caleb
2025-11-21 12:00:40 +08:00
commit 18ea900c12
1189 changed files with 134605 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,58 @@
//
// FUAIConfig.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/11/20.
//
#import <Foundation/Foundation.h>
#import "FUConfig.h"
#import "FUStruct.h"
typedef enum : NSUInteger {
FUBodyTrackModeHalf,
FUBodyTrackModeFull,
} FUBodyTrackMode;
typedef enum : NSUInteger {
FUBodyTrackStatusNoBody,
FUBodyTrackStatusHalfLessBody,
FUBodyTrackStatusHalfBody,
FUBodyTrackStatusHalfMoreBody,
FUBodyTrackStatusFullBody
} FUBodyTrackStatus;
@interface FUAIConfig : FUConfig
@end
@interface FUAIConfig (AR)
@property (nonatomic, assign) BOOL ARModeEnable;
@end
@interface FUAIConfig (FaceTrack)
@property (nonatomic, assign) BOOL faceTrackEnable;
@end
@interface FUAIConfig (BodyTrack)
@property (nonatomic, assign) BOOL bodyTrackEnable;
@property (nonatomic, assign) FUBodyTrackMode bodyTrackMode;
@property (nonatomic, assign) BOOL handDetector;
@end
@interface FUAIConfig (Avatar)
@property (nonatomic, assign) FUPosition avatarTranslationScale;
/// 抖动参数设置
- (void)setAvatarAnimFilter:(int)bufferFrames pos:(float)pos angle:(float)angle;
@end

View File

@@ -0,0 +1,323 @@
//
// FUAIKit.h
// FURenderKit
//
// Created by liuyang on 2021/3/2.
//
#import <Foundation/Foundation.h>
#import "CNamaSDK.h"
#import "FURenderIO.h"
@class FUTrackFaceInput;
NS_ASSUME_NONNULL_BEGIN
/// 人脸检测模式
typedef enum : NSUInteger {
FUFaceProcessorDetectModeImage,
FUFaceProcessorDetectModeVideo,
} FUFaceProcessorDetectMode;
/// 人体检测模式
typedef enum : NSUInteger {
FUHumanProcessorDetectModeImage,
FUHumanProcessorDetectModeVideo
} FUHumanProcessorDetectMode;
/// 人脸点位算法性能
typedef enum : NSUInteger {
FUFaceProcessorFaceLandmarkQualityLow,
FUFaceProcessorFaceLandmarkQualityMedium,
FUFaceProcessorFaceLandmarkQualityHigh
} FUFaceProcessorFaceLandmarkQuality;
/// 人脸模型设置
typedef enum : NSInteger {
FUFaceModelConfigDefault = -1
} FUFaceModelConfig;
/// 人脸算法设置
typedef enum : NSUInteger {
FUFaceAlgorithmConfigEnableAll = 0, // 打开全部效果
FUFaceAlgorithmConfigDisableFaceOccu = 1 << 0, // 关闭全脸分割
FUFaceAlgorithmConfigDisableSkinSeg = 1 << 1, // 关闭皮肤分割
FUFaceAlgorithmConfigDisableDelSpot = 1 << 2, // 关闭祛斑痘
FUFaceAlgorithmConfigDisableARMeshV2 = 1 << 3, // 关闭 ARMeshV2
FUFaceAlgorithmConfigDisableRACE = 1 << 4, // 关闭人种分类
FUFaceAlgorithmConfigDisableLANDMARK_HP_OCCU = 1 << 5, //关闭高质量遮挡
FUFaceAlgorithmConfigDisableFaceOccuAndSkinSeg = FUFaceAlgorithmConfigDisableFaceOccu | FUFaceAlgorithmConfigDisableSkinSeg,
FUFaceAlgorithmConfigDisableFaceOccuAndDelSpot = FUFaceAlgorithmConfigDisableFaceOccu | FUFaceAlgorithmConfigDisableDelSpot,
FUFaceAlgorithmConfigDisableSkinSegAndDelSpot = FUFaceAlgorithmConfigDisableSkinSeg | FUFaceAlgorithmConfigDisableDelSpot,
FUFaceAlgorithmConfigDisableFaceOccuAndSkinSegAndDelSpot = FUFaceAlgorithmConfigDisableFaceOccu | FUFaceAlgorithmConfigDisableSkinSeg | FUFaceAlgorithmConfigDisableDelSpot,
FUFaceAlgorithmConfigDisableAll = FUFaceAlgorithmConfigDisableFaceOccu | FUFaceAlgorithmConfigDisableSkinSeg | FUFaceAlgorithmConfigDisableDelSpot | FUFaceAlgorithmConfigDisableARMeshV2 | FUFaceAlgorithmConfigDisableRACE | FUFaceAlgorithmConfigDisableLANDMARK_HP_OCCU
} FUFaceAlgorithmConfig;
/// 人体分割场景
typedef enum : NSUInteger {
FUHumanSegmentationSceneTypeMeeting = 0, // 视频会议
FUHumanSegmentationSceneTypeCommon // 通用
} FUHumanSegmentationSceneType;
/// 人体分割模式
typedef enum : NSUInteger {
FUHumanSegmentationModeCPUCommon = 0x00, // CPU通用模式
FUHumanSegmentationModeGPUCommon = 0x01, // GPU通用模式
FUHumanSegmentationModeGPUMeeting = 0x02 // GPU会议模式
} FUHumanSegmentationMode;
/// 人体算法设置
typedef enum : NSUInteger {
FUHumanAlgorithmConfigEnableAll = 0, // 打开全部效果
FUHumanAlgorithmConfigDisableSeg = 1 << 0, // 关闭人体分割
} FUHumanAlgorithmConfig;
@interface FUAIKit : NSObject
@property (nonatomic, assign) int maxTrackFaces; // 设置最大的人脸跟踪个数 default is 1
@property (nonatomic, assign, readonly) int trackedFacesCount; // 跟踪到的人脸个数
@property (nonatomic, assign) int maxTrackBodies; // 设置最大的人体跟踪个数 default is 1
@property (nonatomic, assign) FUFaceProcessorDetectMode faceProcessorDetectMode; // 人脸检测模式 default is FUFaceProcessorDetectModeVideo
@property (nonatomic, assign) FUHumanProcessorDetectMode humanProcessorDetectMode; // 人体检测模式default is FUHumanProcessorDetectModeVideo
@property (nonatomic, assign) BOOL faceProcessorSetFaceLandmarkHpOccu; // 遮挡点位是否使用高精度模型, 默认YESYES 高精度模型NO 通用模型
@property (nonatomic, assign) BOOL faceProcessorDetectSmallFace; // 是否开启小脸检测default is NO
@property (nonatomic, assign) BOOL asyncTrackFace; //设置是否进行异步人脸跟踪
@property (nonatomic, assign) BOOL faceRaceDetect; // 人种检测是否开启,默认关闭
@property (nonatomic, assign) FUFaceProcessorFaceLandmarkQuality faceProcessorFaceLandmarkQuality; // 人脸算法质量
+ (instancetype)shareKit;
/// 人脸模型设置
/// @param config 枚举值
/// @note 必须在加载 AI 人脸模型之前设置
+ (void)setFaceModelConfig:(FUFaceModelConfig)config;
/// 人脸算法设置
/// @param config 枚举值
/// @note 必须在加载 AI 人脸模型之前设置,默认 FUFaceAlgorithmConfigEnableAll
+ (void)setFaceAlgorithmConfig:(FUFaceAlgorithmConfig)config;
/// 人体模型设置
/// @param config 枚举值
/// @note 必须在加载 AI 人体模型之前设置,默认 FUHumanSegmentationModeCPUCommon
+ (void)setHumanModelConfig:(FUHumanSegmentationMode)config;
/// 人体算法设置
/// @param config 枚举值
/// @note 必须在加载 AI 人脸模型之前设置,默认 FUHumanAlgorithmConfigEnableAll
+ (void)setHumanAlgorithmConfig:(FUHumanAlgorithmConfig)config;
/// 强制设置使用 CPU 运行 AI 模型
/// @note 必须在加载 AI 模型之前设置
+ (void)setModelToCPU;
/// 加载AI模型
/// @param type AI类型
/// @param dataPath 模型路径
+ (void)loadAIModeWithAIType:(FUAITYPE)type dataPath:(NSString *)dataPath;
/// 加载人体AI模型
/// @param dataPath 模型路径
/// @param mode 人体分割模式
/// @note 使用 loadAIModeWithAIType:dataPath: 接口加载人体模型时默认的分割模式为 FUHumanSegmentationModeCPUCommon
+ (void)loadAIHumanModelWithDataPath:(NSString *)dataPath segmentationMode:(FUHumanSegmentationMode)mode;
/// 卸载AI模型
/// @param type AI 类型
+ (void)unloadAIModeForAIType:(FUAITYPE)type;
/// 卸载所有的AI模型
+ (void)unloadAllAIMode;
/// 判断某 AI 模型是否加载
/// @param type AI 类型
+ (BOOL)loadedAIType:(FUAITYPE)type;
/// 加载舌头模型
/// @param modePath 舌头模型地址
+ (void)loadTongueMode:(NSString *)modePath;
/// 设置 AI 识别类型
/// @param type AI 识别类型
+ (void)setTrackFaceAIType:(FUAITYPE)type;
/// 对输入的图像进行 AI 识别,支持人脸、身体、手指能类型的识别
+ (int)trackFaceWithInput:(FUTrackFaceInput *)trackFaceInput;
/// 图像明显发生改变时调用该接口重置内部检测结果
+ (void)resetTrackedResult;
/// 跟踪到的人脸数量
+ (int)aiFaceProcessorNums;
/// 设置面部参数
+ (void)setFaceTrackParam:(NSString *)param value:(int)value;
/**
获取人脸信息:
- 在程序中需要先运行过视频处理接口( 视频处理接口8 除外)或 人脸信息跟踪接口
后才能使用该接口来获取人脸信息;
-
该接口能获取到的人脸信息与我司颁发的证书有关,普通证书无法通过该接口获取到人脸信息;
- 具体参数及证书要求如下:
landmarks: 2D人脸特征点返回值为75个二维坐标长度75*2
证书要求: LANDMARK证书、AVATAR证书
landmarks_ar: 3D人脸特征点返回值为75个三维坐标长度75*3
证书要求: AVATAR证书
rotation: 人脸三维旋转返回值为旋转四元数长度4
证书要求: LANDMARK证书、AVATAR证书
translation: 人脸三维位移返回值一个三维向量长度3
证书要求: LANDMARK证书、AVATAR证书
eye_rotation: 眼球旋转,返回值为旋转四元数,长度4
证书要求: LANDMARK证书、AVATAR证书
rotation_raw: 人脸三维旋转不考虑屏幕方向返回值为旋转四元数长度4
证书要求: LANDMARK证书、AVATAR证书
expression: 表情系数长度46
证书要求: AVATAR证书
projection_matrix: 投影矩阵长度16
证书要求: AVATAR证书
face_rect: 人脸矩形框,返回值为(xmin,ymin,xmax,ymax)长度4
证书要求: LANDMARK证书、AVATAR证书
rotation_mode: 人脸朝向0-3分别对应手机四种朝向长度1
证书要求: LANDMARK证书、AVATAR证书
@param faceId 被检测的人脸 ID ,未开启多人检测时传 0
,表示检测第一个人的人脸信息;当开启多人检测时,其取值范围为 [0 ~ maxFaces-1]
,取其中第几个值就代表检测第几个人的人脸信息
@param name 人脸信息参数名: "landmarks" , "eye_rotation" , "translation" ,
"rotation" ....
@param pret 作为容器使用的 float 数组指针,获取到的人脸信息会被直接写入该 float
数组。
@param number float 数组的长度
@return 返回 1 代表获取成功,返回 0 代表获取失败
*/
+ (int)getFaceInfo:(int)faceId
name:(NSString *)name
pret:(float *)pret
number:(int)number;
/*
* 获取人种分类
* faceId 被检测的人脸 ID ,未开启多人检测时传 0
* return -1:unknow, 0:black, 1:white, 2:yellow, 3:brown
*/
+ (int)getFaceRace:(int)faceId;
/// 设置了InputCameraMatrix之后获取获取人脸信息
+ (int)getRotatedFaceInfo:(int)faceId
name:(NSString *)name
pret:(float *)pret
number:(int)number;
/// 人脸检测置信度
/// @param index 人脸索引
+ (float)fuFaceProcessorGetConfidenceScore:(int)index;
/// 设置跟踪到人脸时每次检测的间隔帧数
/// @param frames 帧数
/// @note 底层默认间隔帧数为7
+ (void)setFaceProcessorDetectEveryFramesWhenFace:(int)frames;
/// 设置未跟踪到人脸时每次检测的间隔帧数
/// @param frames 帧数
/// @note 底层默认间隔帧数为7
+ (void)setFaceProcessorDetectEveryFramesWhenNoFace:(int)frames;
/// 设置人脸离开延迟打开或关闭
/// @param enable YES为打开 NO为关闭
+ (void)setFaceDelayLeaveEnable:(BOOL)enable;
/// 跟踪到的人体数量
+ (int)aiHumanProcessorNums;
/// 重置身体识别
+ (void)resetHumanProcessor;
/// 设置人体分割场景类型
+ (void)setHumanSegmentationSceneType:(FUHumanSegmentationSceneType)type __attribute__((deprecated("Use loadAIHumanModelWithDataPath: segmentationMode: instead.")));
/// 跟踪到的手势数量
+ (int)aiHandDistinguishNums;
/// 获取手势类型
/// @param handIndex aiHandDistinguishNums返回手的索引
+ (FUAIGESTURETYPE)fuHandDetectorGetResultGestureType:(int)handIndex;
/// 设置未跟踪到手势时每次检测的间隔帧数
/// @param frames 帧数
+ (void)setHandDetectEveryFramesWhenNoHand:(int)frames;
/// 动作识别: actionId index of fuHumanProcessorGetNumResults
+ (int)fuHumanProcessorGetResultActionType:(int)actionId;
@end
@interface FUAIKit (Test)
@property (nonatomic, assign) float use_new_cnn_detection;
@property (nonatomic, assign) float other_face_detection_frame_step_new;
@property (nonatomic, assign) float min_facesize_big;
@property (nonatomic, assign) float small_face_frame_step;
@property (nonatomic, assign) float min_facesize_small;
@property (nonatomic, assign) float other_face_detection_frame_step;
@property (nonatomic, assign) float size_min;
@end
#pragma mark - FUTrackFaceInput
@interface FUTrackFaceConfig : NSObject
/// 是否进行舌头的检测,默认不对舌头进行检测。
@property (nonatomic, assign) BOOL trackTongue;
@property (nonatomic, assign) FUImageOrientation imageOrientation; // 设置人物在原始图像中的方向,默认为 FUImageOrientationUP。
@property (nonatomic, assign) BOOL gravityEnable; // 重力开关,开启此功能可以根据已设置的 trackOrientation 自动适配AI检测的方向。
/// 当前图片是否来源于前置摄像头,默认为 NO
@property (nonatomic, assign) BOOL isFromFrontCamera;
/// 当前图片是否来源于镜像摄像头,默认为 NO
@property (nonatomic, assign) BOOL isFromMirroredCamera;
@end
/// trackFaceWithInput 接口的输入CVPixelBufferRef、FUImageBuffer只需要传入一个就好如果传入多个将按优先级使用其中一种优先级为CVPixelBufferRef > FUImageBuffer;
@interface FUTrackFaceInput : NSObject
/// 输入的 pixelBuffer
@property (nonatomic, assign) CVPixelBufferRef pixelBuffer;
/// 输入的 imageBuffer
@property (nonatomic, assign) FUImageBuffer imageBuffer;
/// 设置 trackFace 相关的输入配置,详细参数请查看 FUTrackFaceConfig 类的接口注释。
@property (nonatomic, strong) FUTrackFaceConfig *trackFaceConfig;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,49 @@
//
// FUAISegmentItem.h
// FURenderKit
//
// Created by Chen on 2021/1/28.
//
#import "FUSticker.h"
#import "FUStruct.h"
#import "UIImage+FURenderKit.h"
NS_ASSUME_NONNULL_BEGIN
/**
* 人像分割道具
*/
@interface FUAISegment : FUSticker
/// 摄像机切换前后需要设置
@property (nonatomic, assign) int cameraMode;
/// 轮廓分割线和人体的间距
@property (nonatomic, assign) double lineGap;
/// 轮廓分割线宽度
@property (nonatomic, assign) double lineSize;
/// 轮廓分割线颜色
/// @note 忽略alpha
@property (nonatomic, assign) FUColor lineColor;
/// 自定义背景图片
@property (nonatomic, strong) UIImage *backgroundImage;
/// 自定义背景视频
/// @note NSURL or NSString设置以后自动开始播放
@property (nonatomic, copy) id videoPath; // 背景视频
/// 背景视频是否播放
@property (nonatomic, assign) BOOL pause;
/// 开始背景视频播放
- (void)startVideoDecode;
/// 取消背景视频播放
- (void)stopVideoDecode;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,16 @@
//
// FUActionRecognition.h
// FURenderKit
//
// Created by Chen on 2021/1/18.
//
#import "FUItem.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUActionRecognition : FUItem
@property (nonatomic, assign) double edgeDistance;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,17 @@
//
// FUAnimation.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/11/16.
//
#import "FUItem.h"
@interface FUAnimation : FUItem
+ (instancetype)animationWithPath:(NSString *)path name:(NSString *)name;
- (NSArray *)getAllAnimations;
- (NSArray *)getAllItems;
@end

View File

@@ -0,0 +1,22 @@
//
// FUAnimoji.h
// FURenderKit
//
// Created by Chen on 2021/1/28.
//
#import "FUSticker.h"
NS_ASSUME_NONNULL_BEGIN
/**
* FUAnimoji 表情
*/
@interface FUAnimoji : FUSticker
/**
* NO 不跟随YES 跟随
*/
@property (nonatomic, assign) BOOL flowEnable;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,245 @@
//
// FUAvatar.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/11/16.
//
#import "FUItem.h"
#import "FUAnimation.h"
#import "FUStruct.h"
#import "FUFacepupKeys.h"
#import "FUDeformationKeys.h"
#import "FUAvatarColorKeys.h"
#import "FUAvatarMakeup.h"
#import "CNamaSDK.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUAvatar : FURenderableObject
@property (nonatomic, assign) FUPosition position;
@property (nonatomic, assign) BOOL visible;
@property (nonatomic, assign) double rotate;
/// 身体组件列表
@property (nonatomic, copy, readonly) NSArray<FUItem *> *components;
/// 当前正在播放的动画
@property (nonatomic, strong, readonly) FUAnimation *currentAnimation;
/// 动画列表
@property (nonatomic, copy, readonly) NSArray<FUAnimation *> *animations;
@property (nonatomic, assign) int faceTrackID;
// 阴影
@property (nonatomic, assign) double shadowPCFLevel;
@property (nonatomic, assign) int shadowSampleOffset;
- (void)updateTransformWithTranslateDelta:(float)translateDelta rotateDelta:(float)rotateDelta scaleDelta:(float)scaleDelta;
/// 通过Avatar的名称获取Avatar信息的Json字符串
/// @param name Avatar的名称
- (NSString *)avatarJsonWithName:(NSString *)name;
@end
@interface FUAvatar (Component)
/// 添加身体组件,如果组件的 name 不为空,可以通过 name 查找或移除组件;如果 avatar 已有组件存在与新组件名称一致的组件,已存在的组件将被替换。
/// @param component 身体组件
- (void)addComponent:(FUItem *)component;
- (BOOL)replaceComponent:(FUItem *)component withNewComponent:(FUItem *)newComponent;
- (BOOL)replaceComponentWithName:(NSString *)name newComponent:(FUItem *)newComponent;
/// 批量添加和移除接口,如果 avatar 已有组件与新组件数组中存在名称一致的组件,已存在的组件将被替换。
/// @param newComponents 新的组件数组
/// @param removeComponentNames 老组件名字数组
- (void)addNewComponents:(NSArray<FUItem *> *)newComponents withRemoveComponentNames:(NSArray<NSString *> *)removeComponentNames ;
/// 批量添加和移除接口,如果 avatar 已有组件与新组件数组中存在名称一致的组件,已存在的组件将被替换。
/// @param newComponents 新的组件数组
/// @param removeComponentFileIds 老组件fileId数组
- (void)addNewComponents:(NSArray<FUItem *> *)newComponents withRemoveComponentFileIds:(NSArray<NSString *> *)removeComponentFileIds;
/// 通过组件名称查找组件
/// @param componentName 组件名称
- (FUItem *)componentForName:(NSString *)componentName;
/// 移除身体组件
/// @param component 身体组件
- (void)removeComponent:(FUItem *)component;
/// 通过身体组件名称移除组件
/// @param componentName 组件名称
- (FUItem*)removeComponentWithName:(NSString *)componentName;
- (void)updateComponentsVisiableWithARMode:(BOOL)ARMode;
/// 处理选中多个道具时的互斥协同逻辑
/// @param fileIds 道具fileId 集合
/// @param assetRootPath 资源跟路径
- (void)handleExcludeAndAssociateWithFileIds:(NSArray<NSString *> *)fileIds assetRootPath:(NSString *)assetRootPath;
/// 处理选中多个道具时的互斥协同逻辑
/// @param fileIds 道具fileId 集合
/// @param assetRootPath 资源跟路径
/// @param instanceId Avatar实例id
/// @param avatar avatar
+ (void)handleExcludeAndAssociateWithFileIds:(NSArray<NSString *> *)fileIds assetRootPath:(NSString *)assetRootPath instanceId:(int)instanceId avatar:(FUAvatar *)avatar;
@end
@interface FUAvatar (Animation)
@property (nonatomic, assign) BOOL enableAnimationLerp;
/// 添加动画,如果动画的 name 不为空,可以通过 name 查找或移除动画
/// @param animation 动画
- (void)addAnimation:(FUAnimation *)animation;
/// 通过动画名称查找动画
/// @param animationName 动画名称
- (FUAnimation *)animationForName:(NSString *)animationName;
/// 移除动画
/// @param animation 动画
- (void)removeAnimation:(FUAnimation *)animation;
/// 通过名称移除动画
/// @param animationName 动画名称
- (void)removeAnimationWithName:(NSString *)animationName;
/// 移除所有动画
- (void)removeAllAnimations;
/// 播放动画
/// @param animation 动画
/// @param playOnce YES 只播放一次NO 循环播放
/// @param transitionDuration 动画过度时间
- (void)playAnimation:(nullable FUAnimation *)animation playOnce:(BOOL)playOnce transitionDuration:(float)transitionDuration;
/// 通过名称播放动画
/// @param animationName 动画名称
/// @param playOnce YES 只播放一次NO 循环播放
/// @param transitionDuration 动画过度时间
- (void)playAnimationWithName:(NSString *)animationName playOnce:(BOOL)playOnce transitionDuration:(float)transitionDuration;
- (void)pauseCurrentAnimation;
- (void)resumeCurrentAnimation;
- (void)stopCurrentAnimation;
- (void)resetCurrentAnimation;
- (double)getProgressForAnimation:(FUAnimation *)animation;
- (double)getTransitionProgressForAnimation:(FUAnimation *)animation;
- (int)getFrameNumberForAnimation:(FUAnimation *)animation;
@end
@interface FUAvatar (DynamicBone)
@property (nonatomic, assign) BOOL modelmatToBone;
@property (nonatomic, assign) BOOL dynamicBoneTeleportMode;
@property (nonatomic, assign) BOOL dynamicBoneRootTranslateSpeedLimitMode;
@property (nonatomic, assign) BOOL dynamicBoneRootRotateSpeedLimitMode;
- (void)refreshDynamicBone;
- (void)resetDynamicBone;
@end
@interface FUAvatar (Blendshape)
@property (nonatomic, assign) BOOL enableExpressionBlend;
@property (nonatomic) FUBlendshapeWeight inputBlendshapeWeight;
@property (nonatomic) FUBlendshapeWeight systemBlendshapeWeight;
- (void)updateInputBlendshape:(FUBlendshape)blendshape;
@end
@interface FUAvatar (EyesFocusToCamera)
@property (nonatomic, assign) BOOL eyesFocusToCamera;
@property (nonatomic, assign) double eyesFocusHeightAdjust;
@property (nonatomic, assign) double eyesFocusDistanceAdjust;
@property (nonatomic, assign) double eyesFocusWeight;
@end
@interface FUAvatar (Color)
- (NSDictionary <NSString *, NSData *> *)allColorKeyValues;
- (NSDictionary<NSString *,NSNumber *> *)allColorIntensityKeyValues;
- (void)setColor:(FURGBColor)color forComponentName:(NSString *)componentName;
- (void)setColor:(FURGBColor)color forKey:(NSString *)colorKey;
- (void)setColorIntensity:(float)colorIntensity forKey:(NSString *)colorIntensityKey;
- (int)getSkinColorIndex;
@end
@interface FUAvatar (Facepup)
@property (nonatomic, copy, readonly) NSArray<NSNumber *> *allFacepupValues;
@property (nonatomic, copy, readonly) NSDictionary<NSString *, NSNumber *> *allFacepupKeyValues;
+ (void)setFacepupKeysWithJsonPath:(NSString *)josnPath;
- (void)enterFacepupMode;
- (void)quitFacepupMode;
- (void)setFacepupValue:(double)facepupValue forKey:(NSString *)facepupKey;
- (CGPoint)getFaceVertexScreenCoordinateForVertexIndex:(int)index;
- (float)getFacepupOriginalValueForKey:(NSString *)facepupKey;
@end
@interface FUAvatar (HumanAnimDriver)
-(void)setEnableHumanAnimDriver:(BOOL)enableHumanAnimDriver;
@end
@interface FUAvatar (Deformation)
@property (nonatomic, copy, readonly) NSDictionary<NSString *, NSNumber *> *allDeformationKeyValues;
- (void)setDeformationValue:(double)deformationValue forKey:(NSString *)deformationKey;
@end
@interface FUAvatar (BodyTrack)
@property (nonatomic, assign) FUAIHUMANFOLLOWMODE bodyFollowMode;
@property (nonatomic, assign) BOOL bodyTrackEnable;
@property (nonatomic, assign) int humanProcessorType; // 身体数据的来源类型
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,21 @@
//
// FUAvatarCheck.h
// FURenderKit
//
// Created by 刘保健 on 2021/12/30.
//
#import <Foundation/Foundation.h>
#import "FUAvatar.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUAvatarCheck : NSObject
+ (FUAvatarCheck *)initWithControllerConfigPath:(NSString *)controllerConfigPath litemListJson:(NSString *)litemListJson;
- (void)checkAvatarComponentFileIds:(NSArray <NSString *>*)fileIds avatar:(FUAvatar *)avatar assetRootPath:(NSString *)assetRootPath;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,28 @@
//
// FUAvatarColorKeys.h
// FURenderKit
//
// Created by liuyang on 2021/2/18.
//
//FUParamsKeysDefine(FUAvatarColor,
// // 颜色
// FUAvatarColorSkinColor = @"skin_color", // 肤色
// FUAvatarColorIrisColor = @"iris_color", // 瞳孔颜色
// FUAvatarColorGlassColor = @"glass_color", // 眼镜片颜色
// FUAvatarColorGlassFrameColor = @"glass_frame_color", // 眼镜框颜色
// FUAvatarColorHairColor = @"hair_color", // 头发颜色
// FUAvatarColorLipColor = @"makeup_lipgloss_color", // 头发颜色
// FUAvatarColorLipColor12 = @"makeup_eyelash_color", // 头发颜色
// )
//
//FUParamsKeysDefine(FUAvatarColorIntensity,
// // 颜色强度
// FUAvatarColorIntensityHair = @"hair_color_intensity" // 头发颜色强度
// )
//
//FUParamsKeysDefine(FUAvatarColorIndex,
// // 颜色索引
// FUAvatarColorIndexSkin = @"skin_color_index", // 当前肤色在肤色表的索引从0开始
// FUAvatarColorIndexLip = @"lip_color_index" // 当前唇色在唇色表的索引从0开始
// )

View File

@@ -0,0 +1,18 @@
//
// FUAvatarMakeup.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/11/25.
//
#import "FUItem.h"
#import "FUStruct.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUAvatarMakeup : FUItem
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,18 @@
//
// FUBackGround.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/11/16.
//
#import "FUItem.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUBackground : FUItem
@property (nonatomic, assign) BOOL supportFollowBodyMode; // 身体驱动时是否支持跟随身体模式
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,19 @@
//
// FUBeauty-Deprecated.h
// FURenderKit
//
// Created by 项林平 on 2022/3/29.
//
#import "FUBeauty.h"
@interface FUBeauty (Deprecated)
@property (nonatomic, assign) double cheekNarrowV2 DEPRECATED_MSG_ATTRIBUTE("use cheekNarrow instead");//窄脸 取值范围 0.0-1.0, 0.0为无效果1.0为最大效果默认值0.0
@property (nonatomic, assign) double cheekSmallV2 DEPRECATED_MSG_ATTRIBUTE("use cheekSmall instead");//小脸 取值范围 0.0-1.0, 0.0为无效果1.0为最大效果默认值0.0
@property (nonatomic, assign) double eyeEnlargingV2 DEPRECATED_MSG_ATTRIBUTE("use eyeEnlarging instead");//大眼 取值范围 0.0-1.0, 0.0为无效果1.0为最大效果默认值0.0
@property (nonatomic, assign) double intensityForeheadV2 DEPRECATED_MSG_ATTRIBUTE("use intensityForehead instead");//额头 取值范围 0.0-1.0, 0.5-0.0是变小0.5-1.0是变大默认值0.5
@property (nonatomic, assign) double intensityNoseV2 DEPRECATED_MSG_ATTRIBUTE("use intensityNose instead");//瘦鼻 取值范围 0.0-1.0, 0.0为无效果1.0为最大效果默认值0.0
@property (nonatomic, assign) double intensityMouthV2 DEPRECATED_MSG_ATTRIBUTE("use intensityMouth instead");//嘴型 取值范围 0.0-1.0, 0.5-0.0是变大0.5-1.0是变小默认值0.5
@end

View File

@@ -0,0 +1,217 @@
//
// FUBeauty.m
// FURenderKit
//
// Created by 项林平 on 2023/5/16.
//
#import "FUItem.h"
#import "FUFilterDefineKey.h"
#import "FUBeautyPropertyModeDefine.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUBeauty : FUItem
/// 磨皮是否使用 mask
@property (nonatomic, assign) BOOL blurUseMask;
/// 朦胧磨皮开关 0清晰磨皮 1朦胧磨皮
@property (nonatomic, assign) int heavyBlur;
/// 磨皮类型 0清晰磨皮 1朦胧磨皮 2精细磨皮 3均匀磨皮
/// @note 此属性优先级比 heavyBlur 低, 在使用时要将 heavyBlur 设为0
@property (nonatomic, assign) int blurType;
/// 将所有属性恢复到默认值
- (void)resetToDefault;
@end
@interface FUBeauty (Skin)
/// 皮肤分割皮肤美白YES开启NO关闭默认NO
/// @note 开启时美白效果仅支持皮肤区域,关闭时美白效果支持全局区域
/// @note 推荐非直播场景和 iPhoneXR 以上机型使用
@property (nonatomic, assign) BOOL enableSkinSegmentation;
/// 肤色检测开关 0为关, 1为开默认值0.0
@property (nonatomic, assign) int skinDetect;
/// 肤色检测之后非肤色区域的融合程度 取值范围0.0-1.0默认值0.0
@property (nonatomic, assign) int nonskinBlurScale;
/// 精细磨皮 取值范围0.0-6.0, 默认6.0
@property (nonatomic, assign) double blurLevel;
/// 祛斑痘,取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
/// @note 硬件支持原因,祛斑痘仅支持 iPhoneXR 及以上机型使用
@property (nonatomic, assign) double antiAcneSpot;
/// 美白 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double colorLevel;
/// 红润 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double redLevel;
/// 清晰 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double clarity;
/// 锐化 取值范围0.0-1.0, 默认0.0
@property (nonatomic, assign) double sharpen;
/// 五官立体 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double faceThreed;
/// 亮眼 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double eyeBright;
/// 美牙 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double toothWhiten;
/// 去黑眼圈 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double removePouchStrength;
/// 去法令纹 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double removeNasolabialFoldsStrength;
@end
@interface FUBeauty (Shape)
/// 变形取值 0女神变形 1网红变形 2自然变形 3默认变形 4精细变形
@property (nonatomic, assign) int faceShape;
/// 渐变所需要的帧数 0为关闭渐变, 大于0开启渐变
@property (nonatomic, assign) int changeFrames;
/// 变形程度 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值1.0
@property (nonatomic, assign) double faceShapeLevel;
/// v脸 0.0-1.0默认0.0
@property (nonatomic, assign) double cheekV;
/// 瘦脸 0.0-1.0默认0.0
@property (nonatomic, assign) double cheekThinning;
/// 长脸 0.0-1.0默认0.0
@property (nonatomic, assign) double cheekLong;
/// 圆脸 0.0-1.0默认0.0
@property (nonatomic, assign) double cheekCircle;
/// 窄脸 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double cheekNarrow;
/// 小脸 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double cheekSmall;
/// 短脸 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double cheekShort;
/// 瘦颧骨 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double intensityCheekbones;
/// 瘦下颌骨 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double intensityLowerJaw;
/// 大眼 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double eyeEnlarging;
/// 下巴 取值范围 0.0-1.0, 0.5-0是变小, 0.5-1是变大, 默认值0.5
@property (nonatomic, assign) double intensityChin;
/// 额头 取值范围 0.0-1.0, 0.5-0是变小, 0.5-1是变大, 默认值0.5
@property (nonatomic, assign) double intensityForehead;
/// 瘦鼻 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double intensityNose;
/// 嘴型 取值范围 0.0-1.0, 0.5-0.0是变大, 0.5-1.0是变小, 默认值0.5
@property (nonatomic, assign) double intensityMouth;
/// 嘴唇厚度 取值范围 0.0-1.0, 默认值0.5, 0.5-0是变薄, 0.5-1是变厚, 默认值0.5
@property (nonatomic, assign) double intensityLipThick;
/// 眼睛位置 取值范围 0.0-1.0, 默认值0.5, 0.5-0是变低, 0.5-1是变高, 默认值0.5
@property (nonatomic, assign) double intensityEyeHeight;
/// 开眼角 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double intensityCanthus;
/// 眼睑下至 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double intensityEyeLid;
/// 眼距 取值范围 0.0-1.0, 0.5-0.0是变大, 0.5-1.0是变小, 默认值0.5
@property (nonatomic, assign) double intensityEyeSpace;
/// 眼睛角度 取值范围 0.0-1.0, 0.5-0.0逆时针旋转, 0.5-1.0顺时针旋转, 默认值0.5
@property (nonatomic, assign) double intensityEyeRotate;
/// 长鼻 取值范围 0.0-1.0, 0.5-0.0是变长, 0.5-1.0是变短, 默认值0.5
@property (nonatomic, assign) double intensityLongNose;
/// 缩人中 取值范围 0.0-1.0, 0.5-0.0是变短, 0.5-1.0是变长, 默认值0.5
@property (nonatomic, assign) double intensityPhiltrum;
/// 微笑嘴角 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double intensitySmile;
/// 圆眼 取值范围 0.0-1.0, 0.0为无效果, 1.0为最大效果, 默认值0.0
@property (nonatomic, assign) double intensityEyeCircle;
/// 眉毛上下 取值范围 0.0-1.0, 0.5-0是向上, 0.5-1是向下, 默认值0.5
@property (nonatomic, assign) double intensityBrowHeight;
/// 眉间距 取值范围 0.0-1.0, 默认值0.5, 0.5-0是变小, 0.5-1是变大, 默认值0.5
@property (nonatomic, assign) double intensityBrowSpace;
/// 眉毛粗细 取值范围 0.0-1.0, 默认值0.5, 0.5-0是变细, 0.5-1是变粗, 默认值0.5
@property (nonatomic, assign) double intensityBrowThick;
@end
@interface FUBeauty (Filter)
/// 滤镜名称 字符串类型,默认值为 "origin" , 即为使用原图效果
/// @see FUFilter
@property (nonatomic, strong) FUFilter filterName;
/// 滤镜程度值 取值范围 0.0-1.00.0为无效果, 1.0为最大效果, 默认值1.0
@property (nonatomic, assign) double filterLevel;
/// 获取指定滤镜的程度值
/// - Parameter filterForKey: 滤镜名称
- (double)filterValueForKey:(NSString *)filterForKey;
/// 所有支持的滤镜名称字符串数组
- (NSArray *)allFilterKeys;
@end
@interface FUBeauty (Mode)
/**
* 设置部分美颜属性的mode, 不同mode会有主观上会有不同效果
* 必须在设置美颜各个属性值之前调用该接口
* key和mode说明
| key | 属性 | 支持的mode |
| ------------- | -------- | ------------------------------------------------------------ |
| color_level | 美白 | FUBeautyPropertyMode1, FUBeautyPropertyMode2(v8.2.0) |
| remove_pouch_strength | 去黑眼圈 | FUBeautyPropertyMode1, FUBeautyPropertyMode2(v8.2.0, 高性能设备推荐) |
| remove_nasolabial_folds_strength | 去法令纹 | FUBeautyPropertyMode1, FUBeautyPropertyMode2(v8.2.0, 高性能设备推荐) |
| cheek_thinning | 瘦脸 | FUBeautyPropertyMode1, FUBeautyPropertyMode2(v8.3.0) |
| cheek_narrow | 窄脸 | FUBeautyPropertyMode1, FUBeautyPropertyMode2(v8.0.0) |
| cheek_small | 小脸 | FUBeautyPropertyMode1, FUBeautyPropertyMode2(v8.0.0) |
| eye_enlarging | 大眼 | FUBeautyPropertyMode1, FUBeautyPropertyMode2(v8.0.0), FUBeautyPropertyMode3(v8.2.0, 高性能设备推荐) |
| intensity_chin | 下巴 | FUBeautyPropertyMode1, FUBeautyPropertyMode2(v8.4.0) |
| intensity_forehead | 额头 | FUBeautyPropertyMode1, FUBeautyPropertyMode2(v8.0.0) |
| intensity_nose | 瘦鼻 | FUBeautyPropertyMode1, FUBeautyPropertyMode2(v8.0.0) |
| intensity_mouth | 嘴型 | FUBeautyPropertyMode1, FUBeautyPropertyMode2(v8.0.0), FUBeautyPropertyMode3(v8.2.0, 高性能设备推荐) |
**/
- (void)addPropertyMode:(FUBeautyPropertyMode)mode forKey:(FUModeKey)key;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,34 @@
//
// FUBeautyPropertyModeDefine.h
// FURenderKit
//
// Created by 项林平 on 2022/3/29.
//
#ifndef FUBeautyPropertyModeDefine_h
#define FUBeautyPropertyModeDefine_h
#import "FUKeysDefine.h"
typedef NS_ENUM(NSUInteger, FUBeautyPropertyMode) {
FUBeautyPropertyMode1 = 1,
FUBeautyPropertyMode2 = 2,
FUBeautyPropertyMode3 = 3
};
FUParamsKeysDefine(FUModeKey,
FUModeKeyColorLevel = @"color_level",
FUModeKeyRemovePouchStrength = @"remove_pouch_strength",
FUModeKeyRemoveNasolabialFoldsStrength = @"remove_nasolabial_folds_strength",
FUModeKeyCheekThinning = @"cheek_thinning",
FUModeKeyCheekNarrow = @"cheek_narrow",
FUModeKeyCheekSmall = @"cheek_small",
FUModeKeyEyeEnlarging = @"eye_enlarging",
FUModeKeyIntensityChin = @"intensity_chin",
FUModeKeyIntensityForehead = @"intensity_forehead",
FUModeKeyIntensityNose = @"intensity_nose",
FUModeKeyIntensityMouth = @"intensity_mouth"
)
#endif /* FUBeautyPropertyModeDefine_h */

View File

@@ -0,0 +1,30 @@
//
// FUBodyBeauty.h
// FURenderKit
//
// Created by Chen on 2021/1/15.
//
#import "FUItem.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUBodyBeauty : FUItem
@property (nonatomic, assign) double bodySlimStrength; //瘦身
@property (nonatomic, assign) double legSlimStrength; //长腿
@property (nonatomic, assign) double waistSlimStrength; //瘦腰
@property (nonatomic, assign) double shoulderSlimStrength; //美肩
@property (nonatomic, assign) double hipSlimStrength; //美臀
@property (nonatomic, assign) double headSlim; //小头
@property (nonatomic, assign) double legSlim; //瘦腿
@property (nonatomic, assign) int debug; //是否开启debug点位
@property (nonatomic, assign) int clearSlim; //重置:清空所有的美体效果,恢复为默认值
/**
* 取值范围 0 ~ 3
*/
@property (nonatomic, assign) int orientation;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,37 @@
//
// FUBodyBeautyDefineKeys.h
// FUAvatarSDK
//
// Created by Chen on 2021/2/1.
//
#ifndef FUBodyBeautyDefineKeys_h
#define FUBodyBeautyDefineKeys_h
#import "FUKeysDefine.h"
FUParamsKeysDefine(FUBodyBeautyKey,
//瘦身
FUBodyBeautyKeyBodySlimStrength = @"BodySlimStrength",
//长腿
FUBodyBeautyKeyLegSlimStrength = @"LegSlimStrength",
//瘦腰
FUBodyBeautyKeyWaistSlimStrength = @"WaistSlimStrength",
//长腿
FUBodyBeautyKeyShoulderSlimStrength = @"ShoulderSlimStrength",
//美臀
FUBodyBeautyKeyHipSlimStrength = @"HipSlimStrength",
//小头
FUBodyBeautyKeyLegHeadSlim = @"HeadSlim",
//瘦腿
FUBodyBeautyKeyLegSlim = @"LegSlim",
)
#endif /* FUBodyBeautyDefineKeys_h */

View File

@@ -0,0 +1,52 @@
// Software License Agreement (BSD License)
//
// Copyright (c) 2010-2020, Deusty, LLC
// All rights reserved.
//
// Redistribution and use of this software in source and binary forms,
// with or without modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Neither the name of Deusty nor the names of its contributors may be used
// to endorse or promote products derived from this software without specific
// prior written permission of Deusty, LLC.
#if TARGET_OS_OSX
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
NS_ASSUME_NONNULL_BEGIN
/**
* This class represents an NSColor replacement for CLI projects that don't link with AppKit
**/
@interface FUCLIColor : NSObject
/**
* Convenience method for creating a `FUCLIColor` instance from RGBA params
*
* @param red red channel, between 0 and 1
* @param green green channel, between 0 and 1
* @param blue blue channel, between 0 and 1
* @param alpha alpha channel, between 0 and 1
*/
+ (instancetype)colorWithCalibratedRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
/**
* Get the RGBA components from a `FUCLIColor`
*
* @param red red channel, between 0 and 1
* @param green green channel, between 0 and 1
* @param blue blue channel, between 0 and 1
* @param alpha alpha channel, between 0 and 1
*/
- (void)getRed:(nullable CGFloat *)red green:(nullable CGFloat *)green blue:(nullable CGFloat *)blue alpha:(nullable CGFloat *)alpha NS_SWIFT_NAME(get(red:green:blue:alpha:));
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,16 @@
//
// FUCameraAnimation.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/11/24.
//
#import "FUAnimation.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUCameraAnimation : FUAnimation
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,136 @@
//
// FUCamera.h
// FUAPIDemo
//
// Created by liuyang on 2016/12/26.
// Copyright © 2016年 liuyang. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
@class FUCaptureCamera;
@protocol FUCaptureCameraAudioDelegate <NSObject>
//音频
- (void)didOutputAudioSampleBuffer:(CMSampleBufferRef)sampleBuffer;
@end
@protocol FUCaptureCameraDelegate <NSObject>
-(void)didOutputVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer captureDevicePosition:(AVCaptureDevicePosition)position;
@end
@protocol FUCaptureCameraDataSource <NSObject>
- (CGPoint)fuCaptureFaceCenterInImage:(FUCaptureCamera *)camera ;
@end
typedef NS_ENUM( NSInteger, FUCaptureCameraFocusMode) {
/* 先找人脸对焦模式 */
FUCaptureCameraFocusModeAutoFace,
/* 固定点对焦模式 */
FUCaptureCameraFocusModeChangeless
};
@interface FUCaptureCamera : NSObject
@property (nonatomic, weak) id<FUCaptureCameraAudioDelegate> audioDelegate;
@property (nonatomic, weak) id<FUCaptureCameraDelegate> delegate;
@property (nonatomic, weak) id<FUCaptureCameraDataSource> dataSource;
@property (nonatomic, assign, readonly) BOOL isFrontCamera;
@property (nonatomic, assign, readonly) BOOL isMirrored;
@property (nonatomic, assign, readonly) AVCaptureVideoOrientation videoOrientation;
@property (assign, nonatomic) int captureFormat; //采集格式
@property (copy , nonatomic) dispatch_queue_t videoCaptureQueue;//视频采集的队列
@property (copy , nonatomic) dispatch_queue_t audioCaptureQueue;//音频采集队列
@property (copy , nonatomic) dispatch_queue_t tmpCaptureQueue;//视频采集的队列
@property (assign, nonatomic) AVCaptureSessionPreset sessionPreset;
@property (assign, nonatomic) BOOL needsAudioTrack;//是否需要音频默认为NO
/// 是否正在采集
@property (assign, nonatomic) BOOL capturing;
- (instancetype)initWithCameraPosition:(AVCaptureDevicePosition)cameraPosition captureFormat:(int)captureFormat;
- (void)startCapture;
- (void)stopCapture;
- (void)changeCameraInputDeviceisFront:(BOOL)isFront;
- (void)takePhotoAndSave;
- (void)startRecord;
- (void)stopRecordWithCompletionHandler:(void (^)(NSString *videoPath))handler;
/* 当前分辨率是否支持前后置 */
-(BOOL)supportsAVCaptureSessionPreset:(BOOL)isFront;
/**
设置采集方向
@param orientation 方向
*/
- (void)setCaptureVideoOrientation:(AVCaptureVideoOrientation)orientation;
/**
查询当前相机最大曝光补偿信息
@param current 当前
@param max 最大
@param min 最小
*/
- (void)getCurrentExposureValue:(float *)current max:(float *)max min:(float *)min;
/**
恢复以屏幕中心自动连续对焦和曝光
*/
- (void)resetFocusAndExposureModes;
/// 修改采集分辨率
/// @param sessionPreset 分辨率
- (BOOL)changeSessionPreset:(AVCaptureSessionPreset)sessionPreset;
/**
修改采集视频镜像关系
@param videoMirrored videoMirrore
*/
- (void)changeVideoMirrored:(BOOL)videoMirrored;
/**
修改帧率
在iOS上使用AvCaptureDevice的setActiveFormat:和AvCaptureSession的setSessionPreset:是互斥的。
如果 frameRate <= 30 setActiveFormat 则该设备所连接的会话将其预设更改为avCaptureSessionPresetinputPriority
*/
- (void)changeVideoFrameRate:(int)frameRate;
- (void)setExposureValue:(float)value;
/// 设置曝光模式和兴趣点
/// @param focusMode 对焦模式
/// @param exposureMode 曝光模式
/// @param point 兴趣点
/// @param monitorSubjectAreaChange 是否监听主题变化
- (void)focusWithMode:(AVCaptureFocusMode)focusMode exposeWithMode:(AVCaptureExposureMode)exposureMode atDevicePoint:(CGPoint)point monitorSubjectAreaChange:(BOOL)monitorSubjectAreaChange;
/// 修改对焦模式
/// @param mode 对焦模式
- (void)cameraChangeMode:(FUCaptureCameraFocusMode)mode;
// 缩放
// 可用于模拟对焦
- (void)setZoomValue:(CGFloat)zoomValue;
@end

View File

@@ -0,0 +1,33 @@
//
// FUAnimationFIlterItem.h
// FURenderKit
//
// Created by Chen on 2021/1/13.
//
#import "FUItem.h"
NS_ASSUME_NONNULL_BEGIN
/// 动漫滤镜风格
typedef NS_ENUM(NSInteger, FUComicFilterStyle) {
FUComicFilterStyleNone = -1, // 无
FUComicFilterStyleCartoon = 0, // 动漫
FUComicFilterStyleSketch = 1, // 素描
FUComicFilterStylePortrait = 2, // 人像
FUComicFilterStylePainting = 3, // 油画
FUComicFilterStyleSandPainting = 4, // 沙画
FUComicFilterStylePenDrawing = 5, // 钢笔画
FUComicFilterStylePencilDrawing = 6,// 铅笔画
FUComicFilterStyleGraffiti = 7 // 涂鸦
};
@interface FUComicFilter : FUItem
/// 动漫滤镜风格
/// @see FUComicFilterStyle
@property (nonatomic, assign) FUComicFilterStyle style;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,20 @@
//
// FUConfig.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/11/23.
//
#import <Foundation/Foundation.h>
#import "FUParam.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUConfig : NSObject
- (int)setValue:(id)value forName:(NSString *)name paramType:(FUParamType)paramType;
- (id)getValueForName:(NSString *)name paramType:(FUParamType)paramType;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,22 @@
//
// FUCustomBackground.h
// FURenderKit
//
// Created by liuyang on 2022/1/7.
//
#import "FUBackground.h"
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface FUCustomBackground : FUBackground
@property (nonatomic, strong) UIImage *image;
- (instancetype)initWithPath:(NSString *)path name:(NSString *)name image:(UIImage *)image;
+ (instancetype)backgroundWithPath:(NSString *)path name:(NSString *)name image:(UIImage *)image;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,123 @@
//
// FUDeformationKeys.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/12/23.
//
#import "FUKeysDefine.h"
FUParamsKeysDefine(FUDeformation,
//身材
FUDeformationTall = @"tall", //高
FUDeformationShort = @"short", //矮
FUDeformationFat = @"fat", //胖
FUDeformationThin = @"thin", //瘦
//脸型
FUDeformationEyeNarrow = @"eye_narrow", //眼睛窄
FUDeformationEyeWide = @"eye_wide", // 眼睛宽
FUDeformationEyeDown = @"eye_down", //眼睛下
FUDeformationEyeUp = @"eye_up", // 眼睛上
FUDeformationEyeInner = @"eye_inner", // 眼睛内
FUDeformationEyeBackward = @"eye_backward", //眼睛小
FUDeformationEyeForward = @"eye_forward", //眼睛大
FUDeformationUpperlidoutNarrow = @"upperLidOut_narrow", //外上眼皮右
FUDeformationUpperlidoutWide = @"upperLidOut_wide", // 外上眼皮左
FUDeformationUpperlidoutDown = @"upperLidOut_down", //外上眼皮左下
FUDeformationUpperlidoutUp = @"upperLidOut_up", //外上眼皮左上
FUDeformationUpperlidmidNarrow = @"upperLidMid_narrow", //中上眼皮右
FUDeformationUpperlidmidWide = @"upperLidMid_wide", // 中上眼皮左
FUDeformationUpperlidmidDown = @"upperLidMid_down", // 中上眼皮下
FUDeformationUpperlidmidUp = @"upperLidMid_up", // 中上眼皮上
FUDeformationUpperlidinNarrow = @"upperLidIn_narrow", //内上眼皮右
FUDeformationUpperlidinWide = @"upperLidIn_wide", // 内上眼皮左
FUDeformationUpperlidinDown = @"upperLidIn_down", //内上眼皮下
FUDeformationUpperlidinUp = @"upperLidIn_up", // 内上眼皮上下
FUDeformationLidinnerNarrow = @"lidInner_narrow", //内眼角内
FUDeformationLidinnerWide = @"lidInner_wide", //内眼角外
FUDeformationLidinnerDown = @"lidInner_down", //内眼角下
FUDeformationLidinnerUp = @"lidInner_up", // 内眼角上
FUDeformationLowerlidinNarrow = @"lowerLidIn_narrow", //内下眼皮右
FUDeformationLowerlidinWide = @"lowerLidIn_wide", //内下眼皮左
FUDeformationLowerlidinDown = @"lowerLidIn_down", // 内下眼皮下
FUDeformationLowerlidinUp = @"lowerLidIn_up", //内下眼皮上
FUDeformationLowerlidmidNarrow = @"lowerLidMid_narrow", //中下眼皮右
FUDeformationLowerlidmidWide = @"lowerLidMid_wide", //中下眼皮左
FUDeformationLowerlidmidDown = @"lowerLidMid_down", //中下眼皮下
FUDeformationLowerlidmidUp = @"lowerLidMid_up", // 中下眼皮上
FUDeformationLowerlidoutNarrow = @"lowerLidOut_narrow", // 外下眼皮右
FUDeformationLowerlidoutWide = @"lowerLidOut_wide", //外下眼皮左
FUDeformationLowerlidoutDown = @"lowerLidOut_down", // 外下眼皮下
FUDeformationLowerlidoutUp = @"lowerLidOut_up", //外下眼皮上
FUDeformationLidouterNarrow = @"lidOuter_narrow", //外眼角内
FUDeformationLidouterWide = @"lidOuter_wide", // 外眼角外
FUDeformationLidouterDown = @"lidOuter_down", //外眼角下
FUDeformationLidouterUp = @"lidOuter_up", //外眼角上
FUDeformationNoseDown = @"nose_down", //鼻子下
FUDeformationNoseUp = @"nose_up", //鼻子上
FUDeformationNoseBackward = @"nose_backward", //鼻子后
FUDeformationNoseForward = @"nose_forward", //鼻子前
FUDeformationNosetipDown = @"noseTip_down", // 鼻尖下
FUDeformationNosetipUp = @"noseTip_up", //鼻尖上
FUDeformationNosetipBackward = @"noseTip_backward", // 鼻尖后
FUDeformationNosetipForward = @"noseTip_forward", // 鼻尖前
FUDeformationUpperheadNarrow = @"upperHead_narrow", // 脸窄
FUDeformationUpperheadWide = @"upperHead_wide", // 脸宽
FUDeformationUpperheadDown = @"upperHead_down", // 上脸短
FUDeformationUpperheadUp = @"upperHead_up", //上脸长
FUDeformationUpperheadBackward = @"upperHead_backward", //上脸后
FUDeformationUpperheadForward = @"upperHead_forward", //上脸前
FUDeformationLowerheadDown = @"lowerHead_down", //下脸长
FUDeformationLowerheadUp = @"lowerHead_up", //下脸短
FUDeformationLowerheadBackward = @"lowerHead_backward", // 下脸后
FUDeformationLowerheadForward = @"lowerHead_forward", //下脸前
FUDeformationUpperjawNarrow = @"upperJaw_narrow", //脸颊瘦
FUDeformationUpperjawWide = @"upperJaw_wide", //脸颊胖
FUDeformationMidjawNarrow = @"midJaw_narrow", //下颚瘦
FUDeformationMidjawWide = @"midJaw_wide", //下颚胖
FUDeformationMidjawDown = @"midJaw_down", //下颚下
FUDeformationMidjawUp = @"midJaw_up", //下颚上
FUDeformationLowerjawNarrow = @"lowerJaw_narrow", //腮帮瘦
FUDeformationLowerjawWide = @"lowerJaw_wide", //腮帮胖
FUDeformationLowerjawDown = @"lowerJaw_down", //腮帮下
FUDeformationLowerjawUp = @"lowerJaw_up", //腮帮上
FUDeformationJawlineNarrow = @"jawLine_narrow", // 下颌角窄
FUDeformationJawlineWide = @"jawLine_wide", // 下颌角宽
FUDeformationJawlineDown = @"jawLine_down", // 下颌角下
FUDeformationJawlineUp = @"jawLine_up", // 下颌角上
FUDeformationJawtipNarrow = @"jawTip_narrow", // 下巴瘦
FUDeformationJawtipWide = @"jawTip_wide", //下巴胖
FUDeformationJawtipDown = @"jawTip_down", //下巴下
FUDeformationJawtipUp = @"jawTip_up", // 下巴上
FUDeformationJawtipBackward = @"jawTip_backward", //下巴后
FUDeformationJawtipForward = @"jawTip_forward", //下巴前
FUDeformationJawtipPeakNarrow = @"jawTip_peak_narrow", //下巴尖窄
FUDeformationJawtipPeakWide = @"jawTip_peak_wide", // 下巴尖宽
FUDeformationJawtipPeakDown = @"jawTip_peak_down", // 下巴尖长
FUDeformationJawtipPeakUp = @"jawTip_peak_up", // 下巴尖短
FUDeformationJawtipPeakBackward = @"jawTip_peak_backward", // 下巴尖后
FUDeformationJawtipPeakForward = @"jawTip_peak_forward", //下巴尖前
FUDeformationLowerchinDown = @"lowerChin_down", // 下巴内侧下
FUDeformationLowerchinUp = @"lowerChin_up", //下巴内侧上
FUDeformationMouthNarrow = @"mouth_narrow", // 嘴巴小
FUDeformationMouthWide = @"mouth_wide", //嘴巴大
FUDeformationMouthDown = @"mouth_down", //嘴巴下
FUDeformationMouthUp = @"mouth_up", // 嘴巴上
FUDeformationMouthBackward = @"mouth_backward", // 嘴巴后
FUDeformationMouthForward = @"mouth_forward", // 嘴巴前
FUDeformationGlobalbrowDown = @"globalBrow_down", // 眉毛下
FUDeformationGlobalbrowUp = @"globalBrow_up", // 眉毛上
FUDeformationInnerbrowDown = @"InnerBrow_down", //内眉毛下
FUDeformationInnerbrowUp = @"InnerBrow_up", //内眉毛上
FUDeformationMiddlebrowDown = @"middleBrow_down", // 中眉毛下
FUDeformationMiddlebrowUp = @"middleBrow_up", // 中眉毛上
FUDeformationOuterbrowDown = @"outerBrow_down", // 外眉毛下
FUDeformationOuterbrowUp = @"outerBrow_up", //外眉毛上
FUDeformationEarNarrow = @"ear_narrow", //耳朵小
FUDeformationEarWide = @"ear_wide", //耳朵大
FUDeformationEarDown = @"ear_down", //耳朵下
FUDeformationEarUp = @"ear_up", //耳朵上
FUDeformationUpperearDown = @"upperEar_down", // 上耳朵下
FUDeformationUpperearUp = @"upperEar_up" // 上耳朵上
)

View File

@@ -0,0 +1,19 @@
//
// FUFaceRectInfo.h
// FURenderKit
//
// Created by Chen on 2021/1/26.
//
#import <Foundation/Foundation.h>
#import <CoreGraphics/CGGeometry.h>
NS_ASSUME_NONNULL_BEGIN
@interface FUFaceRectInfo : NSObject
+ (instancetype)faceWithId:(int)faceId rect:(CGRect)rect;
@property (nonatomic, assign) int faceId;
@property (nonatomic, assign) CGRect rect;//人脸脸所在图片上的位置
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,112 @@
//
// FUFacepupKeys.h
// FURenderKit
//
// Created by ly-Mac on 2020/12/23.
//
#import "FUKeysDefine.h"
//FUParamsKeysDefine(FUFacepup,
// // 脸型
// FUFacepupHeadBoneWide = @"HeadBone_wide", // 头型变宽
// FUFacepupHeadNarrow = @"Head_narrow", // 头型变窄
// FUFacepupHeadShrink = @"head_shrink", // 头部缩短
// FUFacepupHeadStretch = @"head_stretch", // 头部拉长
// FUFacepupHeadFat = @"head_fat", // 胖
// FUFacepupHeadThin = @"head_thin", // 瘦
// FUFacepupCheekWide = @"cheek_wide", // 颊变宽
// FUFacepupCheekBoneNarrow = @"cheekbone_narrow", // 颊变短
// FUFacepupJawBoneWide = @"jawbone_Wide", // 下颌角向下
// FUFacepupJawBoneNarrow = @"jawbone_Narrow", // 下颌角向下
// FUFacepupJawMWide = @"jaw_m_wide", // 下颌变宽
// FUFacepupJawMNarrow = @"jaw_M_narrow", // 下颌变窄
// FUFacepupJawWide = @"jaw_wide", // 下巴变宽
// FUFacepupJawNarrow = @"jaw_narrow", // 下巴变窄
// FUFacepupJawUp = @"jaw_up", // 下巴变短
// FUFacepupJawLower = @"jaw_lower", // 下巴变长
// FUFacepupJawtipForward = @"jawTip_forward", // 下巴向前
// FUFacepupJawtipBackward = @"jawTip_backward", // 下巴向后
// FUFacepupJawboneMUp = @"jawBone_m_up", // 下颌中间变窄
// FUFacepupJawboneMDown = @"jawBone_m_down", // 下颌中间变宽
//
// // 眼睛
// FUFacepupEyeWide = @"Eye_wide", // 眼睛放大
// FUFacepupEyeShrink = @"Eye_shrink", // 眼睛缩小
// FUFacepupEyeUp = @"Eye_up", // 眼睛向上
// FUFacepupEyeDown = @"Eye_down", // 眼睛向下
// FUFacepupEyeIn = @"Eye_in", // 眼睛向里
// FUFacepupEyeOut = @"Eye_out", // 眼睛向外
// FUFacepupEyeCloseL = @"Eye_close_L", // 左眼闭
// FUFacepupEyeCloseR = @"Eye_close_R", // 右眼闭
// FUFacepupEyeOpenL = @"Eye_open_L", // 左眼睁
// FUFacepupEyeOpenR = @"Eye_open_R", // 右眼睁
// FUFacepupEyeUpperUpL = @"Eye_upper_up_L", // 左上眼皮向上
// FUFacepupEyeUpperUpR = @"Eye_upper_up_R", // 右上眼皮向上
// FUFacepupEyeUpperDownL = @"Eye_upper_down_L", // 左上眼皮向下
// FUFacepupEyeUpperDownR = @"Eye_upper_down_R", // 右上眼皮向下
// FUFacepupEyeUpperbendInL = @"Eye_upperBend_in_L", // 左上眼皮向里
// FUFacepupEyeUpperbendInR = @"Eye_upperBend_in_R", // 右上眼皮向里
// FUFacepupEyeUpperbendOutL = @"Eye_upperBend_out_L", // 左上眼皮向外
// FUFacepupEyeUpperbendOutR = @"Eye_upperBend_out_R", // 右上眼皮向外
// FUFacepupEyeDownerUpL = @"Eye_downer_up_L", // 左下眼皮向上
// FUFacepupEyeDownerUpR = @"Eye_downer_up_R", // 右下眼皮向上
// FUFacepupEyeDownerDnL = @"Eye_downer_dn_L", // 左下眼皮向下
// FUFacepupEyeDownerDnR = @"Eye_downer_dn_R", // 右下眼皮向下
// FUFacepupEyeDownerbendInL = @"Eye_downerBend_in_L", // 左下眼皮向里
// FUFacepupEyeDownerbendInR = @"Eye_downerBend_in_R", // 右下眼皮向里
// FUFacepupEyeDownerbendOutL = @"Eye_downerBend_out_L", // 左下眼皮向外
// FUFacepupEyeDownerbendOutR = @"Eye_downerBend_out_R", // 右下眼皮向外
// FUFacepupEyeOutterIn = @"Eye_outter_in", // 外眼角向里
// FUFacepupEyeOutterOut = @"Eye_outter_out", // 外眼角向外
// FUFacepupEyeOutterUp = @"Eye_outter_up", // 外眼角向上
// FUFacepupEyeOutterDown = @"Eye_outter_down", // 外眼角向下
// FUFacepupEyeInnerIn = @"Eye_inner_in", // 内眼角向里
// FUFacepupEyeInnerOut = @"Eye_inner_out", // 内眼角向外
// FUFacepupEyeInnerUp = @"Eye_inner_up", // 内眼角向上
// FUFacepupEyeInnerDown = @"Eye_inner_down", // 内眼角向下
// FUFacepupEyeForward = @"Eye_forward", // 眼睛向前
//
// // 嘴巴
// FUFacepupUpperlipThick = @"upperLip_Thick", // 上唇变厚
// FUFacepupUpperlipsideThick = @"upperLipSide_Thick", // 上唇两侧变厚
// FUFacepupLowerlipThick = @"lowerLip_Thick", // 下唇变厚
// FUFacepupLowerlipsideThin = @"lowerLipSide_Thin", // 下唇两侧变薄
// FUFacepupLowerlipsideThick = @"lowerLipSide_Thick", // 下唇两侧变厚
// FUFacepupUpperlipThin = @"upperLip_Thin", // 上唇变薄
// FUFacepupLowerlipThin = @"lowerLip_Thin", // 下唇变薄
// FUFacepupMouthMagnify = @"mouth_magnify", // 嘴巴放大
// FUFacepupMouthShrink = @"mouth_shrink", // 嘴巴缩小
// FUFacepupLipcornerOut = @"lipCorner_Out", // 嘴角向外
// FUFacepupLipcornerIn = @"lipCorner_In", // 嘴角向里
// FUFacepupLipcornerUp = @"lipCorner_up", // 嘴角向上
// FUFacepupLipcornerDown = @"lipCorner_down", // 嘴角向下
// FUFacepupMouthMDown = @"mouth_m_down", // 唇尖向下
// FUFacepupMouthMUp = @"mouth_m_up", // 唇尖向上
// FUFacepupMouthUp = @"mouth_Up", // 嘴向上
// FUFacepupMouthDown = @"mouth_Down", // 嘴向下
// FUFacepupMouthSideUp = @"mouth_side_up", // 唇线两侧向上
// FUFacepupMouthSideDown = @"mouth_side_down", // 唇线两侧向下
// FUFacepupMouthForward = @"mouth_forward", // 嘴向前
// FUFacepupMouthBackward = @"mouth_backward", // 嘴向后
// FUFacepupUpperlipsideThin = @"upperLipSide_thin", // 上唇两侧变薄
//
// // 鼻子
// FUFacepupNostrilOut = @"nostril_Out", // 鼻翼变宽
// FUFacepupNostrilIn = @"nostril_In", // 鼻翼变窄
// FUFacepupNosetipUp = @"noseTip_Up", // 鼻尖向上
// FUFacepupNosetipDown = @"noseTip_Down", // 鼻尖向下
// FUFacepupNoseUp = @"nose_Up", // 鼻子向上
// FUFacepupNoseTall = @"nose_tall", // 鼻子变高
// FUFacepupNoseLow = @"nose_low", // 鼻子变矮
// FUFacepupNoseDown = @"nose_Down", // 鼻子向下
// FUFacepupNosetipForward = @"noseTip_forward", // 鼻尖向前
// FUFacepupNosetipBackward = @"noseTip_backward", // 鼻尖向后
// FUFacepupNosetipMagnify = @"noseTip_magnify", // 鼻尖放大
// FUFacepupNosetipShrink = @"noseTip_shrink", // 鼻尖缩小
// FUFacepupNostrilUp = @"nostril_up", // 鼻翼向上
// FUFacepupNostrilDown = @"nostril_down", // 鼻翼向下
// FUFacepupNoseboneTall = @"noseBone_tall", // 鼻梁变高
// FUFacepupNoseboneLow = @"noseBone_low", // 鼻梁变低
// FUFacepupNoseWide = @"nose_wide", // 鼻子变宽
// FUFacepupNoseShrink = @"nose_shrink" // 鼻子变窄
// )

View File

@@ -0,0 +1,21 @@
//
// FUFacialFeatures.h
// FURenderKit
//
// Created by Chen on 2021/3/19.
//
#import "FUSticker.h"
#import "CNamaSDK.h"
NS_ASSUME_NONNULL_BEGIN
/**
* 面部特征
*/
@interface FUFacialFeatures : FUSticker
@property (nonatomic, assign) FUAITYPE aiType;
@property (nonatomic, assign) FUAITYPE landmarksType;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,104 @@
//
// FUFilterDefineKey.h
// FUAvatarSDK
//
// Created by Chen on 2021/1/5.
//
#ifndef FUFilterDefineKey_h
#define FUFilterDefineKey_h
#import "FUKeysDefine.h"
FUParamsKeysDefine(FUFilter,
FUFilterOrigin = @"origin",
//自然
FUFilterZiRan1 = @"ziran1",
FUFilterZiRan2 = @"ziran2",
FUFilterZiRan3 = @"ziran3",
FUFilterZiRan4 = @"ziran4",
FUFilterZiRan5 = @"ziran5",
FUFilterZiRan6 = @"ziran6",
FUFilterZiRan7 = @"ziran7",
FUFilterZiRan8 = @"ziran8",
//质感灰
FUFilterZhiGanHui1 = @"zhiganhui1",
FUFilterZhiGanHui2 = @"zhiganhui2",
FUFilterZhiGanHui3 = @"zhiganhui3",
FUFilterZhiGanHui4 = @"zhiganhui4",
FUFilterZhiGanHui5 = @"zhiganhui5",
FUFilterZhiGanHui6 = @"zhiganhui6",
FUFilterZhiGanHui7 = @"zhiganhui7",
FUFilterZhiGanHui8 = @"zhiganhui8",
//蜜桃
FUFilterMiTao1 = @"mitao1",
FUFilterMiTao2 = @"mitao2",
FUFilterMiTao3 = @"mitao3",
FUFilterMiTao4 = @"mitao4",
FUFilterMiTao5 = @"mitao5",
FUFilterMiTao6 = @"mitao6",
FUFilterMiTao7 = @"mitao7",
FUFilterMiTao8 = @"mitao8",
//白亮
FUFilterBaiLiang1 = @"bailiang1",
FUFilterBaiLiang2 = @"bailiang2",
FUFilterBaiLiang3 = @"bailiang3",
FUFilterBaiLiang4 = @"bailiang4",
FUFilterBaiLiang5 = @"bailiang5",
FUFilterBaiLiang6 = @"bailiang6",
FUFilterBaiLiang7 = @"bailiang7",
//粉嫩
FUFilterFenNen1 = @"fennen1",
FUFilterFenNen2 = @"fennen2",
FUFilterFenNen3 = @"fennen3",
FUFilterFenNen4 = @"fennen4",
FUFilterFenNen5 = @"fennen5",
FUFilterFenNen6 = @"fennen6",
FUFilterFenNen7 = @"fennen7",
FUFilterFenNen8 = @"fennen8",
//冷色调
FUFilterLengSeDiao1 = @"lengsediao1",
FUFilterLengSeDiao2 = @"lengsediao2",
FUFilterLengSeDiao3 = @"lengsediao3",
FUFilterLengSeDiao4 = @"lengsediao4",
FUFilterLengSeDiao5 = @"lengsediao5",
FUFilterLengSeDiao6 = @"lengsediao6",
FUFilterLengSeDiao7 = @"lengsediao7",
FUFilterLengSeDiao8 = @"lengsediao8",
FUFilterLengSeDiao11 = @"lengsediao11",
//暖色调
FUFilterNuanSeDiao1 = @"nuansediao1",
FUFilterNuanSeDiao2 = @"nuansediao2",
//个性
FUFilterGeXing1 = @"gexing1",
FUFilterGeXing2 = @"gexing2",
FUFilterGeXing3 = @"gexing3",
FUFilterGeXing4 = @"gexing4",
FUFilterGeXing5 = @"gexing5",
FUFilterGeXing6 = @"gexing6",
FUFilterGeXing7 = @"gexing7",
FUFilterGeXing10 = @"gexing10",
FUFilterGeXing11 = @"gexing11",
//小清新
FUFilterXiaoQingXin1 = @"xiaoqingxin1",
FUFilterXiaoQingXin3 = @"xiaoqingxin3",
FUFilterXiaoQingXin4 = @"xiaoqingxin4",
FUFilterXiaoQingXin6 = @"xiaoqingxin6",
//黑白
FUFilterHeiBai1 = @"heibai1",
FUFilterHeiBai2 = @"heibai2",
FUFilterHeiBai3 = @"heibai3",
FUFilterHeiBai4 = @"heibai4"
)
#endif /* FUFilterDefineKey_h */

View File

@@ -0,0 +1,40 @@
//
// FUGLContext.h
// FUStaLiteDemo
//
// Created by ly-Mac on 2019/8/9.
// Copyright © 2019 ly-Mac. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <OpenGLES/EAGL.h>
NS_ASSUME_NONNULL_BEGIN
@protocol FUGLContextProtocol <NSObject>
@required
- (void)glQueueAsync:(dispatch_block_t)block;
- (void)glQueueSync:(dispatch_block_t)block;
- (void)glContextDidChange;
@property (nonatomic, weak) EAGLContext *currentGLContext;
@end
@interface FUGLContext : NSObject
@property (nonatomic,strong, readonly) EAGLContext *currentGLContext;
+ (instancetype)shareGLContext;
- (void)setCustomGLContext:(EAGLContext *)customGLContext;
- (void)glQueueAsync:(dispatch_block_t)block;
- (void)glQueueSync:(dispatch_block_t)block;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,62 @@
//
// FUSceneView.h
// FULiveDemo
//
// Created by 刘洋 on 2017/8/15.
// Copyright © 2017年 刘洋. All rights reserved.
//
#import <GLKit/GLKit.h>
typedef NS_ENUM(NSInteger, FUGLDisplayViewOrientation) {
FUGLDisplayViewOrientationPortrait = 0,
FUGLDisplayViewOrientationLandscapeRight = 1,
FUGLDisplayViewOrientationPortraitUpsideDown = 2,
FUGLDisplayViewOrientationLandscapeLeft = 3,
};
typedef NS_ENUM(NSInteger, FUGLDisplayViewContentMode) {
/* 等比例短边充满 */
FUGLDisplayViewContentModeScaleAspectFill = 0,
/* 拉伸铺满 */
FUGLDisplayViewContentModeScaleToFill = 1,
/* 等比例长边充满 */
FUGLDisplayViewContentModeScaleAspectFit = 2,
};
@class FUGLDisplayView;
@protocol FUGLDisplayViewGestureDelegate <NSObject>
- (void)displayView:(FUGLDisplayView *)displayView panMovedWithTranslation:(CGPoint)translation translationDelta:(CGPoint)translationDelta gestureState:(UIGestureRecognizerState)gestureState;
- (void)displayView:(FUGLDisplayView *)displayView pinchMovedWithScale:(CGFloat)scale scaleDelta:(CGFloat)scaleDelta gestureState:(UIGestureRecognizerState)gestureState;
@end
@interface FUGLDisplayView : UIView
@property (nonatomic, assign) FUGLDisplayViewContentMode contentMode;
// 设置视频朝向,保证视频总是竖屏播放
@property (nonatomic, assign) FUGLDisplayViewOrientation orientation;
@property (nonatomic, weak) id<FUGLDisplayViewGestureDelegate> gestureDelegate;
@property (nonatomic, assign) NSInteger disapplePointIndex;
@property (nonatomic, assign) BOOL alphaEnable;
- (void)setDisplayFramebuffer;
- (void)displayPixelBuffer:(CVPixelBufferRef)pixelBuffer;
- (void)displayImageData:(void *)imageData withSize:(CGSize)size;
- (void)displayPixelBuffer:(CVPixelBufferRef)pixelBuffer withLandmarks:(float *)landmarks count:(int)count;
- (void)presentFramebuffer;
- (void)displayTexture:(int)texture withTextureSize:(CGSize)textureSize;
/// 点位取色
/// @param point glView上的点坐标
- (UIColor *)colorInPoint:(CGPoint)point;
@end

View File

@@ -0,0 +1,20 @@
//
// FUGestureItem.h
// FURenderKit
//
// Created by Chen on 2021/1/28.
//
#import "FUSticker.h"
NS_ASSUME_NONNULL_BEGIN
/**
* 手势道具
*/
@interface FUGesture : FUSticker
//比心道具支持自动调整y轴位置
@property (nonatomic, assign) double handOffY;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,64 @@
//
// FUGreenTent.h
// FURenderKit
//
// Created by Chen on 2021/1/15.
//
#import "FUItem.h"
#import "FUStruct.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUGreenScreen : FUItem
/// 背景图片
@property (nonatomic, strong, nullable) UIImage *backgroundImage;
/// 背景视频URLString
/// @note 设置之后自动开始播放若设置为nil自动停止
@property (nonatomic, copy, nullable) NSString *videoPath;
/// 安全区域图片
@property (nonatomic, strong, nullable) UIImage *safeAreaImage;
/// 关键颜色
/// 默认值为[0,255,0],取值范围[0-255,0-255,0-255]
/// @note 设置关键颜色后会自动改变相似度、平滑度和祛色度的值
@property (nonatomic, assign) FUColor keyColor;
/// 相似度:色度最大容差
/// 取值范围0.0-1.0,色度最大,容差值越大,更多幕景被抠除
/// @note 值跟随关键颜色变化
@property (nonatomic, assign) double chromaThres;
/// 平滑度:色度最小限差,
/// 取值范围0.0-1.0,值越大,更多幕景被扣除
/// @note 值跟随关键颜色变化
@property (nonatomic, assign) double chromaThrest;
/// 祛色度:图像前后景祛色度过度
/// 取值范围0.0-1.0,值越大,两者边缘处透明过度更平滑
/// @note 值跟随关键颜色变化
@property (nonatomic, assign) double alphal;
/// 中心点
@property (nonatomic, assign) CGPoint center;
/// 缩放比例
@property (nonatomic, assign) float scale;
/// 当前是否正在进行抠图,抠图就停止绿慕渲染
@property (nonatomic, assign) BOOL cutouting;
/// 背景视频播放是否暂停
@property (nonatomic, assign) BOOL pause;
/// 开始播放背景视频
- (void)startVideoDecode;
/// 取消播放背景视频
- (void)stopVideoDecode;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,22 @@
//
// FUGroupAnimation.h
// FURenderKit
//
// Created by liuyang on 2021/4/22.
//
#import "FUAnimation.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUGroupAnimation : FUAnimation
@property (nonatomic, copy, readonly) NSArray<FUItem *> *components;
@property (nonatomic, copy, readonly) NSArray<FUAnimation *> *componentAnimations;
- (instancetype)initWithPath:(NSString *)path name:(nullable NSString *)name components:(nullable NSArray<FUItem *> *)components componentAnimations:(nullable NSArray<FUAnimation *> *)componentAnimations;
+ (instancetype)groupAnimationWithPath:(NSString *)path name:(nullable NSString *)name components:(nullable NSArray<FUItem *> *)components componentAnimations:(nullable NSArray<FUAnimation *> *)componentAnimations;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,39 @@
//
// FUHairItem.h
// FURenderKit
//
// Created by Chen on 2021/1/15.
//
#import "FUItem.h"
#import "FUStruct.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUHairBeauty : FUItem
/**
* 单色美发道具 index 对应的值范围 0 - 7渐变色美发道具index对应的值范围 0 - 4
*/
@property (nonatomic, assign) int index;
/**
* 0对应无效果1对应最强效果中间连续过渡。
*/
@property (nonatomic, assign) double strength;
@end
@interface FUHairBeauty (normal)
@property (nonatomic, assign) FULABColor normalColor;
@property (nonatomic, assign) double shine;
@end
@interface FUHairBeauty (gradient)
@property (nonatomic, assign) FULABColor gradientColor0;
@property (nonatomic, assign) FULABColor gradientColor1;
@property (nonatomic, assign) double shine0;
@property (nonatomic, assign) double shine1;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,30 @@
//
// FUHairDefineKey.h
// FUAvatarSDK
//
// Created by Chen on 2021/1/20.
//
#ifndef FUHairDefineKey_h
#define FUHairDefineKey_h
#import "FUKeysDefine.h"
FUParamsKeysDefine(FUHairColor,
FUHairColorL = @"Col_L",
FUHairColorA = @"Col_A",
FUHairColorB = @"Col_B",
FUHairColor0L = @"Col0_L",
FUHairColor0A = @"Col0_A",
FUHairColor0B = @"Col0_B",
FUHairColor1L = @"Col1_L",
FUHairColor1A = @"Col1_A",
FUHairColor1B = @"Col1_B",
)
#endif /* FUHairDefineKey_h */

View File

@@ -0,0 +1,55 @@
//
// FUImageHelper.h
// FULiveDemo
//
// Created by L on 2018/8/3.
// Copyright © 2018年 L. All rights reserved.
//
#import <AVFoundation/AVFoundation.h>
#import <UIKit/UIKit.h>
@interface FUImageHelper : NSObject
+ (void)convertUIImageToBitmapRGBA8:(UIImage *)image completionHandler:(void (^)(int32_t size, unsigned char * bits))completionHandler;
+ (UIImage *)convertBitmapRGBA8ToUIImage:(unsigned char *)buffer
withWidth:(int)width
withHeight:(int)height;
/// 根据UIImage返回CVPixelBufferRef
/// @param image UIImage实例对象
/// 注意CVPixelBufferRef需要手动release
+ (CVPixelBufferRef)pixelBufferFromImage:(UIImage *)image;
/// 根据CVPixelBufferRef返回UIImage
/// @param pixelBufferRef buffer
/// 注意如果后续业务有使用到image.CGImage则需要及时释放掉 image.CGImage
+ (UIImage *)imageFromPixelBuffer:(CVPixelBufferRef)pixelBufferRef;
+ (unsigned char *)getRGBAWithImage:(UIImage *)image;
+ (unsigned char *)getRGBAWithImageName:(NSString *)imageName width:(int *)width height:(int *)height;
/// 截屏处理取色
+ (UIColor*)getPixelColorScreenWindowAtLocation:(CGPoint)point;
/// 针对静态图片处理取色
+ (UIColor *)getPixelColorWithImage:(UIImage *)image point:(CGPoint)point DEPRECATED_MSG_ATTRIBUTE("use colorInPoint: in FUGLDisplayView instead");
/// 针对每一帧处理取色
+ (UIColor *)getPixelColorWithPixelBuff:(CVPixelBufferRef)pixelBuffer point:(CGPoint)point DEPRECATED_MSG_ATTRIBUTE("use colorInPoint: in FUGLDisplayView instead");
+ (UIImage *)rotateImageWithAngle:(UIImage*)vImg Angle:(NSInteger)vAngle IsExpand:(BOOL)vIsExpand;
/// 获取图像数据
/// @param pixelBuffer buffer
/// @param transform 图像方向(0: up 1: right 2: down 3: left)
/// @return Byte
+ (Byte *)getBytesFromPixelBuffer:(CVPixelBufferRef)pixelBuffer transform:(int)transform;
/// 获取视频第一帧图片
/// @param videoURL 视频URL
+ (UIImage *)getPreviewImageWithVideoURL:(NSURL *)videoURL;
@end

View File

@@ -0,0 +1,44 @@
//
// FUInternalCameraSetting.h
// FURenderKit
//
// Created by ly-Mac on 2021/3/2.
//
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface FUInternalCameraSetting : NSObject
/// 相机采集格式
/// 默认为kCVPixelFormatType_32BGRA
@property (nonatomic, assign) int format;
/// 相机分辨率
/// 默认为AVCaptureSessionPreset1280x720
@property (nonatomic, copy) AVCaptureSessionPreset sessionPreset;
/// 相机前后置摄像头
/// 默认为AVCaptureDevicePositionFront
@property (nonatomic, assign) AVCaptureDevicePosition position;
/// 默认为30
@property (nonatomic, assign) int fps;
/// 是否打开内部虚拟相机
/// 需要注意的是在打开内部虚拟相机时用户如果使用Scene相关需要真实相机的功能内部会自动开启真实相机
/// 并且当用户关闭相关Scene功能时内部会自动关闭
/// 默认为 NO
@property (nonatomic, assign) BOOL useVirtualCamera; //
/// 如果使用内部相机时SDK会自动判断当前是否需要使用系统相机如果不需相机内部会模拟一个相机并循环输出图像。
/// 该属性可以设置输出图像的宽高默认宽高为720x1280如果设置为CGSizeZero,则会使用 sessionPreset 的宽高。
@property (nonatomic, assign) CGSize virtualCameraResolution;
/// 相机是否需要音频默认为NO
@property (nonatomic, assign) BOOL needsAudioTrack;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,18 @@
//
// FUItem+createTexture.h
// FURenderKit
//
// Created by Chen on 2021/1/8.
//
#import "FUItem.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUItem (createTexture)
- (int)createTextureWithImage:(UIImage *)image forName:(NSString *)name;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,71 @@
//
// FUItem.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/11/16.
//
#import <Foundation/Foundation.h>
#import "FUParam.h"
#import "FURenderableObject.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUItem : FURenderableObject
@property (nonatomic, copy) NSString *name; // 道具名称
@property (nonatomic, copy) NSString *path; // 道具绝对路径
@property (nonatomic, copy, readonly) NSString *fileId;
@property (nonatomic, assign) BOOL supportARMode; // 是否支持 AR 模式
@property (nonatomic, copy) NSSet<NSNumber *> *bodyInvisibleList; // 身体隐藏区域
/// 根据道具路径创建道具对象,可支持自动加载
/// @param path 道具路径
/// @param name 道具名称
/// @param fileId itemList 中的 path
- (instancetype)initWithPath:(NSString *)path name:(nullable NSString *)name fileId:(nullable NSString *)fileId;
/// 根据道具路径创建道具对象,可支持自动加载
/// @param path 道具路径
/// @param name 道具名称
- (instancetype)initWithPath:(NSString *)path name:(nullable NSString *)name;
+ (instancetype)itemWithPath:(NSString *)path name:(nullable NSString *)name fileId:(nullable NSString *)fileId;
+ (instancetype)itemWithPath:(NSString *)path name:(nullable NSString *)name;
- (int)setParam:(FUParam *)param;
- (int)setParam:(id)param forName:(NSString *)name paramType:(FUParamType)paramType;
- (id)getParamForName:(NSString *)name paramType:(FUParamType)paramType;
//把缓存的属性值全部设置一边
- (BOOL)setAllProperty;
////replaceObj 被替换的对象
//- (BOOL)replaceOldObj:(FUItem *)replaceObj;
////replaceOldBeauty 过滤不替换的属性名称
//@property (nonatomic, copy) NSArray *(^FiltersBlock)(void);
//
///**
// * 遇到结构体属性上抛给特定的FUItem处理如 FUMakeupFUHairItem*
// * typeName属性类型name 属性名称
// */
//@property (nonatomic, copy) void (^StructBlock)(NSString *typeName, NSString *name);
//
///**
// * 遇到资源类的item上抛给特定的FUItem处理如FUMakeup
// * oldItem 属性类的item如果是资源类上层处理。否则就递归处理非资源类FUItem
// * name 属性名称
// */
//@property (nonatomic, copy) void (^ResourceBlock)(FUItem *oldItem, NSString *name);
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,39 @@
//
// FUKeysDefine.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/12/22.
//
#import "metamacros.h"
#define FUParamsKeysDefine(keyPreName,...) \
typedef NSString * keyPreName NS_STRING_ENUM; \
metamacro_foreach_cxt(params_key_define,,static keyPreName , __VA_ARGS__) \
static NSString *_##keyPreName##_constants_string = @"" #__VA_ARGS__; \
_FUParamsKeys_GenerateImplementation(keyPreName)
#define params_key_define(INDEX, CONTEXT, VAR) CONTEXT const VAR;
#define _FUParamsKeys_GenerateImplementation(keyPreName) \
static inline NSArray * keyPreName##AllKeys(){ \
static NSArray *_##keyPreName##AllKeys = NULL; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
NSString *constantsString = _##keyPreName##_constants_string; \
constantsString = [[constantsString componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] componentsJoinedByString:@""]; \
if ([constantsString hasSuffix:@","]) { \
constantsString = [constantsString substringToIndex:[constantsString length]-1]; \
} \
NSArray *stringPairs = [constantsString componentsSeparatedByString:@","]; \
NSMutableArray *keys = [NSMutableArray arrayWithCapacity:[stringPairs count]]; \
for (NSString *stringPair in stringPairs) { \
NSArray *labelAndValueString = [stringPair componentsSeparatedByString:@"="]; \
NSString *key = [labelAndValueString objectAtIndex:1]; \
key = [key stringByReplacingOccurrencesOfString:@"@\"" withString:@""]; \
key = [key stringByReplacingOccurrencesOfString:@"\"" withString:@""]; \
[keys addObject:key]; \
} \
_##keyPreName##AllKeys = [keys copy]; \
}); \
return _##keyPreName##AllKeys; \
}

View File

@@ -0,0 +1,16 @@
//
// FULight.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/11/16.
//
#import "FUItem.h"
NS_ASSUME_NONNULL_BEGIN
@interface FULight : FUItem
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,29 @@
//
// FULightMakeUpTextureKeyDefineKey.h
// FUAvatarSDK
//
// Created by Chen on 2021/1/14.
//
#ifndef FULightMakeUpTextureKeyDefineKey_h
#define FULightMakeUpTextureKeyDefineKey_h
#import "FUKeysDefine.h"
FUParamsKeysDefine(FULightMakeUpTextureKey,
//眉毛
FULightMakeUpTextureKeyTexBrow = @"tex_brow",
//眼影
FULightMakeUpTextureKeyTexEye = @"tex_eye",
//美瞳
FULightMakeUpTextureKeyTexPupil = @"tex_pupil",
//睫毛
FULightMakeUpTextureKeyTexEyeLash = @"tex_eyeLash",
//口红高光
FULightMakeUpTextureKeyTexHighlight = @"tex_highlight",
//眼线
FULightMakeUpTextureKeyTexEyeLiner = @"tex_eyeLiner",
//腮红
FULightMakeUpTextureKeyTexBlusher = @"tex_blusher"
)
#endif /* FULightMakeUpTextureKeyDefineKey_h */

View File

@@ -0,0 +1,50 @@
//
// FULightMakeup.h
// FURenderKit
//
// Created by Chen on 2021/1/14.
//
#import "FUItem.h"
#import "FUStruct.h"
#import <UIKit/UIImage.h>
#import "FUMakeupValueDefine.h"
NS_ASSUME_NONNULL_BEGIN
@interface FULightMakeup : FUItem
@property (nonatomic, assign) BOOL isMakeupOn; //0 关 1开
@property (nonatomic, assign) FUMakeupLipType lipType;//口红类型 0雾面 2润泽 3珠光 6高性能不支持双色7润泽Ⅱ
@property (nonatomic, assign) BOOL isTwoColor;//口红双色开关0为关闭1为开启如果想使用咬唇开启双色开关并且将makeup_lip_color2的值都设置为0
@property (nonatomic, assign) BOOL makeupLipMask;//嘴唇优化效果开关1.0为开 0为关
@end
@interface FULightMakeup (image)
@property (nonatomic, strong) UIImage *subEyebrowImage;//眉毛
@property (nonatomic, strong) UIImage *subEyeshadowImage;//眼影
@property (nonatomic, strong) UIImage *subPupilImage;//美瞳
@property (nonatomic, strong) UIImage *subEyelashImage;//睫毛
@property (nonatomic, strong) UIImage *subHightLightImage;//高光
@property (nonatomic, strong) UIImage *subEyelinerImage;//眼线
@property (nonatomic, strong) UIImage *subBlusherImage;//腮红
@end
@interface FULightMakeup (intensity)
@property (nonatomic, assign) double intensityLip;//口红
@property (nonatomic, assign) double intensityBlusher;//腮红
@property (nonatomic, assign) double intensityEyeshadow;//眼影
@property (nonatomic, assign) double intensityEyeliner;//眼线
@property (nonatomic, assign) double intensityEyelash;//睫毛
@property (nonatomic, assign) double intensityPupil;//美瞳
@property (nonatomic, assign) double intensityEyebrow;//眉毛
@end
@interface FULightMakeup (Color)
@property (nonatomic, assign) FUColor makeUpLipColor;//口红颜色
@end
@interface FULightMakeup (landMark)
@property (nonatomic, assign) int isUserFix; //这个参数控制是否使用修改过得landmark点如果设为1为使用0为不使用
@property (nonatomic, assign) FULandMark fixMakeUpData;//这个参数为一个数组,需要客户端传递一个数组进去,传递的数组的长度为 150*人脸数,也就是将所有的点位信息存储的数组中传递进来。
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,45 @@
//
// FUMakeUpChildStrengthKeyKey.h
// FUAvatarSDK
//
// Created by Chen on 2021/1/6.
//
#ifndef FUMakeUpChildStrengthKey_h
#define FUMakeUpChildStrengthKey_h
#import "FUKeysDefine.h"
FUParamsKeysDefine(FUMakeUpChildStrengthKey,
//粉底
FUMakeUpChildStrengthKeyIntensityFoundation = @"makeup_intensity_foundation",
//口红
FUMakeUpChildStrengthKeyIntensityLip = @"makeup_intensity_lip",
//腮红
FUMakeUpChildStrengthKeyIntensityBlusher = @"makeup_intensity_blusher",
//眉毛
FUMakeUpChildStrengthKeyIntensityEyeBrow = @"makeup_intensity_eyeBrow",
//眼影
FUMakeUpIntensityEye = @"makeup_intensity_eye",
//眼线
FUMakeUpChildStrengthKeyIntensityEyeLiner = @"makeup_intensity_eyeLiner",
//睫毛
FUMakeUpChildStrengthKeyIntensityEyelash = @"makeup_intensity_eyelash",
//高光
FUMakeUpChildStrengthKeyIntensityHighlight = @"makeup_intensity_highlight",
//阴影
FUMakeUpChildStrengthKeyIntensityShadow = @"makeup_intensity_shadow",
//美瞳
FUMakeUpChildStrengthKeyIntensityPupil = @"makeup_intensity_pupil"
)
#endif /* FUMakeUpChildStrengthKey_h */

View File

@@ -0,0 +1,52 @@
//
// FUMakeUpColorsKey1.h
// FURenderKit
//
// Created by Chen on 2021/2/1.
//
#ifndef FUMakeUpColorsKey_h
#define FUMakeUpColorsKey_h
#import "FUKeysDefine.h"
FUParamsKeysDefine(FUMakeUpColor,
//粉底
FUMakeUpColorFoundationColor = @"makeup_foundation_color",
//口红颜色
FUMakeUpColorLipColor = @"makeup_lip_color",
//口红颜色v2
FUMakeUpColorLipColorV2 = @"makeup_lip_color_v2",
//口红颜色2
FUMakeUpColorLipColor2 = @"makeup_lip_color2",
//腮红
FUMakeUpColorBlusherColor = @"makeup_blusher_color",
//眉毛
FUMakeUpColorEyeBrowColor = @"makeup_eyeBrow_color",
//眼影
FUMakeUpColorEyeColor = @"makeup_eye_color",
//眼线
FUMakeUpColorEyeLinerColor = @"makeup_eyeLiner_color",
//睫毛
FUMakeUpColorEyelashColor = @"makeup_eyelash_color",
//高光
FUMakeUpColorHighlightColor = @"makeup_highlight_color",
//阴影
FUMakeUpColorShadowColor = @"makeup_shadow_color",
//美瞳
FUMakeUpColorPupilColor = @"makeup_pupil_color"
)
#endif /* FUMakeUpColorsKey_h */

View File

@@ -0,0 +1,55 @@
//
// FUMakeUpTextureKey.h
// FURenderKit
//
// Created by Chen on 2021/2/1.
//
#ifndef FUMakeUpTextureKey_h
#define FUMakeUpTextureKey_h
#import "FUKeysDefine.h"
FUParamsKeysDefine(FUMakeUpTextureKey,
//眉毛
FUMakeUpTextureKeyTexBrow = @"tex_brow",
//眼影
FUMakeUpTextureKeyTexEye1 = @"tex_eye",
//眼影2
FUMakeUpTextureKeyTexEye2 = @"tex_eye2",
//眼影3
FUMakeUpTextureKeyTexEye3 = @"tex_eye3",
//眼影4
FUMakeUpTextureKeyTexEye4 = @"tex_eye4",
//美瞳
FUMakeUpTextureKeyTexPupil = @"tex_pupil",
//睫毛
FUMakeUpTextureKeyTexEyeLash = @"tex_eyeLash",
//眼线
FUMakeUpTextureKeyTexEyeLiner = @"tex_eyeLiner",
//腮红1
FUMakeUpTextureKeyTexBlusher1 = @"tex_blusher",
//腮红2
FUMakeUpTextureKeyTexBlusher2 = @"tex_blusher2",
//粉底
FUMakeUpTextureKeyTexFoundation = @"tex_foundation",
//高光
FUMakeUpTextureKeyTexHighlight = @"tex_highlight",
//阴影
FUMakeUpTextureKeyTexShadow = @"tex_shadow"
)
#endif /* FUMakeUpTextureKey_h */

View File

@@ -0,0 +1,193 @@
//
// FUMakeup.h
// FURenderKit
//
// Created by Chen on 2021/1/6.
//
#import "FUItem.h"
#import <Foundation/Foundation.h>
#import "FUStruct.h"
#import "FUMakeupValueDefine.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUMakeup : FUItem
/// 美妆开关默认为YES
@property (nonatomic, assign) BOOL isMakeupOn;
/// 在解绑妆容时是否清空除口红以外的妆容NO表示不清空YES表示清空口红可由强度进行设置
@property (nonatomic, assign) BOOL isClearMakeup;
/// 美妆分割YES为开NO为关默认NO
/// @note 建议在高端机型中使用
@property (nonatomic, assign) BOOL makeupSegmentation;
/// 口红类型
/// @see FUMakeupLipType
@property (nonatomic, assign) FUMakeupLipType lipType;
/// 是否开启口红高光YES为开NO为关
@property (nonatomic, assign) BOOL isLipHighlightOn;
/// 口红双色开关NO为关闭YES为开启
/// @note 如果想使用咬唇需要开启双色开关并且将makeup_lip_color2的值都设置为0
@property (nonatomic, assign) BOOL isTwoColor;
/// 眉毛变形类型
/// @see FUMakeupBrowWarpType
/// @note 如果browWarp为NO眉毛变形类型设置失效
@property (nonatomic, assign) FUMakeupBrowWarpType browWarpType;
/// 是否使用眉毛变形 YES为开 NO为关默认为NO
@property (nonatomic, assign) BOOL browWarp;
@end
#pragma mark - 主题妆
@interface FUMakeup (Subject)
/// 更新组合装
/// @param makeupPackage 子妆
/// @param needCleanSubItem 是否清除老子妆
- (void)updateMakeupPackage:(FUItem * __nullable)makeupPackage needCleanSubItem:(BOOL)needCleanSubItem;
/// 整体妆容程度值
@property (nonatomic, assign) double intensity;
/// 整体妆容滤镜程度值
@property (nonatomic, assign) double filterIntensity;
/// 局部妆容对象,属于组合装内部的具体部位(眉毛、眼镜、鼻子等)自定义设置
@property (nonatomic, strong, nullable) FUItem *subEyebrow;
@property (nonatomic, strong, nullable) FUItem *subEyeshadow;
@property (nonatomic, strong, nullable) FUItem *subPupil;
@property (nonatomic, strong, nullable) FUItem *subEyelash;
@property (nonatomic, strong, nullable) FUItem *subEyeliner;
@property (nonatomic, strong, nullable) FUItem *subBlusher;
@property (nonatomic, strong, nullable) FUItem *subFoundation;
@property (nonatomic, strong, nullable) FUItem *subHighlight;
@property (nonatomic, strong, nullable) FUItem *subShadow;
@property (nonatomic, strong, nullable) FUItem *subLip;
@end
#pragma mark - 图层混合模式
@interface FUMakeup (blend)
@property (nonatomic, assign) FUMakeupBlendType blendTypeEyeshadow1;
@property (nonatomic, assign) FUMakeupBlendType blendTypeEyeshadow2;
@property (nonatomic, assign) FUMakeupBlendType blendTypeEyeshadow3;
@property (nonatomic, assign) FUMakeupBlendType blendTypeEyeshadow4;
@property (nonatomic, assign) FUMakeupBlendType blendTypeEyelash;
@property (nonatomic, assign) FUMakeupBlendType blendTypeEyeliner;
@property (nonatomic, assign) FUMakeupBlendType blendTypeBlusher1;
@property (nonatomic, assign) FUMakeupBlendType blendTypeBlusher2;
@property (nonatomic, assign) FUMakeupBlendType blendTypePupil;
@end
#pragma mark - 子妆程度值
@interface FUMakeup (intensity)
/// 粉底程度值
@property (nonatomic, assign) double intensityFoundation;
/// 口红程度值
@property (nonatomic, assign) double intensityLip;
/// 口红高光程度值
/// @note 暂时只用于lipType=FUMakeupLipTypeMoisturizing的情况
@property (nonatomic, assign) double intensityLipHighlight;
/// 腮红程度值
@property (nonatomic, assign) double intensityBlusher;
/// 眉毛程度值
@property (nonatomic, assign) double intensityEyebrow;
/// 眼影程度值
@property (nonatomic, assign) double intensityEyeshadow;
/// 眼线程度值
@property (nonatomic, assign) double intensityEyeliner;
/// 睫毛程度值
@property (nonatomic, assign) double intensityEyelash;
/// 高光程度值
@property (nonatomic, assign) double intensityHighlight;
/// 阴影程度值
@property (nonatomic, assign) double intensityShadow;
/// 美瞳程度值
@property (nonatomic, assign) double intensityPupil;
@end
#pragma mark - 子妆颜色
@interface FUMakeup (Color)
/// 粉底颜色
@property (nonatomic, assign) FUColor foundationColor;
/// 口红颜色
@property (nonatomic, assign) FUColor lipColor;
/// 口红颜色2
@property (nonatomic, assign) FUColor lipColor2;
/// 腮红颜色
@property (nonatomic, assign) FUColor blusherColor;
/// 眉毛颜色
@property (nonatomic, assign) FUColor eyebrowColor;
/// 眼线颜色
@property (nonatomic, assign) FUColor eyelinerColor;
/// 睫毛颜色
@property (nonatomic, assign) FUColor eyelashColor;
/// 高光颜色
@property (nonatomic, assign) FUColor highlightColor;
/// 阴影颜色
@property (nonatomic, assign) FUColor shadowColor;
/// 美瞳颜色
@property (nonatomic, assign) FUColor pupilColor;
/// 眼影特殊处理
/// @note 如果is_two_color为1会启用这个颜色外圈颜色为color2内圈颜色为color如果color都为0则外圈为透明即为咬唇效果
/// - Parameters:
/// - color: 第一层眼影调色参数数组的第四个值对应alpha为0时会关闭这层的调色功能大于0时会开启
/// - color1: 第二层眼影调色参数数组的第四个值对应alpha为0时会关闭这层的调色功能大于0时会开启内部暂时未处理使用color2和color3
/// - color2: 第三层眼影调色参数数组的第四个值对应alpha为0时会关闭这层的调色功能大于0时会开启
/// - color3: 第四层眼影调色参数数组的第四个值对应alpha为0时会关闭这层的调色功能大于0时会开启
- (void)setEyeColor:(FUColor)color
color1:(FUColor)color1
color2:(FUColor)color2
color3:(FUColor)color3;
@end
@interface FUMakeup (landMark)
/// 这个参数控制是否使用修改过得landmark点1为使用0为不使用
@property (nonatomic, assign) int isUserFix;
/// 这个参数为一个数组,需要客户端传递一个数组进去
/// @note 传递的数组的长度为 150*人脸数,也就是将所有的点位信息存储的数组中传递进来
@property (nonatomic, assign) FULandMark fixMakeUpData;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,38 @@
//
// FUMakeupValueDefine.h
// FURenderKit
//
// Created by Chen on 2021/3/4.
//
#ifndef FUMakeupValueDefine_h
#define FUMakeupValueDefine_h
typedef NS_ENUM(NSUInteger, FUMakeupLipType) {
FUMakeupLipTypeFOG = 0, //雾面
FUMakeupLipTypeGlossy = 2, //润泽Ⅰ
FUMakeupLipTypePearlyLustre = 3, //珠光
FUMakeupLipTypeHightPerformance = 6, //高性能
FUMakeupLipTypeMoisturizing = 7, //润泽Ⅱ
};
typedef NS_ENUM(NSUInteger, FUMakeupBrowWarpType) {
FUMakeupBrowWarpTypeArch = 0, //柳叶眉
FUMakeupBrowWarpTypeSynophridia, //一字眉
FUMakeupBrowWarpTypeDistantMountains, //小山眉
FUMakeupBrowWarpTypeStandard, //标准眉
FUMakeupBrowWarpTypeHelpShape, //扶形眉
FUMakeupBrowWarpTypeDaily, //日常风
FUMakeupBrowWarpTypeJapanese //日系风
};
typedef NS_ENUM(NSInteger, FUMakeupBlendType) {
FUMakeupBlendTypeInvalid = -1, //默认无效
FUMakeupBlendTypeMultiply = 0, //正片叠底
FUMakeupBlendTypeNormal, //正常混合
FUMakeupBlendTypeOverlay, //叠加
FUMakeupBlendTypeSoftLight, //柔光模式
};
#endif /* FUMakeupValueDefine_h */

View File

@@ -0,0 +1,47 @@
//
// FUMusicFilter.h
// FURenderKit
//
// Created by Chen on 2021/1/28.
//
#import "FUSticker.h"
NS_ASSUME_NONNULL_BEGIN
/**
* 音乐滤镜
*/
@interface FUMusicFilter : FUSticker
/**
* 设置音乐文件路径,但不播放,等到音乐滤镜在底层库渲染时自动播放音乐
* 同步音乐和渲染效果
*/
@property (nonatomic, strong) NSString *musicPath;
/**
* 播放当前已经设置的音乐文件
*/
- (void)play;
/**
* 继续播放
*/
- (void)resume;
/**
* 停止播放
*/
- (void)stop;
/**
* 暂停
*/
- (void)pause;
/**
* 获取播放进度
*/
- (float)playProgress;
/**
* 获取当前媒体播放时间
*/
- (NSTimeInterval)currentTime;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
//
// FUBidirectionalMap.h
// FUVideoEditor
//
// Created by Roy Zhang on 2020/4/15.
// Copyright © 2020 Faceunity. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface FUOvonicMap : NSObject
@property (nonatomic, strong) NSMutableDictionary *keysToValues;
@property (nonatomic, strong) NSMapTable *valuesToKeys;
@property (nonatomic, readonly) unsigned long long count;
+ (FUOvonicMap*)map;
+ (FUOvonicMap*)mapWithDictionary:(NSDictionary *)dictionary;
- (FUOvonicMap*)initWithDictionary:(NSDictionary *)dictionary;
- (void)createValuesToKeysMapping;
- (id)objectForKeyedSubscript:(id)key;
- (void)setObject:(id)object forKeyedSubscript:(id)key;
- (void)removeObjectForKey:(id)key;
- (id)keyForObject:(id)object;
- (NSArray *)allKeys;
- (NSArray *)allValues;
- (NSDictionary *)dictionary;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,33 @@
//
// FUParam.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/11/17.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
FUParamTypeString,
FUParamTypeDouble,
FUParamTypeUInt64,
FUParamTypeBufferByte,
FUParamTypeBufferDouble,
FUParamTypeBufferFloat,
} FUParamType;
@interface FUParam : NSObject
@property (nonatomic, copy) NSString *name;
@property (nonatomic, assign) FUParamType type;
@property (nonatomic, strong) id paramValue;
+ (FUParam *)paramWithName:(NSString *)name value:(id)paramValue type:(FUParamType)type;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,82 @@
//
// FUPoster.h
// FURenderKit
//
// Created by Chen on 2021/1/8.
//
#import "FUItem.h"
#import <CoreGraphics/CGGeometry.h>
#import "FURenderIO.h"
@class FUPoster;
NS_ASSUME_NONNULL_BEGIN
@class UIImage, FUFaceRectInfo;
@protocol FUPosterProtocol <NSObject>
@optional
/**
* 检测输入照片人脸结果异常调用, 用于处理异常提示 UI逻辑.
* code: -1, 人脸异常(检测到人脸但是角度不对返回-10: 未检测到人脸
*/
- (void)poster:(FUPoster *)poster inputImageTrackErrorCode:(int)code;
/**
* 检测海报模版背景图片人脸结果(异常调用)
* code: -1, 人脸异常(检测到人脸但是角度不对返回-1 0: 未检测到人脸
*/
- (void)poster:(FUPoster *)poster tempImageTrackErrorCode:(int)code;
/**
* 输入照片检测到单人脸回调此方法
*/
- (void)poster:(FUPoster *)poster trackedFaceInfo:(FUFaceRectInfo *)faceInfo;
/**
* 输入照片检测到多张人脸回调此方法,用于UI层绘制多人脸 UI
*/
- (void)poster:(FUPoster *)poster trackedMultiFaceInfos:(NSArray <FUFaceRectInfo *> *)faceInfos;
/**
* inputImage 和 蒙板image 合成的结果回调
* data : 海报蒙板和照片合成之后的图片数据
*/
- (void)poster:(FUPoster *)poster didRenderToImage:(UIImage *)image;
/**
* 设置模板弯曲度,需要外部传入
* return double 对象
*/
- (NSNumber *)renderOfWarp;
@end
@interface FUPoster : FUItem
@property (nonatomic, weak) id<FUPosterProtocol>delegate;
/**
* inputImage 需要替换包含人脸图片
* templateImage 背景模板包含人脸的图片
*/
- (void)renderWithInputImage:(UIImage *)inputImage templateImage:(UIImage *)templateImage;
/**
* 替换背景图片
*/
- (void)changeTempImage:(UIImage *)tempImage;
/**
* 计算人脸区域
*/
+ (CGRect)cacluteRectWithIndex:(int)index height:(int)originHeight width:(int)orighnWidth;
/**
* 选择某张具体的人脸,
* faceId 通过 checkPosterWithFaceIds:rectsMap 获取
*/
- (void)chooseFaceID:(int)faceID;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,21 @@
//
// FUQualitySticker.h
// FURenderKit
//
// Created by Chen on 2021/4/14.
//
#import "FUSticker.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUQualitySticker : FUSticker
@property (nonatomic, assign) BOOL isFlipPoints; //点位镜像0为关闭1为开启
@property (nonatomic, assign) BOOL is3DFlipH; //翻转模型
/// 精品贴纸点击屏幕特殊效果
- (void)clickToChange;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,144 @@
//
// FURenderInput.h
// FURenderKit
//
// Created by liuyang on 2021/1/4.
//
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import "CNamaSDK.h"
typedef enum : NSUInteger {
FUImageBufferFormatRGBA,
FUImageBufferFormatBGRA,
FUImageBufferFormatYUV420V,
FUImageBufferFormatYUV420F,
FUImageBufferFormatYUVI420,
} FUImageBufferFormat;
typedef enum : NSUInteger {
FUImageOrientationUP,
FUImageOrientationRight,
FUImageOrientationDown,
FUImageOrientationLeft
} FUImageOrientation;
/// CPU image 数据
struct FUImageBuffer {
Byte *buffer0; // 格式与传入 buffer 类型对应关系RGBA: rgba_buffer; BGRA: bgra_buffer; YUV420V/YUV420F/YUVI420: y_buffer
size_t stride0; // 格式与传入 stride 类型对应关系RGBA: rgba_stride; BGRA: bgra_stride; YUV420V/YUV420F/YUVI420: y_stride
Byte *buffer1; // 格式与传入 buffer 类型对应关系RGBA/BGRA: NULL; YUV420V/YUV420F: uv_buffer; YUVI420: u_buffer
size_t stride1; // 格式与传入 stride 类型对应关系RGBA/BGRA: 0; YUV420V/YUV420F: uv_stride; YUVI420: u_stride
Byte *buffer2; // 格式与传入 buffer 类型对应关系RGBA/BGRA: NULL; YUV420V/YUV420F: NULL; YUVI420: v_buffer
size_t stride2; // 格式与传入 stride 类型对应关系RGBA/BGRA: 0; YUV420V/YUV420F: 0; YUVI420: v_stride
CGSize size; // 图像宽高
FUImageBufferFormat format; // 图像格式
};
typedef struct FUImageBuffer FUImageBuffer;
FUImageBuffer FUImageBufferMakeRGBA(Byte *buffer0, size_t width, size_t height, size_t stride0);
FUImageBuffer FUImageBufferMakeBGRA(Byte *buffer0, size_t width, size_t height, size_t stride0);
FUImageBuffer FUImageBufferMakeYUV420F(Byte *buffer0, Byte *buffer1, size_t width, size_t height, size_t stride0, size_t stride1);
FUImageBuffer FUImageBufferMakeYUV420V(Byte *buffer0, Byte *buffer1, size_t width, size_t height, size_t stride0, size_t stride1);
FUImageBuffer FUImageBufferMakeI420(Byte *buffer0, Byte *buffer1, Byte *buffer2, size_t width, size_t height, size_t stride0, size_t stride1, size_t stride2);
FUImageBuffer FUImageBufferMake(Byte *buffer0, Byte *buffer1, Byte *buffer2, size_t width, size_t height, size_t stride0, size_t stride1, size_t stride2, FUImageBufferFormat format);
/// 纹理数据
struct FUTexture {
GLuint ID; // 纹理ID
CGSize size; // 纹理宽高
};
typedef struct FUTexture FUTexture;
#pragma -mark FURenderConfig
@interface FURenderConfig : NSObject
/// 自定义输出结果的大小当前只会对输出的纹理及pixelBuffer有效
@property (nonatomic, assign) CGSize customOutputSize;
/// 当前图片是否来源于前置摄像头,默认为 NO
@property (nonatomic, assign) BOOL isFromFrontCamera;
/// 当前图片是否来源于镜像摄像头,默认为 NO
@property (nonatomic, assign) BOOL isFromMirroredCamera;
/// 原始图像的朝向
@property (nonatomic, assign) FUImageOrientation imageOrientation;
/// 贴纸水平镜像
@property (nonatomic, assign) BOOL stickerFlipH;
/// 贴纸垂直镜像
@property (nonatomic, assign) BOOL stickerFlipV;
/// 重力开关,开启此功能可以根据已设置的 imageRotation 自动适配AI检测的方向。
@property (nonatomic, assign) BOOL gravityEnable;
/// 设置为YES 只会生效美颜结果
@property (nonatomic, assign) BOOL onlyRenderBeauty;
/// 设置输入pixelBuffer/imageBuffer的旋转方向以使buffer数据与textureTransform作用后纹理的方向一致该参数仅用于AI算法检测不会改变buffer的方向或镜像属性
@property (nonatomic, assign) TRANSFORM_MATRIX bufferTransform;
/// 设置输入纹理的旋转及镜像信息,设置该属性会影响输出纹理的方向。默认基于 CPU 图像创建的纹理与CPU 图像成上下镜像关系,此时 textureTransform 对应的值为 DEFAULT以此类推如果对默认生成的纹理做了其他变换则将该参数设置为对应的变换即可。
@property (nonatomic, assign) TRANSFORM_MATRIX textureTransform;
/// 设置输出pixelBuffer/imageBuffer的旋转方向以使buffer数据与textureTransform作用后纹理的方向一致该参数仅用于AI算法检测不会改变buffer的方向或镜像属性
@property (nonatomic, assign) TRANSFORM_MATRIX outputTransform;
/// 是否渲染到当前的FBO设置为YES时返回的 FURenderOutput 内的所有数据均为空值。
@property (nonatomic, assign) BOOL renderToCurrentFBO;
//是否读回到输入的buffer, 如果手机在后台状态也不回写数据返回的output对象内部buffer为空。
@property (nonatomic, assign) BOOL readBackToPixelBuffer;
/// 设置为YES 且 renderToCurrentFBO 为 NO 时只会输出纹理不会输出CPU层的图像。
@property (nonatomic, assign) BOOL onlyOutputTexture;
/// 控制输出图像是否保留透明信息默认值为NO可能会输出不透明的图像开启该参数可以保持图像中透明信息。
@property (nonatomic, assign) BOOL keepAlpha;
/// 如果 renderKit 有 glDisplayView ,控制绘制结果将直接渲染到 glDisplayView
@property (nonatomic, assign) BOOL autoDisplay;
@end
#pragma -mark FURenderInput
@interface FURenderInput : NSObject
/// 输入的纹理
@property (nonatomic, assign) FUTexture texture;
/// 输入的 pixelBuffer
@property (nonatomic, assign) CVPixelBufferRef pixelBuffer;
/// 输入的 imageBuffer如果同时传入了 pixelBuffer将优先使用 pixelBuffer
/// 输入 imageBuffer在 renderConfig 的 onlyOutputTexture 为 NO 时render 结果会直接读会输入的 imageBuffer大小格式与输入均保持一致。
@property (nonatomic, assign) FUImageBuffer imageBuffer;
/// 设置render相关的输入输出配置详细参数请查看 FURenderConfig 类的接口注释。
@property (nonatomic, strong, readonly) FURenderConfig *renderConfig;
@end
#pragma -mark FURenderOutput
@interface FURenderOutput : NSObject
/// 输出的纹理
@property (nonatomic, assign) FUTexture texture;
/// 输出的 pixelBuffer
@property (nonatomic, assign) CVPixelBufferRef pixelBuffer;
/// 输出的 imageBuffer内部数据与输入的 imageBuffer 一致。
@property (nonatomic, assign) FUImageBuffer imageBuffer;
@end

View File

@@ -0,0 +1,86 @@
//
// FURenderKit-umbrella.h
// FURenderKit
//
// Created by 项林平 on 2022/2/21.
//
#import "FURenderKit.h"
#import "FUAIKit.h"
#import "CNamaSDK.h"
#import "FURenderer.h"
#import "FURenderIO.h"
#import "FUConfig.h"
#import "FUAIConfig.h"
#import "FUSetupConfig.h"
#import "FUInternalCameraSetting.h"
#import "FUKeysDefine.h"
#import "FUDeformationKeys.h"
#import "FUBeautyPropertyModeDefine.h"
#import "FUFilterDefineKey.h"
#import "FUMakeupValueDefine.h"
#import "FUMakeUpTextureKey.h"
#import "FUMakeUpColorsKey.h"
#import "FUBodyBeautyDefineKeys.h"
#import "FULightMakeUpTextureKeyDefineKey.h"
#import "FUHairDefineKey.h"
#import "FUMakeUpChildStrengthDefineKey.h"
#import "FUAvatarColorKeys.h"
#import "FUFacepupKeys.h"
#import "FUStruct.h"
#import "FURenderableObject.h"
#import "FUItem.h"
#import "FUCustomBackground.h"
#import "FUMusicFilter.h"
#import "FUStickerContainer.h"
#import "FUFaceRectInfo.h"
#import "FUParam.h"
#import "FUActionRecognition.h"
#import "FUSticker.h"
#import "FUGreenScreen.h"
#import "FUBodyBeauty.h"
#import "FUAnimoji.h"
#import "FUQualitySticker.h"
#import "FUAnimation.h"
#import "FUHairBeauty.h"
#import "FUBeauty.h"
#import "FUBeauty-Deprecated.h"
#import "FUComicFilter.h"
#import "FUAISegment.h"
#import "FUMakeup.h"
#import "FUBackground.h"
#import "FULightMakeup.h"
#import "FUScene.h"
#import "FUSceneCamera.h"
#import "FUAvatar.h"
#import "FUAvatarMakeup.h"
#import "FUFacialFeatures.h"
#import "FUGroupAnimation.h"
#import "FUPoster.h"
#import "FUCameraAnimation.h"
#import "FUGesture.h"
#import "FULight.h"
#import "FUCaptureCamera.h"
#import "FUGLDisplayView.h"
#import "FUGLContext.h"
#import "FURenderQueue.h"
#import "metamacros.h"
#import "FUImageHelper.h"
#import "FUOvonicMap.h"
#import "FUCLIColor.h"
#import "FUAvatarCheck.h"
#import "FUVideoComponentDefines.h"
#import "FUVideoReader.h"
#import "FUVideoWriter.h"
#import "FUVideoProcessor.h"
#import "UIImage+FURenderKit.h"
#import "FUItem+createTexture.h"
#import "UIDevice+FURenderKit.h"

View File

@@ -0,0 +1,301 @@
//
// FURenderKit.h
// FURenderKit
//
// Created by ly-Mac on 2020/12/2.
//
#import <Foundation/Foundation.h>
#import "FUScene.h"
#import "FUAvatarCheck.h"
#import "FUGroupAnimation.h"
#import "FUCaptureCamera.h"
#import "FUInternalCameraSetting.h"
#import "FUGLDisplayView.h"
#import "FUSetupConfig.h"
#import "FURenderIO.h"
#import "FUBeauty.h"
#import "FUMakeup.h"
#import "FUStickerContainer.h"
#import "FULightMakeup.h"
#import "FUComicFilter.h"
#import "FUHairBeauty.h"
#import "FUGreenScreen.h"
#import "FUBodyBeauty.h"
#import "FUActionRecognition.h"
#import "FUPoster.h"
#import "FUMusicFilter.h"
#import "FUAnimoji.h"
#import "FUGesture.h"
#import "FUFaceRectInfo.h"
#import "FUAISegment.h"
#import "UIImage+FURenderKit.h"
#import "FUImageHelper.h"
#import "UIDevice+FURenderKit.h"
#import "FURenderQueue.h"
#import "FUAIKit.h"
NS_ASSUME_NONNULL_BEGIN
@class FURenderKit;
FUParamsKeysDefine(FUDynamicQualityParamKey,
FUDynamicQualityParamTriggerFPSKey = @"trigger_fps",
FUDynamicQualityParamChangeSpeedKey = @"quality_change_speed",
FUDynamicQualityParamChangeSmoothTimeKey = @"quality_change_smooth_time"
)
#pragma mark - 内部相机render相关协议
@protocol FURenderKitDelegate <NSObject>
@optional
/// 使用内部相机时,即将处理图像时输入回调
- (void)renderKitWillRenderFromRenderInput:(FURenderInput *)renderInput;
/// 使用内部相机时,处理图像后的输出回调
- (void)renderKitDidRenderToOutput:(FURenderOutput *)renderOutput;
/// 使用内部相机时内部是否进行render处理返回NO将直接输出原图。
- (BOOL)renderKitShouldDoRender;
@end
@interface FURenderKit : NSObject
/// 3D场景实例设置前需要先将 scene 通过 addScene 接口添加到 renderKit
@property (nonatomic, strong, nullable) FUScene *currentScene;
/// 通过 addScene 接口添加到renderKit的3D场景数组
@property (nonatomic, strong, readonly) NSArray *scenes;
/// 美颜
@property (nonatomic, strong, nullable) FUBeauty *beauty;
/// 美妆
@property (nonatomic, strong, nullable) FUMakeup *makeup;
/// 道具贴纸、AR面具、搞笑大头、哈哈镜等道具的容器对象
@property (nonatomic, strong, readonly) FUStickerContainer *stickerContainer;
/// 轻美妆
@property (nonatomic, strong, nullable) FULightMakeup *lightMakeup;
/// 动漫滤镜
@property (nonatomic, strong, nullable) FUComicFilter *comicFilter;
/// 美发
@property (nonatomic, strong, nullable) FUHairBeauty *hairBeauty;
/// 绿慕
@property (nonatomic, strong, nullable) FUGreenScreen *greenScreen;
/// 音乐滤镜
@property (nonatomic, strong, nullable) FUMusicFilter *musicFilter;
/// 美体
@property (nonatomic, strong, nullable) FUBodyBeauty *bodyBeauty;
/// 动作识别
@property (nonatomic, strong, nullable) FUActionRecognition *actionRecognition;
/// 人像分割
@property (nonatomic, strong, nullable) FUAISegment *segmentation;
/// 抗锯齿道具
@property (nonatomic, strong, nullable) FUItem *antiAliasing;
/// 多重采样等级默认为0
@property (nonatomic, assign) int msaaLevel;
/// 内部渲染视图
/// @note 如果使用 glDisplayView 渲染,需要由用户自己创建并赋值给该属性,当内部或外部调用 renderWithInput 时,会自动显示在该 View 中。
@property (nonatomic, strong, nullable) FUGLDisplayView *glDisplayView;
#pragma mark - 内部相机与回调
/// internalCameraSetting 有默认值,用户按需修改对应配置即可。
/// @see FUInternalCameraSetting
@property (nonatomic, strong, readonly) FUInternalCameraSetting *internalCameraSetting;
/// 暂停内部渲染循环不会影响外部对renderWithInput的调用。
@property (nonatomic, assign) BOOL pause;
/// 内部相机,当 使用内部相机,并且 internalCameraSetting 中 useVirtualCamera == NO 时,才会开启内部真实相机。
@property (nonatomic, strong, readonly, nullable) FUCaptureCamera *captureCamera;
/// 内部渲染回调,只有使用内部相机时对应的代理方法才会执行
/// @see FURenderKitDelegate
@property (nonatomic, weak, nullable) id<FURenderKitDelegate> delegate;
#pragma mark - setup and destroy
/// FURenderKit 单例
+ (instancetype)shareRenderKit;
/// SDK 初始化
/// @param setupConfig 初始化配置
/// @see FUSetupConfig
+ (BOOL)setupWithSetupConfig:(FUSetupConfig *)setupConfig;
/// setupconfig 里面需要填入offLinePath 离线鉴权包地址
/// @return 第一次鉴权成功后的文件
+ (NSData *)setupLocalWithSetupConfig:(FUSetupConfig *)setupConfig;
/// 内部调用fuSetupInternalCheck 初始化鉴权
/// @return NO 失败, YES成功
+ (BOOL)setupInternalCheckWithSetupConfig:(FUSetupConfig *)setupConfig;
/// 内部调用fuSetupInternalCheckPackageBind 初始化鉴权
/// @param setupConfig 初始化配置
/// @return NO 失败, YES成功
+ (BOOL)setupInternalCheckPackageBindWithSetupConfig:(FUSetupConfig *)setupConfig;
/// 销毁 FURenderKit释放内存同时会清空所有的特效模型。
+ (void)destroy;
/// 清空所有的特效模型美颜、美型、美妆、3D场景与形象等。
+ (void)clear;
#pragma mark - version
/// 获取版本信息
/// @return 版本信息
+ (NSString *)getVersion;
/// 设置 log 等级
/// @param logLevel log 等级
+ (void)setLogLevel:(FULOGLEVEL)logLevel;
/// 设置 log 保存路径
/// @param filePath log 保存路径
+ (void)setLogFilePath:(NSString *)filePath;
#pragma mark - scene
/// 异步添加场景,添加完成后需要将场景设置为 currentScene 才可以生效
/// @param scene 被添加的场景
/// @param completion 添加完成的回调
- (void)addScene:(FUScene *)scene completion:(nullable void(^)(BOOL success))completion;
/// 移除场景,如果被移除的场景为当前场景,当前渲染效果也会失效。
/// @param scene 需要被移除的场景
/// @param completion 移除完成的回调
- (void)removeScene:(FUScene *)scene completion:(nullable void(^)(BOOL success))completion;
/// 替换场景,如果需要让新的场景生效,需要将其设置为 currentScene
/// @param scene 被替换的场景,为空时直接添加新的场景
/// @param newScene 新的场景,为空时直接移除被替换的场景
/// @param completion 替换成功的回调
- (void)replaceScene:(nullable FUScene *)scene withNewScene:(nullable FUScene *)newScene completion:(nullable void(^)(BOOL success))completion;
#pragma mark - internalCamera
/// 开启内部相机,相机配置请修改 internalCameraSetting 相关属性
/// @see FUInternalCameraSetting
- (void)startInternalCamera;
/// 关闭内部相机
- (void)stopInternalCamera;
#pragma mark - Record && capture
/// 开始录像
/// @param filePath 录像保存地址
+ (void)startRecordVideoWithFilePath:(NSString *)filePath;
/// 结束录像
/// @param complention 录制结束回调
+ (void)stopRecordVideoComplention:(void(^)(NSString *filePath))complention;
/// 获取单帧图像
+ (UIImage *)captureImage;
#pragma mark - renderWithInput
/// 核心渲染接口
/// @discussion 当贴纸、美颜、美型、美妆、3D场景与形象配置到 RenderKit之后调用该接口会把效果作用于输出的结果中。支持输入单纹理、纹理+imageBuffer、纹理+pixelBuffer、单imageBuffer、单pixelBuffer输出与输入相对应也可以支持只输出纹理、或渲染到当前FBO。
/// @param input 输入图像,类型为 FURenderInput
/// @return 输出图像结果,类型为 FURenderOutput
- (FURenderOutput *)renderWithInput:(FURenderInput *)input;
#pragma mark - Performance
/// 当前设备性能等级
+ (FUDevicePerformanceLevel)devicePerformanceLevel;
/// 美妆效果覆盖开关,默认打开
/// @note 当多个包含美妆效果的 bundle 互相影响时可以调用该接口设置为 YES否则可以设为 NO
+ (void)setMakeupCoverResourceEnabled:(BOOL)enabled;
/// 动态调节质量开关
/// @param enabled YES / NO
/// @note 目前只用于美颜,开启时会自动动态调节
+ (void)setDynamicQualityControlEnabled:(BOOL)enabled;
/// 动态调节质量配置
/// @param params 详细说明:
/// key: 参考FUDynamicQualityParamKey
/// value 说明:
/// 1. 触发帧率低于该帧率时会触发动态调节大于0默认 25
/// 2. 变化速率大于0默认 1.7
/// 3. 变化平滑度大于0默认 2.5
+ (void)setDynamicQualityParams:(NSDictionary *)params;
/// ARMeshV2 开关
/// @note 建议高端机型打开
/// @note 目前版本不建议调用,建议使用 FUAIKit 的 setFaceAlgorithmConfig 接口设置
+ (void)setARMeshV2Enabled:(BOOL)enabled;
#pragma mark - Others
/// 获取证书里面的模块权限
/// @return code get i-th code, currently available for 0 and 1
+ (int)getModuleCode:(int)code;
/// 获取错误码
/// @return 错误码
+ (int)getSystemError;
/// 获取错误信息
/// @return 错误信息
+(NSString *)getSystemErrorString;
+ (int)profileGetNumTimers;
+ (long long)profileGetTimerAverage:(int)index;
/// 设置缓存目录,提升加载模型速度
/// @param directory 可读写目录路径
+ (void)setCacheDirectory:(NSString *)directory;
#pragma mark - frame time profile
/// 开启/关闭算法耗时统计功能,默认关闭
/// @param enable YES开启 NO关闭
+ (void)setFrameTimeProfileEnable:(BOOL)enable;
/// 设置算法耗时输出到控制台
+ (void)setFrameTimeProfileAutoReportToConsole;
/// 设置算法耗时输出到文件
/// @param filePath 文件路径
+ (void)setFrameTimeProfileAutoReportToFile:(NSString *_Nonnull)filePath;
/// 设置算法耗时打印间隔默认为300
/// @param interval 时间间隔
+ (void)setFrameTimeProfileReportInterval:(int)interval;
/// 开启/关闭算法耗时统计详细信息,默认关闭
/// @param enable YES开启 NO关闭
+ (void)setFrameTimeProfileReportDetailsEnable:(BOOL)enable;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,20 @@
//
// FURenderQueue.h
// FURenderKit
//
// Created by liuyang on 2022/6/8.
//
// 渲染队列,可以使用该队列处理单帧同步效果
//
#import "FUSerialQueue.h"
NS_ASSUME_NONNULL_BEGIN
@interface FURenderQueue : FUSerialQueue
+ (void)sync:(dispatch_block_t)block;
+ (void)async:(dispatch_block_t)block;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,18 @@
//
// FURenderableObject.h
// FURenderKit
//
// Created by liuyang on 2021/1/15.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface FURenderableObject : NSObject
@property (nonatomic, assign) BOOL enable;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,916 @@
//
// FURenderer.h
//
// Created by ly on 16/11/2.
// Copyright © 2016年 liuyang. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GLKit/GLKit.h>
#import "CNamaSDK.h"
typedef struct {
CVPixelBufferRef pixelBuffer;
GLuint bgraTextureHandle;
} FUOutput;
typedef enum {
FUFormatBGRABuffer = FU_FORMAT_BGRA_BUFFER,
FUFormatRGBABuffer = FU_FORMAT_RGBA_BUFFER,
FUFormatNV12Buffer = FU_FORMAT_NV12_BUFFER,
FUFormatI420Buffer = FU_FORMAT_I420_BUFFER,
FUFormatRGBATexture = FU_FORMAT_RGBA_TEXTURE,
} FUFormat;
typedef enum {
FURotationMode0 = FU_ROTATION_MODE_0,
FURotationMode90 = FU_ROTATION_MODE_90,
FURotationMode180 = FU_ROTATION_MODE_180,
FURotationMode270 = FU_ROTATION_MODE_270,
} FURotationMode;
__attribute__((visibility("default"))) @interface FURotatedImage : NSObject
@property void* mData;
@property int mWidth;
@property int mHeight;
- (instancetype)init;
@end
;
__attribute__((visibility("default"))) @interface FUAvatarInfo : NSObject {
@public
float landmarks[150];
float identity[75];
float expression[56];
float translation[3];
float rotation[4];
float rotationMode[1];
float pupilPos[2];
int isValid;
TAvatarInfo info;
}
@end
__attribute__((visibility("default"))) @interface FURenderer : NSObject
/**
获取 FURenderer 单例
@return FURenderer 单例
*/
+ (FURenderer*)shareRenderer;
/**
context切换
*/
- (void)setBackCurrentContext;
- (void)setUpCurrentContext;
/**
初始化接口1:
- 初始化 SDK并对 SDK 进行授权,在调用其他接口前必须要先进行初始化。
- 使用该接口进行初始化的话,需要在代码中配置 EAGLContext
环境,并且保证我们的接口是在同一个 EAGLContext 下调用的
@param data v3.bundle 对应的二进制数据地址
@param dataSize v3.bundle 数据的字节数
@param ardata 该参数已舍弃,传 NULL 即可
@param package 密钥数组必须配置好密钥SDK 才能正常工作
@param size 密钥数组大小
@return 初始化结果为0则初始化失败大于0则初始化成功
*/
- (int)setupWithData:(void*)data
dataSize:(int)dataSize
ardata:(void*)ardata
authPackage:(void*)package
authSize:(int)size;
/**
初始化接口2
- 初始化 SDK并对 SDK 进行授权,在调用其他接口前必须要先进行初始化。
- 与 初始化接口1 相比此接口新增 shouldCreate
参数如果传入YES我们将在内部创建并持有一个 EAGLContext无需外部再创建
EAGLContext 环境。
@param data v3.bundle 对应的二进制数据地址
@param dataSize v3.bundle 数据的字节数
@param ardata 该参数已废弃,传 NULL 即可
@param package 密钥数组必须配置好密钥SDK 才能正常工作
@param size 密钥数组大小
@param shouldCreate 如果设置为 YES我们会在内部创建并持有一个
EAGLContextOpenGL相关操作建议所用OC层接口
(注OC接口会切换到内部创建的EAGLContext上执行防止多EAGLContext异常问题)
@return 初始化结果为0则初始化失败大于0则初始化成功
*/
- (int)setupWithData:(void*)data
dataSize:(int)dataSize
ardata:(void*)ardata
authPackage:(void*)package
authSize:(int)size
shouldCreateContext:(BOOL)shouldCreate;
/**
初始化接口3
- 初始化SDK并对 SDK 进行授权,在调用其他接口前必须要先进行初始化。
- 与 初始化接口2 相比改为通过 v3.bundle
的文件路径进行初始化,并且删除了废弃的 ardata 参数。
@param v3path v3.bundle 对应的文件路径
@param package 密钥数组必须配置好密钥SDK 才能正常工作
@param size 密钥数组大小
@param shouldCreate 如果设置为 YES我们会在内部创建并持有一个
EAGLContextOpenGL相关操作建议所用OC层接口
(注OC接口会切换到内部创建的EAGLContext上执行防止多EAGLContext异常问题)
@return 初始化结果为0则初始化失败大于0则初始化成功
*/
- (int)setupWithDataPath:(NSString*)v3path
authPackage:(void*)package
authSize:(int)size
shouldCreateContext:(BOOL)shouldCreate;
/**
初始化接口4
- 初始化SDK采用离线鉴权方式
@param v3path v3.bundle 对应的文件路径
@param offLinePath offLineBundle.bundle 离线鉴权包路径
@param package 密钥数组必须配置好密钥SDK 才能正常工作
@param size 密钥数组大小
@param shouldCreate 如果设置为 YES我们会在内部创建并持有一个
EAGLContextOpenGL相关操作建议所用OC层接口
(注OC接口会切换到内部创建的EAGLContext上执行防止多EAGLContext异常问题)
@return 第一次鉴权成功后的文件
*/
- (NSData*)setupLocalWithV3Path:(NSString*)v3path
offLinePath:(NSString*)offLinePath
authPackage:(void*)package
authSize:(int)size
shouldCreateContext:(BOOL)shouldCreate;
/**
视频处理接口1
- 将 items 中的道具绘制到 pixelBuffer 中
@param pixelBuffer 图像数据支持的格式为BGRA、YUV420SP
@param frameid 当前处理的视频帧序数,每次处理完对其进行加 1 操作,不加 1
将无法驱动道具中的特效动画
@param items 包含多个道具句柄的 int 数组,包括普通道具、美颜道具、手势道具等
@param itemCount 句柄数组中包含的句柄个数
@return 被处理过的的图像数据,返回 nil 视频处理失败
*/
- (CVPixelBufferRef)renderPixelBuffer:(CVPixelBufferRef)pixelBuffer
withFrameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount;
/**
视频处理接口2
- 将 items 中的道具绘制到 pixelBuffer 中
- 与 视频处理接口1 相比新增 flip 参数,将该参数设置为 YES
可使道具做水平镜像翻转
@param pixelBuffer 图像数据支持的格式为BGRA、YUV420SP
@param frameid 当前处理的视频帧序数,每次处理完对其进行加 1 操作,不加 1
将无法驱动道具中的特效动画
@param items 包含多个道具句柄的 int 数组
@param itemCount 句柄数组中包含的句柄个数
@param flip 道具镜像使能,如果设置为 YES 可以将道具做镜像操作
@return 被处理过的的图像数据,返回 nil 视频处理失败
*/
- (CVPixelBufferRef)renderPixelBuffer:(CVPixelBufferRef)pixelBuffer
withFrameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount
flipx:(BOOL)flip;
/**
视频处理接口3
- 将 items 中的道具绘制到 pixelBuffer 中
- 与 视频处理接口2 相比新增 customSize 参数,可以自定义输出分辨率
@param pixelBuffer 图像数据支持的格式为BGRA、YUV420SP
@param frameid 当前处理的视频帧序数,每次处理完对其进行加 1 操作,不加 1
将无法驱动道具中的特效动画
@param items 包含多个道具句柄的 int 数组
@param itemCount 句柄数组中包含的句柄个数
@param flip 道具镜像使能,如果设置为 YES 可以将道具做镜像操作
@param customSize 自定义输出的分辨率目前仅支持BGRA格式
@return 被处理过的的图像数据,返回 nil 视频处理失败
*/
- (CVPixelBufferRef)renderPixelBuffer:(CVPixelBufferRef)pixelBuffer
withFrameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount
flipx:(BOOL)flip
customSize:(CGSize)customSize NS_AVAILABLE_IOS(8_0);
/**
视频处理接口4
- 将 items 中的道具绘制到一个新的 pixelBuffer 中,输出与输入不是同一个
pixelBuffer
@param pixelBuffer 图像数据支持的格式为BGRA、YUV420SP
@param frameid 当前处理的视频帧序数,每次处理完对其进行加 1 操作,不加 1
将无法驱动道具中的特效动画
@param items 包含多个道具句柄的 int 数组,包括普通道具、美颜道具、手势道具等
@param itemCount 句柄数组中包含的句柄个数
@return 被处理过的的图像数据,返回 nil 视频处理失败
*/
- (CVPixelBufferRef)renderToInternalPixelBuffer:(CVPixelBufferRef)pixelBuffer
withFrameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount
NS_AVAILABLE_IOS(8_0);
/**
视频处理接口5
- 将 items 中的道具绘制到 textureHandle 及 pixelBuffer 中
- 该接口适用于可同时输入 GLES texture 及 pixelBuffer 的用户,这里的
pixelBuffer 主要用于 CPU 上的人脸检测,如果只有 GLES texture 此接口将无法工作。
@param pixelBuffer 图像数据支持的格式为BGRA、YUV420SP用于人脸识别
@param textureHandle 用户当前 EAGLContext 下的 textureID用于图像处理
@param frameid 当前处理的视频帧序数,每次处理完对其进行加 1 操作,不加 1
将无法驱动道具中的特效动画
@param items 包含多个道具句柄的 int 数组,包括普通道具、美颜道具、手势道具等
@param itemCount 句柄数组中包含的句柄个数
@return 被处理过的的图像数据
*/
- (FUOutput)renderPixelBuffer:(CVPixelBufferRef)pixelBuffer
bgraTexture:(GLuint)textureHandle
withFrameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount NS_AVAILABLE_IOS(8_0);
/**
视频处理接口6
- 将items中的道具绘制到 textureHandle 及 pixelBuffer 中
- 与 视频处理接口5 相比新增 flip 参数,将该参数设置为 YES
可使道具做水平镜像翻转。
@param pixelBuffer 图像数据支持的格式为BGRA、YUV420SP用于人脸识别
@param textureHandle 用户当前 EAGLContext 下的 textureID用于图像处理
@param frameid 当前处理的视频帧序数,每次处理完对其进行加 1 操作,不加 1
将无法驱动道具中的特效动画
@param items 包含多个道具句柄的int数组包括普通道具、美颜道具、手势道具等
@param itemCount 句柄数组中包含的句柄个数
@param flip 道具镜像使能,如果设置为 YES 可以将道具做镜像操作
@return 被处理过的的图像数据
*/
- (FUOutput)renderPixelBuffer:(CVPixelBufferRef)pixelBuffer
bgraTexture:(GLuint)textureHandle
withFrameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount
flipx:(BOOL)flip NS_AVAILABLE_IOS(8_0);
/**
视频处理接口7
- 将items中的道具绘制到 textureHandle 及 pixelBuffer 中
- 与 视频处理接口6 相比新增 customSize 参数,可以自定义输出分辨率。
@param pixelBuffer 图像数据支持的格式为BGRA、YUV420SP用于人脸识别
@param textureHandle 用户当前 EAGLContext 下的 textureID用于图像处理
@param frameid 当前处理的视频帧序数,每次处理完对其进行加 1 操作,不加 1
将无法驱动道具中的特效动画
@param items 包含多个道具句柄的int数组包括普通道具、美颜道具、手势道具等
@param itemCount 句柄数组中包含的句柄个数
@param flip 道具镜像使能,如果设置为 YES 可以将道具做镜像操作
@param customSize 自定义输出的分辨率目前仅支持BGRA格式
@return 被处理过的的图像数据
*/
- (FUOutput)renderPixelBuffer:(CVPixelBufferRef)pixelBuffer
bgraTexture:(GLuint)textureHandle
withFrameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount
flipx:(BOOL)flip
customSize:(CGSize)customSize NS_AVAILABLE_IOS(8_0);
/**
视频处理接口8
-
该接口不包含人脸检测功能,只能对图像做美白、红润、滤镜、磨皮操作,不包含瘦脸及大眼等美型功能。
@param pixelBuffer 图像数据支持的格式为BGRA、YUV420SP
@param item 美颜道具句柄
@return 被处理过的的图像数据 返回 nil 视频处理失败
*/
- (CVPixelBufferRef)beautifyPixelBuffer:(CVPixelBufferRef)pixelBuffer
withBeautyItem:(int)item;
/**
视频处理接口9
- 将 items 中的道具绘制到 YUV420P 图像中
@param y Y帧图像地址
@param u U帧图像地址
@param v V帧图像地址
@param ystride Y帧stride
@param ustride U帧stride
@param vstride V帧stride
@param width 图像宽度
@param height 图像高度
@param frameid 当前处理的视频帧序数,每次处理完对其进行加 1 操作,不加 1
将无法驱动道具中的特效动画
@param items 包含多个道具句柄的 int 数组,包括普通道具、美颜道具、手势道具等
@param itemCount 句柄数组中包含的句柄个数
*/
- (void)renderFrame:(uint8_t*)y
u:(uint8_t*)u
v:(uint8_t*)v
ystride:(int)ystride
ustride:(int)ustride
vstride:(int)vstride
width:(int)width
height:(int)height
frameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount;
/**
视频处理接口10
- 将 items 中的道具绘制到 YUV420P 图像中
- 与 视频处理接口9 相比新增 flip 参数,将该参数设置为 YES
可使道具做水平镜像翻转
@param y Y帧图像地址
@param u U帧图像地址
@param v V帧图像地址
@param ystride Y帧stride
@param ustride U帧stride
@param vstride V帧stride
@param width 图像宽度
@param height 图像高度
@param frameid 当前处理的视频帧序数,每次处理完对其进行加 1 操作,不加 1
将无法驱动道具中的特效动画
@param items 包含多个道具句柄的 int 数组,包括普通道具、美颜道具、手势道具等
@param itemCount 句柄数组中包含的句柄个数
@param flip 道具镜像使能,如果设置为 YES 可以将道具做镜像操作
*/
- (void)renderFrame:(uint8_t*)y
u:(uint8_t*)u
v:(uint8_t*)v
ystride:(int)ystride
ustride:(int)ustride
vstride:(int)vstride
width:(int)width
height:(int)height
frameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount
flipx:(BOOL)flip;
/**
视频处理接口11
- 将 items 中的道具绘制到 pixelBuffer 中
- 与 视频处理接口2 相比新增 masks 参数,用来指定 items
中的道具画在多人中的哪一张脸上
@param pixelBuffer 图像数据支持的格式为BGRA、YUV420SP
@param frameid 当前处理的视频帧序数,每次处理完对其进行加 1 操作,不加 1
将无法驱动道具中的特效动画
@param items 包含多个道具句柄的 int 数组
@param itemCount 句柄数组中包含的句柄个数
@param flip 道具镜像使能,如果设置为 YES 可以将道具做镜像操作
@param masks 指定items中的道具画在多张人脸中的哪一张脸上的 int 数组,其长度要与
items 长度一致,
masks中的每一位与items中的每一位道具一一对应。使用方法为要使某一个道具画在检测到的第一张人脸上
对应的int值为 "2的0次方"画在第二张人脸上对应的int值为
“2的1次方”第三张人脸对应的int值为 “2的2次方” 以此类推。例masks =
{pow(2,0),pow(2,1),pow(2,2)....},值得注意的是美颜道具对应的int值为 0。
@return 被处理过的的图像数据,返回 nil 视频处理失败
*/
- (CVPixelBufferRef)renderPixelBuffer:(CVPixelBufferRef)pixelBuffer
withFrameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount
flipx:(BOOL)flip
masks:(void*)masks;
/**
视频处理接口12 注意:目前仅支持背景分割场景
- 将 items 中的道具绘制到 pixelBuffer 中
- 与 视频处理接口2 相比新增 customSize 参数,可以自定义输出分辨率
@param pixelBuffer 图像数据支持的格式为BGRA、YUV420SP
@param frameid 当前处理的视频帧序数,每次处理完对其进行加 1 操作,不加 1
将无法驱动道具中的特效动画
@param items 包含多个道具句柄的 int 数组
@param itemCount 句柄数组中包含的句柄个数
@param flip 道具镜像使能,如果设置为 YES 可以将道具做镜像操作
@param customSize 自定义输出的分辨率目前仅支持BGRA格式
@param useAlpha 是否带道具透明通道if useAlpha = NO,RGBA 数据alpha
会被强制设置为1其他视频处理接口皆为该模式
@return 被处理过的的图像数据,返回 nil 视频处理失败
*/
- (CVPixelBufferRef)renderPixelBuffer:(CVPixelBufferRef)pixelBuffer
withFrameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount
flipx:(BOOL)flip
customSize:(CGSize)customSize
useAlpha:(BOOL)useAlpha;
- (int)renderItems:(void*)inPtr
inFormat:(FUFormat)inFormat
outPtr:(void*)outPtr
outFormat:(FUFormat)outFormat
width:(int)width
height:(int)height
frameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount
flipx:(BOOL)flip;
- (int)renderBundles:(void*)inPtr
inFormat:(FUFormat)inFormat
outPtr:(void*)outPtr
outFormat:(FUFormat)outFormat
width:(int)width
height:(int)height
frameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount;
- (int)renderBundlesSplitView:(void*)inPtr
inFormat:(FUFormat)inFormat
outPtr:(void*)outPtr
outFormat:(FUFormat)outFormat
width:(int)width
height:(int)height
frameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount
splitViewInfoPtr:(TSplitViewInfo*)splitViewInfoPtr;
- (CVPixelBufferRef)renderBundlesWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
withFrameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount;
- (CVPixelBufferRef)
renderBundlesSplitViewWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
withFrameId:(int)frameid
items:(int*)items
itemCount:(int)itemCount
splitViewInfoPtr:(TSplitViewInfo*)splitViewInfoPtr;
- (void)setInputCameraMatrix:(int)flip_x
flip_y:(int)flip_y
rotate_mode:(int)rotate_mode;
- (void)setOutputResolution:(int)w h:(int)h;
/*
@return 1代表成功0代表失败
*/
- (int)rotateImage:(FURotatedImage*)outImage
inPtr:(void*)inPtr
inFormat:(FUFormat)inFormat
width:(int)width
height:(int)height
rotationMode:(FURotationMode)rotationMode
flipX:(BOOL)flipX
flipY:(BOOL)flipY;
/**
resize视频图像目前仅支持BGRA格式的pixelBuffer
@param pixelBuffer BGRA格式的pixelBuffer
@param resizeSize resizeSize
@return resizeSize之后的pixelBuffer
*/
- (CVPixelBufferRef)resizePixelBuffer:(CVPixelBufferRef)pixelBuffer
resizeSize:(CGSize)resizeSize NS_AVAILABLE_IOS(8_0);
/**
通过texture获取指定大小与格式的pixelBuffer
@param texture rgba texture
@param textureSize texture 尺寸
@param outPutSize 输出的pixelBuffer的尺寸
@param outputFormat
输出的pixelBuffer的格式接受的参数有两个分别为FU_FORMAT_NV12_BUFFER、FU_FORMAT_BGRA_BUFFER
@return 从texture获取到的指定大小与格式的pixelBuffer
*/
- (CVPixelBufferRef)getPixelBufferFromTexture:(int)texture
textureSize:(CGSize)textureSize
outputSize:(CGSize)outPutSize
outputFormat:(int)outputFormat
NS_AVAILABLE_IOS(8_0);
/**
切换摄像头时需调用的接口:
- 切换摄像头时需要调用该接口,我们会在内部重置人脸检测的一些状态
*/
+ (void)onCameraChange;
/**
销毁所有gl资源时需调用的接口
- 销毁所有gl资源时需要调用该接口
*/
+ (void)ReleaseGLResources;
/**
销毁所有道具时需调用的接口:
- 销毁所有道具时需要调用该接口我们会在内部销毁每个指令中的OpenGL资源
*/
+ (void)OnDeviceLost;
/**
销毁所有道具时需调用的接口:
- 销毁所有道具时需要调用该接口我们仅销毁Cpu资源
*/
+ (void)OnDeviceLostSafe;
/**
通过道具二进制文件创建道具:
- 通过道具二进制文件创建道具句柄
@param data 道具二进制文件
@param size 文件大小
@return 创建的道具句柄
*/
+ (int)createItemFromPackage:(void*)data size:(int)size;
/**
通过道具文件路径创建道具:
- 通过道具文件路径创建道具句柄
@param path 道具文件路径
@return 创建的道具句柄
*/
+ (int)itemWithContentsOfFile:(NSString*)path;
/**
销毁单个道具:
- 通过道具句柄销毁道具,并释放相关资源
- 销毁道具后请将道具句柄设为 0 ,以避免 SDK 使用无效的句柄而导致程序出错。
@param item 道具句柄
*/
+ (void)destroyItem:(int)item;
/**
销毁所有道具:
- 销毁全部道具,并释放相关资源
- 销毁道具后请将道具句柄数组中的句柄设为 0 ,以避免 SDK
使用无效的句柄而导致程序出错。
*/
+ (void)destroyAllItems;
/**
加载AI能力模型bundle
@param data AI能力模型二进制文件
@param size 文件大小
@param type AI能力类型,定义在FUAITYPE中
@return 加载成功返回1否则返回0
*/
+ (int)loadAIModelFromPackage:(void*)data size:(int)size aitype:(FUAITYPE)type;
/**
在不需要的时候释放AI能力模型bundle
@param type AI能力类型,定义在FUAITYPE中
@return 释放成功返回1否则返回0
*/
+ (int)releaseAIModel:(FUAITYPE)type;
/**
获取AI能力模型是否加载。
@param type AI能力类型,定义在FUAITYPE中
@return 已加载返回1否则返回0
*/
+ (int)isAIModelLoaded:(FUAITYPE)type;
/**
为道具设置参数:
@param item 道具句柄
@param name 参数名
@param value 参数值:只支持 NSString 、 NSNumber 两种数据类型
@return 执行结果:返回 0 代表设置失败,大于 0 表示设置成功
*/
+ (int)itemSetParam:(int)item withName:(NSString*)name value:(id)value;
/**
为道具设置参数:
@param item 道具句柄
@param name 参数名
@param value 参数值double 数组
@param length 参数值double 数组长度
@return 执行结果:返回 0 代表设置失败,大于 0 表示设置成功
*/
+ (int)itemSetParamdv:(int)item
withName:(NSString*)name
value:(double*)value
length:(int)length;
/**
从道具中获取 double 数组:
@param item 道具句柄
@param name 参数名
@param value 参数值double 数组
@param length 参数值double 数组长度
@return 执行结果:返回获取的数组长度
*/
+ (int)itemGetParamdv:(int)item
withName:(NSString*)name
buffer:(double*)buffer
length:(int)length;
/**
从道具中获取 float 数组:
@param item 道具句柄
@param name 参数名
@param value 参数值float 数组
@param length 参数值float 数组长度
@return 执行结果:返回获取的数组长度
*/
+ (int)itemGetParamfv:(int)item
withName:(NSString*)name
buffer:(float*)buffer
length:(int)length;
/**
从道具中获取 double 型参数值:
@param item 道具句柄
@param name 参数名
@return 参数值
*/
+ (double)getDoubleParamFromItem:(int)item withName:(NSString*)name;
/**
从道具中获取 NSString 型参数值:
@param item 道具句柄
@param name 参数名
@return 参数值
*/
+ (NSString*)getStringParamFromItem:(int)item withName:(NSString*)name;
+ (int)itemSetParamu8v:(int)item
withName:(NSString*)name
buffer:(void*)buffer
size:(int)size;
+ (int)itemGetParamu8v:(int)item
withName:(NSString*)name
buffer:(void*)buffer
size:(int)size;
+ (int)itemSetParamu64:(int)item
withName:(NSString*)name
value:(unsigned long long)value;
/**
判断是否检测到人脸:
@return 检测到的人脸个数,返回 0 代表没有检测到人脸
*/
+ (int)isTracking;
/**
判断SDK是否已经初始化
@return 返回1代表初始化返回0代表未初始化
*/
+ (int)isLibraryInit;
/**
开启多人检测模式:
- 开启多人检测模式,最多可同时检测 8 张人脸
@param maxFaces 设置多人模式开启的人脸个数,最多支持 8 个
@return 上一次设置的人脸个数
*/
+ (int)setMaxFaces:(int)maxFaces;
/**
人脸信息跟踪:
- 该接口只对人脸进行检测,如果程序中没有运行过视频处理接口( 视频处理接口8
除外),则需要先执行完该接口才能使用 获取人脸信息接口 来获取人脸信息
@param inputFormat 输入图像格式FU_FORMAT_BGRA_BUFFER 或 FU_FORMAT_NV12_BUFFER
@param inputData 输入的图像 bytes 地址
@param width 图像宽度
@param height 图像高度
@return 检测到的人脸个数,返回 0 代表没有检测到人脸
*/
+ (int)trackFace:(int)inputFormat
inputData:(void*)inputData
width:(int)width
height:(int)height;
+ (int)trackFaceWithTongue:(int)inputFormat
inputData:(void*)inputData
width:(int)width
height:(int)height;
/**
获取人脸信息:
- 在程序中需要先运行过视频处理接口( 视频处理接口8 除外)或 人脸信息跟踪接口
后才能使用该接口来获取人脸信息;
-
该接口能获取到的人脸信息与我司颁发的证书有关,普通证书无法通过该接口获取到人脸信息;
- 具体参数及证书要求如下:
landmarks: 2D人脸特征点返回值为75个二维坐标长度75*2
证书要求: LANDMARK证书、AVATAR证书
landmarks_ar: 3D人脸特征点返回值为75个三维坐标长度75*3
证书要求: AVATAR证书
rotation: 人脸三维旋转返回值为旋转四元数长度4
证书要求: LANDMARK证书、AVATAR证书
translation: 人脸三维位移返回值一个三维向量长度3
证书要求: LANDMARK证书、AVATAR证书
eye_rotation: 眼球旋转,返回值为旋转四元数,长度4
证书要求: LANDMARK证书、AVATAR证书
rotation_raw: 人脸三维旋转不考虑屏幕方向返回值为旋转四元数长度4
证书要求: LANDMARK证书、AVATAR证书
expression: 表情系数长度46
证书要求: AVATAR证书
projection_matrix: 投影矩阵长度16
证书要求: AVATAR证书
face_rect: 人脸矩形框,返回值为(xmin,ymin,xmax,ymax)长度4
证书要求: LANDMARK证书、AVATAR证书
rotation_mode: 人脸朝向0-3分别对应手机四种朝向长度1
证书要求: LANDMARK证书、AVATAR证书
@param faceId 被检测的人脸 ID ,未开启多人检测时传 0
,表示检测第一个人的人脸信息;当开启多人检测时,其取值范围为 [0 ~ maxFaces-1]
,取其中第几个值就代表检测第几个人的人脸信息
@param name 人脸信息参数名: "landmarks" , "eye_rotation" , "translation" ,
"rotation" ....
@param pret 作为容器使用的 float 数组指针,获取到的人脸信息会被直接写入该 float
数组。
@param number float 数组的长度
@return 返回 1 代表获取成功,返回 0 代表获取失败
*/
+ (int)getFaceInfo:(int)faceId
name:(NSString*)name
pret:(float*)pret
number:(int)number;
+ (int)getFaceInfoRotated:(int)faceId
name:(NSString*)name
pret:(float*)pret
number:(int)number;
/**
获取正在跟踪人脸的标识符用于在SDK外部对多人情况下的不同人脸进行区别。
@param faceId人脸编号表示识别到的第 x
张人脸从0开始到n-1,n为当前跟踪到的人脸数。
@return 人脸的标识符 [1,maxFaces]
*/
+ (int)getFaceIdentifier:(int)faceId;
/**
将普通道具绑定到avatar道具
- 该接口主要应用于 P2A 项目中,将普通道具绑定到 avatar
道具上,从而实现道具间的数据共享;
- 在视频处理时只需要传入 avatar 道具句柄,普通道具也会和 avatar
一起被绘制出来。
- 普通道具又分免费版和收费版,免费版有免费版对应的 contract
文件,收费版有收费版对应的 contract 文件,当绑定时需要同时传入这些 contracts
文件才能绑定成功。
- 注意: contract 的创建和普通道具创建方法一致
@param avatarItem avatar 道具句柄
@param items 需要被绑定到 avatar 道具上的普通道具的句柄数组
@param itemsCount 句柄数组包含的道具句柄个数
@param contracts contract 道具的句柄数组
@param contractsCount contracts 数组中 contract 道具句柄的个数
@return 被绑定到 avatar 道具上的普通道具个数
*/
+ (int)avatarBindItems:(int)avatarItem
items:(int*)items
itemsCount:(int)itemsCount
contracts:(int*)contracts
contractsCount:(int)contractsCount
DEPRECATED_MSG_ATTRIBUTE("use bindItems:items:itemsCount: instead");
/**
将普通道具从avatar道具上解绑
- 该接口可以将普通道具从 avatar
道具上解绑,主要应用场景为切换道具或去掉某个道具
@param avatarItem avatar 道具句柄
@param items 需要从 avatar 道具上的解除绑定的普通道具的句柄数组
@param itemsCount 句柄数组包含的道具句柄个数
@return 从 avatar 道具上解除绑定的普通道具个数
*/
+ (int)avatarUnbindItems:(int)avatarItem
items:(int*)items
itemsCount:(int)itemsCount
DEPRECATED_MSG_ATTRIBUTE("use unBindItems:items:itemsCount: instead");
/**
绑定道具:
-
该接口可以将一些普通道具绑定到某个目标道具上,从而实现道具间的数据共享,在视频处理时只需要传入该目标道具句柄即可
@param item 目标道具句柄
@param items 需要被绑定到目标道具上的其他道具的句柄数组
@param itemsCount 句柄数组包含的道具句柄个数
@return 被绑定到目标道具上的普通道具个数
*/
+ (int)bindItems:(int)item items:(int*)items itemsCount:(int)itemsCount;
/**
解绑道具:
- 该接口可以将一些普通道具从某个目标道具上解绑
@param item 目标道具句柄
@param items 需要从目标道具上解除绑定的普通道具的句柄数组
@param itemsCount 句柄数组包含的道具句柄个数
@return 被绑定到目标道具上的普通道具个数
*/
+ (int)unBindItems:(int)item items:(int*)items itemsCount:(int)itemsCount;
/**
解绑所有道具:
- 该接口可以解绑绑定在目标道具上的全部道具
@param item 目标道具句柄
@return 从目标道具上解除绑定的普通道具个数
*/
+ (int)unbindAllItems:(int)item;
/**
获取 SDK 版本信息:
@return 版本信息
*/
+ (NSString*)getVersion;
+ (void)setDefaultRotationMode:(int)mode;
+ (void)setDeviceOrientation:(int)orientation;
+ (int)getCurrentRotationMode;
+ (int)setMultiSamples:(int)samples;
+ (void)setAsyncTrackFaceEnable:(int)enable;
+ (void)setTongueTrackingEnable:(int)enable;
+ (int)loadTongueModel:(void*)model size:(int)size;
+ (int)SetLoadQuality:(int)quality;
/**
统计接口调用次数
@param 接口名称
@return 返回 1 代表调用成功,返回 0 代表代表失败
**/
+ (int)authCountWithAPIName:(NSString*)name;
/**
释放nama资源
*/
+ (void)namaLibDestroy;
+ (void)humanProcessorReset;
/**
prepare GL resource for a list of items in advance
This function needs a GLES 2.0+ context.
@param items the list of items
@param itemCount the number of items
*/
- (void)prepareGLResource:items:(int*)items itemCount:(int)itemCount;
/**
check prepare gl resource is ready.
1 for ready prepared, 0 false.
@param items the list of items
@param itemCount the number of items
*/
- (int)isGLPrepared:items:(int*)items itemCount:(int)itemCount;
/**
check gl error
@return OpenGL error information, 0 for no error
*/
+ (int)checkGLError;
@end

View File

@@ -0,0 +1,179 @@
//
// FUScene.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/11/16.
//
#import <Foundation/Foundation.h>
#import "FUBackground.h"
#import "FUCustomBackground.h"
#import "FULight.h"
#import "FUSceneCamera.h"
#import "FUAvatar.h"
#import "FUCameraAnimation.h"
#import "FUAIConfig.h"
#import "FURenderableObject.h"
@class FUScene;
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
FUProjectionModePerspective,
FUProjectionModeParallel,
} FUProjectionMode;
@protocol FUSceneDelegate <NSObject>
- (void)scene:(FUScene *)scene AIConfigDidUpdate:(FUAIConfig *)AIConfig;
@end
@interface FUScene : FURenderableObject
@property (nonatomic, weak) id<FUSceneDelegate> delegate;
/// controller_config.bundle 文件路径,默认为 FURenderKit 初始化时设置的 controller_config 路径,用户可以通过修改该参数修改该路径。
@property (nonatomic, copy, readonly) NSString *controllerConfigPath;
/// 背景道具
@property (nonatomic, strong) FUBackground *background;
/// 背景颜色,如果设置了背景颜色,背景道具自动失效
@property (nonatomic, strong) UIColor *backgroundColor;
/// 机位道具
@property (nonatomic, strong) FUSceneCamera *sceneCamera;
/// 是否使用 orthogonal projection, 默认为 perspective projection
@property (nonatomic, assign) BOOL enableOrthogonalProjection;
@property (nonatomic, assign) float renderFov;
@property (nonatomic, assign) float renderOrthSize;
@property (nonatomic, assign) double znear;
@property (nonatomic, assign) double zfar;
/// 光照道具
@property (nonatomic, strong) FULight *light;
@property (nonatomic, assign) BOOL enableLowQualityLighting;
@property (nonatomic, assign) BOOL enableBloom;
/// 阴影开关
@property (nonatomic, assign) BOOL enableShadow;
@property (nonatomic, assign) BOOL enableRenderCameraImage;
@property (nonatomic, copy, readonly) NSArray<FUAvatar *> *avatars;
- (FUScene *)initWithControllerConfigPath:(NSString *)controllerConfigPath;
- (FUScene *)initWithControllerConfigPath:(NSString *)controllerConfigPath litemListJson:(NSString *)litemListJson;
#pragma mark - Avatar
- (BOOL)addAvatar:(FUAvatar *)avatar;
- (void)addAvatar:(FUAvatar *)avatar completion:(void(^)(BOOL result))completion;
- (void)removeAvatar:(FUAvatar *)avatar;
- (void)removeAvatar:(FUAvatar *)avatar completion:(void(^)(void))completion;
- (BOOL)replaceAvatar:(FUAvatar *)avatar withNewAvatar:(FUAvatar *)newAvatar;
- (void)replaceAvatar:(FUAvatar *)avatar withNewAvatar:(FUAvatar *)newAvatar compoletion:(void(^)(BOOL result))completion;
@end
@interface FUScene (AIConfig)
@property (nonatomic, strong, readonly) FUAIConfig *AIConfig;
@end
@interface FUScene (Animation)
@property (nonatomic, assign) BOOL enableCustomAnimationTime;
@property (nonatomic, assign) float customAnimationTime;
@property (nonatomic, assign) BOOL pauseSystemTimeUpdate;
@property (nonatomic, assign) BOOL enableCameraAnimation;
@property (nonatomic, assign) BOOL enableCameraAnimationLerp;
/// 相机动画列表
@property (nonatomic, copy, readonly) NSArray<FUCameraAnimation *> *cameraAnimations;
/// 当前正在播放的相机动画
@property (nonatomic, strong, readonly) FUCameraAnimation *currentCameraAnimation;
/// 添加动画,如果相机动画的 name 不为空,可以通过 name 查找或移除相机动画
/// @param cameraAnimation 动画
- (void)addCameraAnimation:(FUCameraAnimation *)cameraAnimation;
/// 通过动画名称查找相机动画
/// @param cameraAnimationName 相机动画名称
- (FUCameraAnimation *)cameraAnimationForName:(NSString *)cameraAnimationName;
/// 移除相机动画
/// @param cameraAnimation 相机动画
- (void)removeCameraAnimation:(FUCameraAnimation *)cameraAnimation;
/// 通过名称移除相机动画
/// @param cameraAnimationName 相机动画名称
- (void)removeCameraAnimationWithName:(NSString *)cameraAnimationName;
/// 播放相机动画
/// @param cameraAnimation 相机动画
/// @param playOnce YES 只播放一次NO 循环播放
/// @param transitionDuration 相机动画过度时间
- (void)playCameraAnimation:(nullable FUCameraAnimation *)cameraAnimation playOnce:(BOOL)playOnce transitionDuration:(float)transitionDuration;
/// 通过名称播放相机动画
/// @param cameraAnimationName 相机动画名称
/// @param playOnce YES 只播放一次NO 循环播放
/// @param transitionDuration 相机动画过度时间
- (void)playCameraAnimationWithName:(NSString *)cameraAnimationName playOnce:(BOOL)playOnce transitionDuration:(float)transitionDuration;
- (void)pauseCurrentCameraAnimation;
- (void)resumeCurrentCameraAnimation;
- (void)resetCurrentCameraAnimation;
- (float)getProgressForCameraAnimation:(FUCameraAnimation *)cameraAnimation;
- (float)getCurrentCameraAnimationTransitionProgress;
- (int)getFrameNumberForCameraAnimation:(FUCameraAnimation *)cameraAnimation;
@end
@interface FUScene (DynamicBone)
@property (nonatomic, assign) BOOL enableDynamicbone;
@end
@interface FUScene (Reflection)
/// 是否开启倒影(默认为 YES
@property (nonatomic, assign) BOOL enableReflection;
/// 设置倒影参数
/// @param transparency 倒影透明度 01
/// @param distance 倒影显示距离
/// (说明:倒影显示距离与倒影透明度的设置要合理搭配才能出来比较好的效果,两者呈正相关的关系)
- (BOOL)reflectionWithTransparency:(float)transparency distance:(float)distance;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,16 @@
//
// FUAvatarCamera.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/11/16.
//
#import "FUItem.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUSceneCamera : FUItem
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,22 @@
//
// FUSerialQueue.h
// FURenderKit
//
// Created by liuyang on 2021/9/1.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface FUSerialQueue : NSObject
+ (instancetype)queueWithLabel:(NSString *)label;
- (void)sync:(dispatch_block_t)block;
- (void)async:(dispatch_block_t)block;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,27 @@
//
// FUSetupConfig.h
// FURenderKit
//
// Created by liuyang on 2020/12/30.
//
#import <Foundation/Foundation.h>
#import "FUStruct.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUSetupConfig : NSObject
@property (nonatomic, assign) FUAuthPack authPack;
@property (nonatomic, copy) NSString *controllerPath;
@property (nonatomic, assign) BOOL enableCacheSceneShaderProgram;
@property (nonatomic, copy) NSString *controllerConfigPath;
//离线鉴权包路径
@property (nonatomic, copy) NSString *offLinePath;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,19 @@
//
// FUStagePropItem.h
// FURenderKit
//
// Created by Chen on 2021/1/12.
//
#import "FUItem.h"
NS_ASSUME_NONNULL_BEGIN
/**
* 无特殊设置项的道具直接使用此类实例化
* 包含 道具贴纸, AR面具、搞笑大头、表情识别、哈哈镜
*/
@interface FUSticker : FUItem
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,51 @@
//
// FUStickerContainer.h
// FURenderKit
//
// Created by Chen on 2021/1/18.
//
#import <Foundation/Foundation.h>
#import "FUSticker.h"
NS_ASSUME_NONNULL_BEGIN
/**
* 可叠加的道具可以放到这里
*/
@interface FUStickerContainer : NSObject
/**
* 添加 sticker移除当前已经加载的所有 sticker
* flag: YES 移除NO 叠加(不移除)
*/
//- (void)addSticker:(FUSticker *)item removeCurrent:(BOOL)flag;
/**
* 单个FUSticker操作接口
* 内部已经加锁,外部无需处理
*/
- (void)addSticker:(FUSticker *)sticker completion:(nullable void(^)(void))completion;
- (void)removeSticker:(FUSticker *)sticker completion:(nullable void(^)(void))completion;
//- (void)updateSticker:(FUSticker *)item;
//按照路径移除
- (void)removeStickerForPath:(NSString *)stickerPath completion:(nullable void(^)(void))completion;
- (void)replaceSticker:(FUSticker *)oldSticker withSticker:(FUSticker *)newSticker completion:(nullable void(^)(void))completion;
/**
* 多个FUSticker操作接口
* 内部已经加锁,外部无需处理
*/
- (void)addStickers:(NSArray <FUSticker *> *)stickers completion:(nullable void(^)(void))completion;
- (void)removeStickers:(NSArray <FUSticker *> *)stickers completion:(nullable void(^)(void))completion;
//- (void)updateStickers:(NSArray <FUSticker *> *)items;
- (void)removeStickersForPaths:(NSArray <NSString *> *)stickerPaths completion:(nullable void(^)(void))completion;
/**
* 移除所有已经添加的FUSticker
* 内部已经枷锁,外部无序需处理
*/
- (void)removeAllSticks;
- (NSArray *)allStickers;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,159 @@
//
// FUPosition.h
// FUAvatarSDK
//
// Created by ly-Mac on 2020/11/24.
//
#import <UIKit/UIKit.h>
/* Definition of `FU_EXTERN'. */
#if !defined(FU_EXTERN)
# if defined(__cplusplus)
# define FU_EXTERN extern "C" __attribute__((visibility("default")))
# else
# define FU_EXTERN extern __attribute__((visibility("default")))
# endif
#endif /* !defined(FU_EXTERN) */
/* Definition of `FU_EXTERN'. */
#if !defined(FU_INLINE)
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define FU_INLINE inline
# elif defined(__cplusplus)
# define FU_INLINE inline
# elif defined(__GNUC__)
# define FU_INLINE __inline__
# else
# define FU_INLINE
# endif
#endif
/* Definition of the `FU_BOXABLE'. */
#if defined(__has_attribute) && __has_attribute(objc_boxable)
# define FU_BOXABLE __attribute__((objc_boxable))
#else
# define FU_BOXABLE
#endif
struct FUAuthPack {
char *authData;
int authDataSize;
};
typedef struct FUAuthPack FUAuthPack;
FU_EXTERN FUAuthPack FUAuthPackMake(char *authData, int authDataSize);
#pragma mark - FUPosition
struct FUPosition {
float x;
float y;
float z;
};
typedef struct FU_BOXABLE FUPosition FUPosition;
FU_EXTERN FUPosition FUPositionMake(float x, float y, float z);
FU_EXTERN FUPosition FUPositionMakeWithX(FUPosition position, float x);
FU_EXTERN FUPosition FUPositionMakeWithY(FUPosition position, float y);
FU_EXTERN FUPosition FUPositionMakeWithZ(FUPosition position, float z);
FU_EXTERN BOOL FUPositionIsEqual(FUPosition position1, FUPosition position2);
#pragma mark - FUColor
struct FUColor {
double r;
double g;
double b;
double a;
};
typedef struct FUColor FUColor;
FU_EXTERN FUColor FUColorMake(double r, double g, double b, double a);
FU_EXTERN FUColor FUColorMakeWithR(FUColor color, double r);
FU_EXTERN FUColor FUColorMakeWithG(FUColor color, double g);
FU_EXTERN FUColor FUColorMakeWithB(FUColor color, double b);
FU_EXTERN FUColor FUColorMakeWithA(FUColor color, double a);
FU_EXTERN FUColor FUColorMakeWithUIColor(UIColor *color);
FU_EXTERN BOOL FUColorIsEqual(FUColor color1, FUColor color2);
#pragma mark - FURGBColor
struct FURGBColor {
float r;
float g;
float b;
};
typedef struct FU_BOXABLE FURGBColor FURGBColor;
FU_EXTERN FURGBColor FURGBColorMake(float r, float g, float b);
FU_EXTERN FURGBColor FURGBColorMakeWithR(FURGBColor color, float r);
FU_EXTERN FURGBColor FURGBColorMakeWithG(FURGBColor color, float g);
FU_EXTERN FURGBColor FURGBColorMakeWithB(FURGBColor color, float b);
FU_EXTERN FURGBColor FURGBColorMakeWithUIColor(UIColor *color);
FU_EXTERN FURGBColor FURGBColorMakeWithNSData(NSData *data);
FU_EXTERN BOOL FURGBColorIsEqual(FURGBColor color1, FURGBColor color2);
#pragma mark - FUBlendshape
struct FUBlendshape {
float *expression;
int expressionCount;
};
typedef struct FUBlendshape FUBlendshape;
FU_EXTERN FUBlendshape FUBlendshapeMake(float *expression, int expressionCount);
#pragma mark - FUBlendshapeWeight
struct FUBlendshapeWeight {
float *expressionWeight;
int expressionCount;
};
typedef struct FUBlendshapeWeight FUBlendshapeWeight;
FU_EXTERN FUBlendshapeWeight FUBlendshapeWeightMake(float *expressionWeight, int expressionCount);
struct FUShadowBias {
float uniformBias;
float normalBias;
};
typedef struct FUShadowBias FUShadowBias;
FU_EXTERN FUShadowBias FUShadowBiasMake(float uniformBias, float normalBias);
struct FUGestureID {
int left;
int right;
};
typedef struct FUGestureID FUGestureID;
struct FUPixelBufferInfo {
OSType format;
CGSize size;
size_t stride0;
size_t stride1;
size_t dataSize;
};
typedef struct FUPixelBufferInfo FUPixelBufferInfo;
FU_EXTERN FUPixelBufferInfo FUPixelBufferInfoMake(CVPixelBufferRef pixelBuffer);
struct FULandMark {
double *landMarks;
int landMarksCount;
};
typedef struct FULandMark FULandMark;
FU_EXTERN FULandMark FULandMarkMake(double *landMarks, int landMarksCount);
#pragma mark - LABColor
struct FULABColor {
float l;
float a;
float b;
};
typedef struct FULABColor FULABColor;
FU_EXTERN FULABColor FULABColorMake(float l, float a, float b);
FU_EXTERN FULABColor FULABColorMakeWithL(FULABColor color, float l);
FU_EXTERN FULABColor FULABColorMakeWithA(FULABColor color, float a);
FU_EXTERN FULABColor FULABColorMakeWithB(FULABColor color, float b);
FU_EXTERN BOOL FULABColorIsEqual(FULABColor color1, FULABColor color2);
extern FULABColor FULABColorInvalid;
extern FURGBColor FURGBColorInvalid;

View File

@@ -0,0 +1,25 @@
//
// FUVideoComponentDefines.h
// FUVideoComponent
//
// Created by 项林平 on 2022/5/16.
//
#ifndef FUVideoComponentDefines_h
#define FUVideoComponentDefines_h
/// 弱引用对象
#define FUWeakify(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object;
/// 强引用对象
#define FUStrongify(object) autoreleasepool{} __typeof__(object) object = weak##_##object;
/// 视频方向
typedef NS_ENUM(NSInteger, FUVideoOrientation) {
FUVideoOrientationPortrait = 0,
FUVideoOrientationLandscapeRight,
FUVideoOrientationUpsideDown,
FUVideoOrientationLandscapeLeft
};
#endif /* FUVideoComponentDefines_h */

View File

@@ -0,0 +1,55 @@
//
// FUVideoProcessor.h
// FUVideoComponent
//
// Created by 项林平 on 2022/5/27.
//
#import <AVFoundation/AVFoundation.h>
#import "FUVideoSettings.h"
#import "FUVideoReader.h"
#import "FUVideoWriter.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUVideoProcessor : NSObject
/// 视频帧编码前处理,不设置则直接编码
@property (nonatomic, copy) CVPixelBufferRef (^processingVideoBufferHandler)(CVPixelBufferRef videoPixelBuffer, CGFloat time);
/// 音频帧编码前处理,不设置则直接编码
@property (nonatomic, copy) CMSampleBufferRef (^processingAudioBufferHandler)(CMSampleBufferRef audioSampleBuffer);
/// 处理流程完成
@property (nonatomic, copy) void (^processingFinishedHandler)(void);
@property (nonatomic, strong, readonly) FUVideoReader *reader;
@property (nonatomic, strong, readonly) FUVideoWriter *writer;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithReadingURL:(NSURL *)readingURL
writingURL:(NSURL *)writingURL;
/// 初始化方法
/// @param readingURL 解码视频URL
/// @param readerSettings 解码设置nil时使用默认设置
/// @param writingURL 编码视频URL
/// @param writerSettings 编码设置nil时使用默认设置
- (instancetype)initWithReadingURL:(NSURL *)readingURL
readerSettings:(nullable FUVideoReaderSettings *)readerSettings
writingURL:(NSURL *)writingURL
writerSettings:(nullable FUVideoWriterSettings *)writerSettings;
- (void)startProcessing;
/// 内部会销毁解码器和编码器
- (void)cancelProcessing;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,78 @@
//
// FUVideoReader.h
// FUVideoComponent
//
// Created by 项林平 on 2022/5/9.
//
#import <AVFoundation/AVFoundation.h>
#import "FUVideoComponentDefines.h"
#import "FUVideoSettings.h"
NS_ASSUME_NONNULL_BEGIN
@protocol FUVideoReaderDelegate <NSObject>
@optional
/// 视频帧输出注意及时释放videoSampleBuffer
- (void)videoReaderDidOutputVideoSampleBuffer:(CMSampleBufferRef)videoSampleBuffer;
/// 音频帧输出注意及时释放audioSampleBuffer
- (void)videoReaderDidOutputAudioSampleBuffer:(CMSampleBufferRef)audioSampleBuffer;
/// 视频解码完成
- (void)videoReaderDidFinishVideoReading;
/// 音频解码完成
- (void)videoReaderDidFinishAudioReading;
/// 解码完成
- (void)videoReaderDidFinishReading;
@end
@interface FUVideoReader : NSObject
/// 是否正在解码
@property (nonatomic, assign, readonly) BOOL isReading;
/// 视频尺寸
@property (nonatomic, assign, readonly) CGSize videoSize;
/// 视频方向
@property (nonatomic, assign, readonly) FUVideoOrientation videoOrientation;
/// 当前视频是否包含音频轨道
@property (nonatomic, assign, readonly) BOOL containAudioTrack;
/// 视频时长,单位秒
@property (nonatomic, assign, readonly) CGFloat duration;
@property (nonatomic, weak) id<FUVideoReaderDelegate> delegate;
@property (nonatomic, strong) FUVideoReaderSettings *readerSettings;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithURL:(NSURL *)URL;
- (instancetype)initWithURL:(NSURL *)URL settings:(nullable FUVideoReaderSettings *)settings;
- (instancetype)initWithAsset:(AVAsset *)asset;
- (instancetype)initWithAsset:(AVAsset *)asset settings:(nullable FUVideoReaderSettings *)settings;
/// 开始解码
/// @note 内部自动解码为异步
- (void)start;
/// 停止解码
- (void)stop;
- (BOOL)readNextVideoBuffer;
- (BOOL)readNextAudioBuffer;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,70 @@
//
// FUVideoSettings.h
// FUVideoComponent
//
// Created by 项林平 on 2022/5/27.
//
#import <AVFoundation/AVFoundation.h>
#import "FUVideoComponentDefines.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUVideoReaderSettings : NSObject
/// 是否自动解码默认为NO
/// @note 如果为NO可以调用FUVideoReader实例的readNextVideoBuffer和readNextAudioBuffer方法逐帧读取
@property (nonatomic, assign) BOOL readingAutomatically;
/// 是否需要音频轨道默认为YES
@property (nonatomic, assign) BOOL needsAudioTrack;
/// 以视频真实码率或者以默认速度解码默认为YES视频真实码率
@property (nonatomic, assign) BOOL readAtVideoRate;
/// 是否需要循环解码默认为NO
@property (nonatomic, assign) BOOL needsRepeat;
/// 视频解码格式默认为kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
@property (nonatomic) OSType videoOutputFormat;
/// 音频解码格式默认为kAudioFormatLinearPCM (最高保真度)
@property (nonatomic) AudioFormatID audioOutputFormat;
/// 恢复默认设置
- (void)resetToDefault;
@end
@interface FUVideoWriterSettings : NSObject
/// 是否需要音频轨道默认为YES
@property (nonatomic, assign) BOOL needsAudioTrack;
/// 文件格式默认为AVFileTypeQuickTimeMovie
@property (nonatomic, copy) AVFileType fileType;
/// 是否实时数据源默认为NO
@property (nonatomic, assign) BOOL isRealTimeData;
/// 视频方向默认为FUVideoOrientationPortrait
@property (nonatomic, assign) FUVideoOrientation videoOrientation;
/// 视频编码格式默认为AVVideoCodecH264
@property (nonatomic, copy) AVVideoCodecType videoInputFormat;
/// 音频编码格式默认为kAudioFormatMPEG4AAC
@property (nonatomic) AudioFormatID audioInputFormat;
/// 音频声道数量默认为2
@property (nonatomic, assign) NSInteger audioChannels;
/// 音频码率,默认为当前硬件码率
@property (nonatomic) double audioRate;
/// 恢复默认设置
- (void)resetToDefault;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,56 @@
//
// FUVideoWriter.h
// FUVideoComponent
//
// Created by 项林平 on 2022/5/9.
//
#import <AVFoundation/AVFoundation.h>
#import "FUVideoComponentDefines.h"
#import "FUVideoSettings.h"
NS_ASSUME_NONNULL_BEGIN
@interface FUVideoWriter : NSObject
@property (nonatomic, assign, readonly) BOOL isWriting;
@property (nonatomic, strong, readonly) NSURL *videoURL;
@property (nonatomic, strong, readonly) AVAssetWriterInput *videoInput;
@property (nonatomic, strong, readonly) AVAssetWriterInput *audioInput;
/// 视频数据允许写入回调star()方法调用前赋值
@property (nonatomic, copy) BOOL (^videoInputReadyHandler)(void);
/// 音频数据允许写入回调start()方法调用前赋值
@property (nonatomic, copy) BOOL (^audioInputReadyHandler)(void);
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithVideoURL:(NSURL *)URL
videoSize:(CGSize)size;
/// 初始化方法
/// @param URL 文件保存路径(如果已经存在文件,会先删除原文件)
/// @param size 视频尺寸
/// @param settings 编码设置nil时会使用默认设置
- (instancetype)initWithVideoURL:(NSURL *)URL
videoSize:(CGSize)size
setting:(nullable FUVideoWriterSettings *)settings;
- (void)start;
- (void)stop;
/// 写入完成后必须调用该方法
- (void)finishWritingWithCompletion:(nullable void (^)(void))completion;
- (void)appendVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer;
- (void)appendPixelBuffer:(CVPixelBufferRef)pixelBuffer time:(CMTime)timeStamp;
- (void)appendAudioSampleBuffer:(CMSampleBufferRef)sampleBuffer;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,78 @@
//
// UIDevice+FURenderKit.h
// FURenderKit
//
// Created by 项林平 on 2021/8/5.
//
#import <UIKit/UIKit.h>
/// 设备性能等级
typedef NS_ENUM(NSInteger, FUDevicePerformanceLevel) {
FUDevicePerformanceLevelLow_1 = -1, // iPhone6、iPhone6Plus及以下机型
FUDevicePerformanceLevelLow = 1, // iPhone6Plus以上和iPhone8以下机型
FUDevicePerformanceLevelHigh = 2, // iPhone8及以上和iPhoneXR以下机型
FUDevicePerformanceLevelVeryHigh = 3, // iPhoneXR
FUDevicePerformanceLevelExcellent = 4 // iPhoneXR以上机型
};
/// 设备具体机型
typedef NS_ENUM(NSInteger, FUDeviceModelType) {
FUDeviceModelTypeSimulator = 0,
FUDeviceModelTypeiPhone3G,
FUDeviceModelTypeiPhone3GS,
FUDeviceModelTypeiPhone4,
FUDeviceModelTypeiPhone4s,
FUDeviceModelTypeiPhone5,
FUDeviceModelTypeiPhone5c,
FUDeviceModelTypeiPhone5s,
FUDeviceModelTypeiPhone6,
FUDeviceModelTypeiPhone6Plus,
FUDeviceModelTypeiPhone6s,
FUDeviceModelTypeiPhone6sPlus,
FUDeviceModelTypeiPhoneSE,
FUDeviceModelTypeiPhone7,
FUDeviceModelTypeiPhone7Plus,
FUDeviceModelTypeiPhone8,
FUDeviceModelTypeiPhone8Plus,
FUDeviceModelTypeiPhoneX,
FUDeviceModelTypeiPhoneXS,
FUDeviceModelTypeiPhoneXSMax,
FUDeviceModelTypeiPhoneXR,
FUDeviceModelTypeiPhone11,
FUDeviceModelTypeiPhone11Pro,
FUDeviceModelTypeiPhone11ProMax,
FUDeviceModelTypeiPhoneSE2,
FUDeviceModelTypeiPhone12Mini,
FUDeviceModelTypeiPhone12,
FUDeviceModelTypeiPhone12Pro,
FUDeviceModelTypeiPhone12ProMax,
FUDeviceModelTypeiPhone13Mini,
FUDeviceModelTypeiPhone13,
FUDeviceModelTypeiPhone13Pro,
FUDeviceModelTypeiPhone13ProMax,
FUDeviceModelTypeiPhoneSENew,
FUDeviceModelTypeiPhone14,
FUDeviceModelTypeiPhone14Plus,
FUDeviceModelTypeiPhone14Pro,
FUDeviceModelTypeiPhone14ProMax,
FUDeviceModelTypeiPhone15,
FUDeviceModelTypeiPhone15Plus,
FUDeviceModelTypeiPhone15Pro,
FUDeviceModelTypeiPhone15ProMax,
FUDeviceModelTypeOthers
};
NS_ASSUME_NONNULL_BEGIN
@interface UIDevice (FURenderKit)
- (FUDeviceModelType)fu_deviceModelType;
- (NSString *)fu_deviceModelString;
- (FUDevicePerformanceLevel)fu_devicePerformanceLevel;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,36 @@
//
// UIImage+FURenderKit.h
// FURenderKit
//
// Created by liuyang on 2021/3/1.
//
#import <UIKit/UIKit.h>
#import "FURenderIO.h"
NS_ASSUME_NONNULL_BEGIN
@interface UIImage (FURenderKit)
/// 从 UIImage 中获取 FUImageBuffer格式为RGBA需要手动释放 buffer0 或掉用 UIImage 的类方法freeImageBuffer 释放 FUImageBuffer 内部内存。
- (FUImageBuffer)getImageBuffer;
/// 释放从 UIImage 获取到的 FUImageBuffer 内存,释放内存后 buffer0 会被设置为 null
/// @param imageBuffer 从 UIImage 获取到的 FUImageBuffer 的地址指针
+ (void)freeImageBuffer:(FUImageBuffer *)imageBuffer;
/// 将 FUImageBuffer 转换为图片,如果 FUImageBuffer 是从 UIImage 获取的,可以将 autoFreeBuffer 设置为 YES内部会自动释放 FUImageBuffer 内存。
/// @param imageBuffer FUImageBuffer 图像的地址指针
/// @param autoFreeBuffer 是否自动释放 FUImageBuffer
/// 默认alpha 为NO
+ (UIImage *)imageWithRGBAImageBuffer:(FUImageBuffer *)imageBuffer autoFreeBuffer:(BOOL)autoFreeBuffer;
+ (UIImage *)imageWithPixelBuffer:(CVPixelBufferRef)pixelBufferRef;
/// 将 FUImageBuffer 转换为图片,如果 FUImageBuffer 是从 UIImage 获取的,可以将 autoFreeBuffer 设置为 YES内部会自动释放 FUImageBuffer 内存。
/// @param imageBuffer FUImageBuffer 图像的地址指针
/// @param autoFreeBuffer 是否自动释放 FUImageBuffer
/// @param alpha == YES 透明 NO 不透明
+ (UIImage *)imageWithRGBAImageBuffer:(FUImageBuffer *)imageBuffer autoFreeBuffer:(BOOL)autoFreeBuffer alpha:(BOOL)alpha;
@end
NS_ASSUME_NONNULL_END

File diff suppressed because it is too large Load Diff