QueenEngine

@interface QueenEngine : NSObject

/** QueenEngine回调代理对象。
 */
@property (nonatomic, weak) id <QueenEngineDelegate> delegate;

/**
 * 获取版本号。
 */
+ (NSString *)getVersion;

/**
 * 初始化引擎。
 * @param configInfo 配置信息。
 */
- (instancetype)initWithConfigInfo:(QueenEngineConfigInfo *)configInfo;

/**
 * 更新引擎配置参数。
 * 注意:仅当initWithConfigInfo的时候,configInfo为nil的时候此接口才生效,而且仅可设置一次有效值。
 * @param configInfo 配置信息。
 */
- (void)updateConfigInfo:(QueenEngineConfigInfo *)configInfo;

/**
 * 销毁引擎。
 * 注意:需要在渲染线程调用。
 */
- (void)destroyEngine;

/**
 * 高性能模式。
 * 注意:开启后效果会稍变差。
 * @param enabled YES/NO,默认NO。
 */
- (void)powerSavingEnabled:(BOOL)enabled;

/**
 * 设置渲染的viewport。
 * 注意:如果不设置默认使用输入的数据的宽和高。
 * @param originX 默认0
 * @param originY 默认0
 * @param width 默认0
 * @param height 默认0
 */
- (void)setScreenViewportWithOriginX:(int)originX withOriginY:(int)originY withWidth:(int)width withHeight:(int)height;

/**
 * 设置输出裁剪矩形。
 * 注意:如果不设置默认使用输入的数据的宽和高。
 * @param originX 默认0
 * @param originY 默认0
 * @param width 默认0
 * @param height 默认0
 */
- (void)setOutputRectWithOriginX:(int)originX withOriginY:(int)originY withWidth:(int)width withHeight:(int)height;

#pragma mark - "美颜类型和美颜参数API"

/**
 * 打开或者关闭某个功能效果。
 * @param type kQueenBeautyType 类型的一个值。
 * @param enabled YES: 打开,NO:关闭。
 */
- (void)setQueenBeautyType:(kQueenBeautyType)type enable:(BOOL)enabled;

/**
 * 打开或者关闭某个功能效果。
 * @param type kQueenBeautyType 类型的一个值。
 * @param enabled YES: 打开,NO:关闭。
 * @param mode kQueenBeautyFilterMode 类型的一个值。
 */
- (void)setQueenBeautyType:(kQueenBeautyType)type enable:(BOOL)enabled mode:(kQueenBeautyFilterMode)mode;

/**
 * 设置功能参数。
 * @param param 功能参数类型,kQueenBeautyParams 中的一个。
 * @param value 需要设置的数值,参考kQueenBeautyParams的备注。
 */
- (void)setQueenBeautyParams:(kQueenBeautyParams)param value:(float)value;

/**
 * 获取功能参数。
 * @param param 功能参数类型,kQueenBeautyParams 中的一个。
 */
- (float)getQueenBeautyParams:(kQueenBeautyParams)param;

#pragma mark - "滤镜相关API"

/**
 * 设置滤镜资源。
 * 注意:设置滤镜图片前需要将kQueenBeautyTypeLUT打开。
 * @param imagePath 所要设置的滤镜图片的地址。
 */
- (void)setLutImagePath:(NSString *)imagePath;

#pragma mark - "美型相关API"

/**
 * 设置美型参数。
 * 注意:设置前需要将kQueenBeautyTypeFaceShape打开。
 * @param faceShapeType 美型类型,kQueenBeautyFaceShapeType 中的一个。
 * @param value 需要设置的数值,参考kQueenBeautyFaceShapeType的备注。
 */
- (void)setFaceShape:(kQueenBeautyFaceShapeType)faceShapeType value:(float)value;

#pragma mark - "美体相关API"

/**
 * 设置美体参数。
 * 注意:设置前需要将kQueenBeautyTypeBodyShape打开。
 * @param bodyShapeType 美体类型,kQueenBeautyBodyShapeType 中的一个。
 * @param value 需要设置的数值,参考kQueenBeautyBodyShapeType的备注。
 */
- (void)setBodyShape:(kQueenBeautyBodyShapeType)bodyShapeType value:(float)value;

#pragma mark - "美妆相关api"

/**
 * 设置美妆类型和图片素材路径。
 * 注意:设置前需要将kQueenBeautyTypeMakeup 打开。
 * @param makeupType 美妆类型,kQueenBeautyMakeupType 中的一个。
 * @param imagePaths 美妆素材地址集合。
 * @param blend 混合类型。
 */
- (void)setMakeupWithType:(kQueenBeautyMakeupType)makeupType paths:(NSArray<NSString *> *)imagePaths blendType:(kQueenBeautyBlend)blend;

/**
 * 设置美妆类型和图片素材路径。
 * 注意:设置前需要将kQueenBeautyTypeMakeup 打开。
 * @param makeupType 美妆类型,kQueenBeautyMakeupType 中的一个。
 * @param imagePaths 美妆素材地址集合。
 * @param blend 混合类型。
 * @param fps 对应的帧率
 */
- (void)setMakeupWithType:(kQueenBeautyMakeupType)makeupType paths:(NSArray<NSString *> *)imagePaths blendType:(kQueenBeautyBlend)blend fps:(int)fps;

/**
 * 设置美妆透明度,可指定性别。
 * @param makeupType 美妆类型。
 * @param isFeMale 是否是女性,女性:YES,男性:NO,(男性为接口预留,这里均传女性即YES即可)。
 * @param alpha 妆容透明度。
 */
- (void)setMakeupAlphaWithType:(kQueenBeautyMakeupType)makeupType female:(BOOL)isFeMale alpha:(float)alpha;

/**
 * 设置美妆类型的混合类型。
 * @param makeupType 美妆类型。
 * @param blend 混合类型。
 */
- (void)setMakeupBlendWithType:(kQueenBeautyMakeupType)makeupType blendType:(kQueenBeautyBlend)blend;

/**
 * 清除所有美妆。
 */
- (void)resetAllMakeupType;

#pragma mark - "头发美化相关API"

/**
 * 设置头发颜色。
 * 注意:设置前需要将kQueenBeautyTypeHairColor 打开。
 * @param red [0,1]
 * @param green [0,1]
 * @param blue [0,1]
 */
- (void)setHairColorWithRed:(float)red withGreen:(float)green withBlue:(float)blue;

#pragma mark - "贴纸相关API"

/**
 * 增加贴纸/贴图/实景抠图需要替换的背景,素材统一接口,支持GLTF,TAOPAI,MEDIAAI 类型。
 * @param materialPath 要添加的素材的路径。
 */
- (void)addMaterialWithPath:(NSString *)materialPath;

/**
 * 删除贴纸/贴图/实景抠图需要替换的背景。
 * @param materialPath 要删除的素材的路径。
 */
- (void)removeMaterialWithPath:(NSString *)materialPath;

#pragma mark - "抠图相关API"

/**
 * 绿幕/蓝幕抠图。
 * 注意:开启此抠图功能,纯色背景抠图(setPureColorToBackground)会关闭。
 * @param backgroundImagePath 需要绿/蓝幕替换的背景资源路径,传空即为取消抠图功能。
 * @param blueScreenEnabled 是否蓝幕抠图。
 * @param threshold 幕布敏感度[1,10],默认1。
 * @param autoThresholdEnabled 是否根据环境动态计算幕布敏感度,为true时调节参数threshold失效,为false时调节参数threshold生效。
 */
- (void)setGreenScreen:(NSString *)backgroundImagePath blueScreenEnabled:(BOOL)blueScreenEnabled threshold:(float)threshold autoThresholdEnabled:(BOOL)autoThresholdEnabled;

/**
 * 纯色背景抠图。
 * 注意:开启此抠图功能,绿幕抠图(setGreenScreen)会关闭。
 * @param backgroundImagePath 需要纯色背景替换的背景资源路径,传空即为取消抠图功能。
 * @param colorType 需要被替换的颜色类型,0绿色(green),1蓝色(blue),2青色(cyan),3紫色(purple),4黄色(yellow),5红色(red),默认0。
 * @param threshold 颜色敏感度[-1, 1], 默认0。
 */
- (void)setPureColorToBackground:(NSString *)backgroundImagePath colorType:(kQueenBeautyBgColorType)colorType threshold:(float)threshold;

/**
 * 调整实景抠图的背景处理方式
 * @param backgroundProcessType 背景处理方式,默认为背景虚化
 */
- (void)setSegmentBackgroundProcessType:(kQueenBackgroundProcessType)backgroundProcessType;

/**
 * 设置实景抠像的性能模式。
 * 注意:在开启实景抠像功能前调用才能生效。
 * @param performanceMode 实景抠图的性能模式。
 */
- (void)setSegmentPerformanceMode:(kQueenSegmentPerformanceMode)performanceMode;

/**
 * 调整实景抠图的前景边距。
 * @param foregroundPadding 前景边距,[0,15],默认0。
 */
- (void)setAISegmentForegroundPadding:(int)foregroundPadding;

#pragma mark - "互动相关API"

/**
 * AR写字/绘画。
 * @param enabled YES: 打开,NO:关闭。
 * @param mode 1: 写字, 2: 画画。
 */
- (void)setARWriting:(BOOL)enabled mode:(int)mode;

#pragma mark - "数据处理"

/**
 * 人脸识别信息和渲染是否翻转以Y轴方向翻转。
 * @param faceRenderFlipY 需要关键点确定位置的图像渲染时是否反转,默认NO。
 * @param faceInfoFlipY 关键点数据是否翻转,默认NO。
 */
- (void)setFaceRenderFlipY:(BOOL)faceRenderFlipY faceInfoFlipY:(BOOL)faceInfoFlipY;

/**
 * 处理PixelBuffer类型数据。
 * @param pixelBufferData 需要处理的数据。
 * @return 接口调用状态码。
 */
- (kQueenResultCode)processPixelBuffer:(QEPixelBufferData *)pixelBufferData;

/**
 * 处理Texture类型数据。
 * @param textureData 需要处理的数据。
 * @return 接口调用状态码。
 */
- (kQueenResultCode)processTexture:(QETextureData *)textureData;

/**
 * 分析视频帧数据处理。
 * 注意:如处理Texture类型数据时需高级美颜处理需要调用此接口,处理PixelBuffer类型数据不需要调用此接口。
 * @param imageData 帧图片流。
 * @param format 帧图片流颜色格式。
 * @param width 帧图片宽度。
 * @param height 帧图片高度。
 * @param stride 用于检测的图像的跨度(以像素为单位),即每行的字节数, 默认情况下设为 0。
 * @param intputAngle 当前输入帧图片需旋转的角度,计算方式参考Sample工程,注:仅当QueenEngineConfigInfo的autoSettingImgAngle设置为NO才会生效。
 * @param outputAngle 算法输出结果所需旋转的角度,计算方式参考Sample工程,注:仅当QueenEngineConfigInfo的autoSettingImgAngle设置为NO才会生效。
 * @param flipAxis 输出数据的xy轴翻转处理,0为不旋转,1为x轴翻转,2为y轴翻转。
 */
- (void)updateInputDataAndRunAlg:(uint8_t *)imageData withImgFormat:(kQueenImageFormat)format withWidth:(int)width withHeight:(int)height withStride:(int)stride
                  withInputAngle:(int)intputAngle withOutputAngle:(int)outputAngle withFlipAxis:(int)flipAxis;

#pragma mark - "调试相关"

/**
 * 展示人脸识别点位。
 * @param show 是否展示。
 */
- (void)showFaceDetectPoint:(BOOL)show;

/**
 * 展示人体识别点位。
 * @param show 是否展示。
 */
- (void)showBodyDetectPoint:(BOOL)show;

/**
 * 展示手部识别点位。
 * @param show 是否展示。
 */
- (void)showHandDetectPoint:(BOOL)show;

/**
 * 展示人脸区域三角剖分线。
 * @param show 是否展示。
 */
- (void)showMakeupLine:(BOOL)show;

/**
 * 展示AR绘制关键点。
 * @param show 是否展示。
 */
- (void)showARWritingDetectPoint:(BOOL)show;

@end

Undocumented

  • QueenEngine回调代理对象。

    Declaration

    Objective-C

    @property (nonatomic, weak) id<QueenEngineDelegate> delegate;
  • 获取版本号。

    Declaration

    Objective-C

    + (NSString *)getVersion;
  • 初始化引擎。

    Declaration

    Objective-C

    - (instancetype)initWithConfigInfo:(QueenEngineConfigInfo *)configInfo;

    Parameters

    configInfo

    配置信息。

  • 更新引擎配置参数。 注意:仅当initWithConfigInfo的时候,configInfo为nil的时候此接口才生效,而且仅可设置一次有效值。

    Declaration

    Objective-C

    - (void)updateConfigInfo:(QueenEngineConfigInfo *)configInfo;

    Parameters

    configInfo

    配置信息。

  • 销毁引擎。 注意:需要在渲染线程调用。

    Declaration

    Objective-C

    - (void)destroyEngine;
  • 高性能模式。 注意:开启后效果会稍变差。

    Declaration

    Objective-C

    - (void)powerSavingEnabled:(BOOL)enabled;

    Parameters

    enabled

    YES/NO,默认NO。

  • 设置渲染的viewport。 注意:如果不设置默认使用输入的数据的宽和高。

    Declaration

    Objective-C

    - (void)setScreenViewportWithOriginX:(int)originX
                             withOriginY:(int)originY
                               withWidth:(int)width
                              withHeight:(int)height;

    Parameters

    originX

    默认0

    originY

    默认0

    width

    默认0

    height

    默认0

  • 设置输出裁剪矩形。 注意:如果不设置默认使用输入的数据的宽和高。

    Declaration

    Objective-C

    - (void)setOutputRectWithOriginX:(int)originX
                         withOriginY:(int)originY
                           withWidth:(int)width
                          withHeight:(int)height;

    Parameters

    originX

    默认0

    originY

    默认0

    width

    默认0

    height

    默认0

“美颜类型和美颜参数API”

  • 打开或者关闭某个功能效果。

    Declaration

    Objective-C

    - (void)setQueenBeautyType:(kQueenBeautyType)type enable:(BOOL)enabled;

    Parameters

    type

    kQueenBeautyType 类型的一个值。

    enabled

    YES: 打开,NO:关闭。

  • 打开或者关闭某个功能效果。

    Declaration

    Objective-C

    - (void)setQueenBeautyType:(kQueenBeautyType)type
                        enable:(BOOL)enabled
                          mode:(kQueenBeautyFilterMode)mode;

    Parameters

    type

    kQueenBeautyType 类型的一个值。

    enabled

    YES: 打开,NO:关闭。

    mode

    kQueenBeautyFilterMode 类型的一个值。

  • 设置功能参数。

    Declaration

    Objective-C

    - (void)setQueenBeautyParams:(kQueenBeautyParams)param value:(float)value;

    Parameters

    param

    功能参数类型,kQueenBeautyParams 中的一个。

    value

    需要设置的数值,参考kQueenBeautyParams的备注。

  • 获取功能参数。

    Declaration

    Objective-C

    - (float)getQueenBeautyParams:(kQueenBeautyParams)param;

    Parameters

    param

    功能参数类型,kQueenBeautyParams 中的一个。

“滤镜相关API”

  • 设置滤镜资源。 注意:设置滤镜图片前需要将kQueenBeautyTypeLUT打开。

    Declaration

    Objective-C

    - (void)setLutImagePath:(NSString *)imagePath;

    Parameters

    imagePath

    所要设置的滤镜图片的地址。

“美型相关API”

  • 设置美型参数。 注意:设置前需要将kQueenBeautyTypeFaceShape打开。

    Declaration

    Objective-C

    - (void)setFaceShape:(kQueenBeautyFaceShapeType)faceShapeType
                   value:(float)value;

    Parameters

    faceShapeType

    美型类型,kQueenBeautyFaceShapeType 中的一个。

    value

    需要设置的数值,参考kQueenBeautyFaceShapeType的备注。

“美体相关API”

  • 设置美体参数。 注意:设置前需要将kQueenBeautyTypeBodyShape打开。

    Declaration

    Objective-C

    - (void)setBodyShape:(kQueenBeautyBodyShapeType)bodyShapeType
                   value:(float)value;

    Parameters

    bodyShapeType

    美体类型,kQueenBeautyBodyShapeType 中的一个。

    value

    需要设置的数值,参考kQueenBeautyBodyShapeType的备注。

“美妆相关api”

  • 设置美妆类型和图片素材路径。 注意:设置前需要将kQueenBeautyTypeMakeup 打开。

    Declaration

    Objective-C

    - (void)setMakeupWithType:(kQueenBeautyMakeupType)makeupType
                        paths:(NSArray<NSString *> *)imagePaths
                    blendType:(kQueenBeautyBlend)blend;

    Parameters

    makeupType

    美妆类型,kQueenBeautyMakeupType 中的一个。

    imagePaths

    美妆素材地址集合。

    blend

    混合类型。

  • 设置美妆类型和图片素材路径。 注意:设置前需要将kQueenBeautyTypeMakeup 打开。

    Declaration

    Objective-C

    - (void)setMakeupWithType:(kQueenBeautyMakeupType)makeupType
                        paths:(NSArray<NSString *> *)imagePaths
                    blendType:(kQueenBeautyBlend)blend
                          fps:(int)fps;

    Parameters

    makeupType

    美妆类型,kQueenBeautyMakeupType 中的一个。

    imagePaths

    美妆素材地址集合。

    blend

    混合类型。

    fps

    对应的帧率

  • 设置美妆透明度,可指定性别。

    Declaration

    Objective-C

    - (void)setMakeupAlphaWithType:(kQueenBeautyMakeupType)makeupType
                            female:(BOOL)isFeMale
                             alpha:(float)alpha;

    Parameters

    makeupType

    美妆类型。

    isFeMale

    是否是女性,女性:YES,男性:NO,(男性为接口预留,这里均传女性即YES即可)。

    alpha

    妆容透明度。

  • 设置美妆类型的混合类型。

    Declaration

    Objective-C

    - (void)setMakeupBlendWithType:(kQueenBeautyMakeupType)makeupType
                         blendType:(kQueenBeautyBlend)blend;

    Parameters

    makeupType

    美妆类型。

    blend

    混合类型。

  • 清除所有美妆。

    Declaration

    Objective-C

    - (void)resetAllMakeupType;

“头发美化相关API”

  • 设置头发颜色。 注意:设置前需要将kQueenBeautyTypeHairColor 打开。

    Declaration

    Objective-C

    - (void)setHairColorWithRed:(float)red
                      withGreen:(float)green
                       withBlue:(float)blue;

    Parameters

    red

    [0,1]

    green

    [0,1]

    blue

    [0,1]

“贴纸相关API”

  • 增加贴纸/贴图/实景抠图需要替换的背景,素材统一接口,支持GLTF,TAOPAI,MEDIAAI 类型。

    Declaration

    Objective-C

    - (void)addMaterialWithPath:(NSString *)materialPath;

    Parameters

    materialPath

    要添加的素材的路径。

  • 删除贴纸/贴图/实景抠图需要替换的背景。

    Declaration

    Objective-C

    - (void)removeMaterialWithPath:(NSString *)materialPath;

    Parameters

    materialPath

    要删除的素材的路径。

“抠图相关API”

  • 绿幕/蓝幕抠图。 注意:开启此抠图功能,纯色背景抠图(setPureColorToBackground)会关闭。

    Declaration

    Objective-C

    - (void)setGreenScreen:(NSString *)backgroundImagePath
           blueScreenEnabled:(BOOL)blueScreenEnabled
                   threshold:(float)threshold
        autoThresholdEnabled:(BOOL)autoThresholdEnabled;

    Parameters

    backgroundImagePath

    需要绿/蓝幕替换的背景资源路径,传空即为取消抠图功能。

    blueScreenEnabled

    是否蓝幕抠图。

    threshold

    幕布敏感度[1,10],默认1。

    autoThresholdEnabled

    是否根据环境动态计算幕布敏感度,为true时调节参数threshold失效,为false时调节参数threshold生效。

  • 纯色背景抠图。 注意:开启此抠图功能,绿幕抠图(setGreenScreen)会关闭。

    Declaration

    Objective-C

    - (void)setPureColorToBackground:(NSString *)backgroundImagePath
                           colorType:(kQueenBeautyBgColorType)colorType
                           threshold:(float)threshold;

    Parameters

    backgroundImagePath

    需要纯色背景替换的背景资源路径,传空即为取消抠图功能。

    colorType

    需要被替换的颜色类型,0绿色(green),1蓝色(blue),2青色(cyan),3紫色(purple),4黄色(yellow),5红色(red),默认0。

    threshold

    颜色敏感度[-1, 1], 默认0。

  • 调整实景抠图的背景处理方式

    Declaration

    Objective-C

    - (void)setSegmentBackgroundProcessType:
        (kQueenBackgroundProcessType)backgroundProcessType;

    Parameters

    backgroundProcessType

    背景处理方式,默认为背景虚化

  • 设置实景抠像的性能模式。 注意:在开启实景抠像功能前调用才能生效。

    Declaration

    Objective-C

    - (void)setSegmentPerformanceMode:(kQueenSegmentPerformanceMode)performanceMode;

    Parameters

    performanceMode

    实景抠图的性能模式。

  • 调整实景抠图的前景边距。

    Declaration

    Objective-C

    - (void)setAISegmentForegroundPadding:(int)foregroundPadding;

    Parameters

    foregroundPadding

    前景边距,[0,15],默认0。

“互动相关API”

  • AR写字/绘画。

    Declaration

    Objective-C

    - (void)setARWriting:(BOOL)enabled mode:(int)mode;

    Parameters

    enabled

    YES: 打开,NO:关闭。

    mode

    1: 写字, 2: 画画。

“数据处理”

  • 人脸识别信息和渲染是否翻转以Y轴方向翻转。

    Declaration

    Objective-C

    - (void)setFaceRenderFlipY:(BOOL)faceRenderFlipY
                 faceInfoFlipY:(BOOL)faceInfoFlipY;

    Parameters

    faceRenderFlipY

    需要关键点确定位置的图像渲染时是否反转,默认NO。

    faceInfoFlipY

    关键点数据是否翻转,默认NO。

  • 处理PixelBuffer类型数据。

    Declaration

    Objective-C

    - (kQueenResultCode)processPixelBuffer:(QEPixelBufferData *)pixelBufferData;

    Parameters

    pixelBufferData

    需要处理的数据。

    Return Value

    接口调用状态码。

  • 处理Texture类型数据。

    Declaration

    Objective-C

    - (kQueenResultCode)processTexture:(QETextureData *)textureData;

    Parameters

    textureData

    需要处理的数据。

    Return Value

    接口调用状态码。

  • 分析视频帧数据处理。 注意:如处理Texture类型数据时需高级美颜处理需要调用此接口,处理PixelBuffer类型数据不需要调用此接口。

    Declaration

    Objective-C

    - (void)updateInputDataAndRunAlg:(uint8_t *)imageData
                       withImgFormat:(kQueenImageFormat)format
                           withWidth:(int)width
                          withHeight:(int)height
                          withStride:(int)stride
                      withInputAngle:(int)intputAngle
                     withOutputAngle:(int)outputAngle
                        withFlipAxis:(int)flipAxis;

    Parameters

    imageData

    帧图片流。

    format

    帧图片流颜色格式。

    width

    帧图片宽度。

    height

    帧图片高度。

    stride

    用于检测的图像的跨度(以像素为单位),即每行的字节数, 默认情况下设为 0。

    intputAngle

    当前输入帧图片需旋转的角度,计算方式参考Sample工程,注:仅当QueenEngineConfigInfo的autoSettingImgAngle设置为NO才会生效。

    outputAngle

    算法输出结果所需旋转的角度,计算方式参考Sample工程,注:仅当QueenEngineConfigInfo的autoSettingImgAngle设置为NO才会生效。

    flipAxis

    输出数据的xy轴翻转处理,0为不旋转,1为x轴翻转,2为y轴翻转。

“调试相关”

  • 展示人脸识别点位。

    Declaration

    Objective-C

    - (void)showFaceDetectPoint:(BOOL)show;

    Parameters

    show

    是否展示。

  • 展示人体识别点位。

    Declaration

    Objective-C

    - (void)showBodyDetectPoint:(BOOL)show;

    Parameters

    show

    是否展示。

  • 展示手部识别点位。

    Declaration

    Objective-C

    - (void)showHandDetectPoint:(BOOL)show;

    Parameters

    show

    是否展示。

  • 展示人脸区域三角剖分线。

    Declaration

    Objective-C

    - (void)showMakeupLine:(BOOL)show;

    Parameters

    show

    是否展示。

  • 展示AR绘制关键点。

    Declaration

    Objective-C

    - (void)showARWritingDetectPoint:(BOOL)show;

    Parameters

    show

    是否展示。