QueenEngine

@interface QueenEngine : NSObject

/****
 * Specifies the delegate of QueenEngine.
 */
@property (nonatomic, weak) id <QueenEngineDelegate> delegate;

/****
 * Get version of the SDK.
 */
+ (NSString *)getVersion;

/****
 * Initialize the engine.
 * @param configInfo The engine configuration information.
 */
- (instancetype)initWithConfigInfo:(QueenEngineConfigInfo *)configInfo;

/****
 * Update the engine configuration information.
 * Note: This method takes effect only when initWithConfigInfo with nil, and the non-null value can only be set once.
 * @param configInfo The engine configuration information.
 */
- (void)updateConfigInfo:(QueenEngineConfigInfo *)configInfo;

/****
 * Release the engine.
 * Note: Need to be called on the rendering thread.
 */
- (void)destroyEngine;

/****
 * Performance mode.
 * Note: After turning it on, the effect will be slightly worse.
 * @param enabled YES/NO, default is NO.
 */
- (void)powerSavingEnabled:(BOOL)enabled;

/****
 * Set the rendered viewport.
 * Note: If not set, the width and height of the input data are used by default.
 * @param originX Default is 0.
 * @param originY Default is 0.
 * @param width Default is 0.
 * @param height Default is 0.
 */
- (void)setScreenViewportWithOriginX:(int)originX withOriginY:(int)originY withWidth:(int)width withHeight:(int)height;

/****
 * Set the output clipping rectangle.
 * Note: If not set, the width and height of the input data are used by default.
 * @param originX Default is 0.
 * @param originY Default is 0.
 * @param width Default is 0.
 * @param height Default is 0.
 */
- (void)setOutputRectWithOriginX:(int)originX withOriginY:(int)originY withWidth:(int)width withHeight:(int)height;

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

/****
 * Enabled features.
 * @param type kQueenBeautyType.
 * @param enabled YES/NO.
 */
- (void)setQueenBeautyType:(kQueenBeautyType)type enable:(BOOL)enabled;

/****
 * Enabled features.
 * @param type kQueenBeautyType.
 * @param enabled YES/NO.
 * @param mode kQueenBeautyFilterMode.
 */
- (void)setQueenBeautyType:(kQueenBeautyType)type enable:(BOOL)enabled mode:(kQueenBeautyFilterMode)mode;

/****
 * Set value of a specified feature.
 * @param param kQueenBeautyParams.
 * @param value Refer to the description of kQueenBeautyParams.
 */
- (void)setQueenBeautyParams:(kQueenBeautyParams)param value:(float)value;

/****
 * Get value of a specified feature.
 * @param param kQueenBeautyParams
 */
- (float)getQueenBeautyParams:(kQueenBeautyParams)param;

/****
 * Get enabled state of a specified feature.
 * @param beautyType kQueenBeautyType
 */
- (BOOL)getQueenBeautyEnabledState:(kQueenBeautyType)beautyType;

#pragma mark - "滤镜相关API"

/****
 * Set resource of filter.
 * Note: kQueenBeautyTypeLUT should be enabled before setting it.
 * @param imagePath Specifies the filter resource file path.
 */
- (void)setLutImagePath:(NSString *)imagePath;

#pragma mark - "美型相关API"

/****
 * Set value of face shape.
 * Note: kQueenBeautyTypeFaceShape should be enabled before setting it.
 * @param faceShapeType kQueenBeautyFaceShapeType.
 * @param value Refer to the description of kQueenBeautyFaceShapeType.
 */
- (void)setFaceShape:(kQueenBeautyFaceShapeType)faceShapeType value:(float)value;

#pragma mark - "美体相关API"

/****
 * Set value of body shape.
 * Note: kQueenBeautyTypeBodyShape should be enabled before setting it.
 * @param bodyShapeType kQueenBeautyBodyShapeType.
 * @param value Refer to the description of kQueenBeautyBodyShapeType.
 */
- (void)setBodyShape:(kQueenBeautyBodyShapeType)bodyShapeType value:(float)value;

#pragma mark - "美妆相关api"

/****
 * Set value of makeup.
 * Note: kQueenBeautyTypeMakeup should be enabled before setting it.
 * @param makeupType kQueenBeautyMakeupType.
 * @param imagePaths The resource file paths.
 * @param blend kQueenBeautyBlend.
 */
- (void)setMakeupWithType:(kQueenBeautyMakeupType)makeupType paths:(NSArray<NSString *> *)imagePaths blendType:(kQueenBeautyBlend)blend;

/****
 * Set value of makeup.
 * Note: kQueenBeautyTypeMakeup should be enabled before setting it.
 * @param makeupType kQueenBeautyMakeupType.
 * @param imagePaths The resource file paths.
 * @param blend kQueenBeautyBlend.
 * @param fps Specifies the fps of makeup resource.
 */
- (void)setMakeupWithType:(kQueenBeautyMakeupType)makeupType paths:(NSArray<NSString *> *)imagePaths blendType:(kQueenBeautyBlend)blend fps:(int)fps;

/****
 * Set alpha of makeup.
 * @param makeupType kQueenBeautyMakeupType.
 * @param isFeMale NO for male, YES for female, set YES here.
 * @param alpha Specifies the alpha of makeup.
 */
- (void)setMakeupAlphaWithType:(kQueenBeautyMakeupType)makeupType female:(BOOL)isFeMale alpha:(float)alpha;

/****
 * Set blend of makeup.
 * @param makeupType kQueenBeautyMakeupType.
 * @param blend kQueenBeautyBlend.
 */
- (void)setMakeupBlendWithType:(kQueenBeautyMakeupType)makeupType blendType:(kQueenBeautyBlend)blend;

/****
 * Clear all makeup effect.
 */
- (void)resetAllMakeupType;

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

/****
 * Set hair color.
 * Note: kQueenBeautyTypeHairColor should be enabled before setting it.
 * @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"

/****
 * Add sticker.
 * @param materialPath Specifies the sticker resource file path that should be added.
 */
- (void)addMaterialWithPath:(NSString *)materialPath;

/****
 * Remove sticker.
 * @param materialPath Specifies the sticker resource file path that should be removed.
 */
- (void)removeMaterialWithPath:(NSString *)materialPath;

#pragma mark - "抠图相关API"

/****
 * Green/Blue Screen matting.
 * Note: When this is turned on, the pure color background matting (setPureColorToBackground) will be disabled.
 * @param backgroundImagePath Specifies the background resource file path that needs to be replaced by green/blue screen. nil is disabled.
 * @param blueScreenEnabled Set if blue screen matting.
 * @param threshold Specifies the green/blue screen sensitivity, default is 1. Only takes effect when autoThresholdEnabled is NO.
 * @param autoThresholdEnabled Whether to dynamically calculate the screen sensitivity based on the environment.
 */
- (void)setGreenScreen:(NSString *)backgroundImagePath blueScreenEnabled:(BOOL)blueScreenEnabled threshold:(float)threshold autoThresholdEnabled:(BOOL)autoThresholdEnabled;

/****
 * Pure color Screen matting.
 * Note: When this is turned on, the pure color background matting (setGreenScreen) will be disabled.
 * @param backgroundImagePath Specifies the background resource file path that needs to be replaced by specifies color screen. nil is disabled.
 * @param colorType Specifies the color type that should be matted, 0green, 1blue, 2cyan, 3purple, 4yellow, 5red, default is 0.
 * @param threshold Specifies the closeness of color, [-1, 1], default is 0.
 */
- (void)setPureColorToBackground:(NSString *)backgroundImagePath colorType:(kQueenBeautyBgColorType)colorType threshold:(float)threshold;

/****
 * Choose process type for background segment.
 * @param backgroundProcessType kQueenBackgroundProcessType, default is kQueenBackgroundBlur.
 */
- (void)setSegmentBackgroundProcessType:(kQueenBackgroundProcessType)backgroundProcessType;

/****
 * Choose performance mode for background segment.
 * Note: Please call this method before using background segment function.
 * @param performanceMode kQueenSegmentPerformanceMode.
 */
- (void)setSegmentPerformanceMode:(kQueenSegmentPerformanceMode)performanceMode;

/****
 * Set the foreground margins of the background segment.
 * @param foregroundPadding The foreground margins, [0,15], default is 0.
 */
- (void)setAISegmentForegroundPadding:(int)foregroundPadding;

#pragma mark - "互动相关API"

/****
 * AR writing/painting.
 * @param enabled YES/NO.
 * @param mode 1: write, 2: paint.
 */
- (void)setARWriting:(BOOL)enabled mode:(int)mode;

#pragma mark - "数据处理"

/****
 * If the detected face/body coordinates need to be flipped on the y-axis.
 * @param faceRenderFlipY Whether images that require key-positioned positions are rendered inverted, default is NO.
 * @param faceInfoFlipY Whether the keypoint data is flipped, default is NO.
 */
- (void)setFaceRenderFlipY:(BOOL)faceRenderFlipY faceInfoFlipY:(BOOL)faceInfoFlipY;

/****
 * Process QEPixelBufferData.
 * @param pixelBufferData Data should be processed.
 * @return kQueenResultCode.
 */
- (kQueenResultCode)processPixelBuffer:(QEPixelBufferData *)pixelBufferData;

/****
 * Process QETextureData.
 * @param textureData Data should be processed.
 * @return kQueenResultCode.
 */
- (kQueenResultCode)processTexture:(QETextureData *)textureData;

/****
 * For image data analysis.
 * Note: If processing textureData, this method should be called, otherwise this method should not be called.
 * @param imageData Specifies the image raw data.
 * @param format Specifies the color space.
 * @param width Specifies the image width.
 * @param height Specifies the image height.
 * @param stride Specifies the stride (in pixels) of the image, i.e. the number of bytes per line, default is 0.
 * @param intputAngle Specifies the rotation angle of the bufferIn by which the face/body (if any) in the bufferIn needs to be rotated clockwise to the frontal face/body. Examples are 0/90/180/270, default is 0.
 * Note: Only takes effect if QueenEngineConfigInfo's member variable autoSettingImgAngle is set to NO.
 * @param outputAngle Specifies the rotation angle by which the detected frontal face/body needs to be rotated counterclockwise. Examples are 0/90/180/270, default is 0.
 * Note: Only takes effect if QueenEngineConfigInfo's member variable autoSettingImgAngle is set to NO. In general, the value set should be consistent with the inputAngle, so that the coordinate position of the recognized face/human body result fits the original image.
 * @param flipAxis The direction in which the detected face/body coordinates need to be flipped, 0 do nothing,1 Flip on the x-axis, 2 Flip on the y-axis.
 */
- (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 - "调试相关"

/****
 * Show key points for face.
 * @param show YES/NO.
 */
- (void)showFaceDetectPoint:(BOOL)show;

/****
 * Show key points for body.
 * @param show YES/NO.
 */
- (void)showBodyDetectPoint:(BOOL)show;

/****
 * Show key points for hand.
 * @param show YES/NO.
 */
- (void)showHandDetectPoint:(BOOL)show;

/****
 * Show lines for face.
 * @param show YES/NO.
 */
- (void)showMakeupLine:(BOOL)show;

/****
 * Show key points for ar writing/painting.
 * @param show YES/NO.
 */
- (void)showARWritingDetectPoint:(BOOL)show;

@end

Undocumented

  • Specifies the delegate of QueenEngine.

    Declaration

    Objective-C

    @property (nonatomic, weak) id<QueenEngineDelegate> delegate;
  • Get version of the SDK.

    Declaration

    Objective-C

    + (NSString *)getVersion;
  • Initialize the engine.

    Declaration

    Objective-C

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

    Parameters

    configInfo

    The engine configuration information.

  • Update the engine configuration information. Note: This method takes effect only when initWithConfigInfo with nil, and the non-null value can only be set once.

    Declaration

    Objective-C

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

    Parameters

    configInfo

    The engine configuration information.

  • Release the engine. Note: Need to be called on the rendering thread.

    Declaration

    Objective-C

    - (void)destroyEngine;
  • Performance mode. Note: After turning it on, the effect will be slightly worse.

    Declaration

    Objective-C

    - (void)powerSavingEnabled:(BOOL)enabled;

    Parameters

    enabled

    YES/NO, default is NO.

  • Set the rendered viewport. Note: If not set, the width and height of the input data are used by default.

    Declaration

    Objective-C

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

    Parameters

    originX

    Default is 0.

    originY

    Default is 0.

    width

    Default is 0.

    height

    Default is 0.

  • Set the output clipping rectangle. Note: If not set, the width and height of the input data are used by default.

    Declaration

    Objective-C

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

    Parameters

    originX

    Default is 0.

    originY

    Default is 0.

    width

    Default is 0.

    height

    Default is 0.

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

“滤镜相关API”

  • Set resource of filter. Note: kQueenBeautyTypeLUT should be enabled before setting it.

    Declaration

    Objective-C

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

    Parameters

    imagePath

    Specifies the filter resource file path.

“美型相关API”

  • Set value of face shape. Note: kQueenBeautyTypeFaceShape should be enabled before setting it.

    Declaration

    Objective-C

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

    Parameters

    faceShapeType

    kQueenBeautyFaceShapeType.

    value

    Refer to the description of kQueenBeautyFaceShapeType.

“美体相关API”

  • Set value of body shape. Note: kQueenBeautyTypeBodyShape should be enabled before setting it.

    Declaration

    Objective-C

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

    Parameters

    bodyShapeType

    kQueenBeautyBodyShapeType.

    value

    Refer to the description of kQueenBeautyBodyShapeType.

“美妆相关api”

  • Set value of makeup. Note: kQueenBeautyTypeMakeup should be enabled before setting it.

    Declaration

    Objective-C

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

    Parameters

    makeupType

    kQueenBeautyMakeupType.

    imagePaths

    The resource file paths.

    blend

    kQueenBeautyBlend.

  • Set value of makeup. Note: kQueenBeautyTypeMakeup should be enabled before setting it.

    Declaration

    Objective-C

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

    Parameters

    makeupType

    kQueenBeautyMakeupType.

    imagePaths

    The resource file paths.

    blend

    kQueenBeautyBlend.

    fps

    Specifies the fps of makeup resource.

  • Set alpha of makeup.

    Declaration

    Objective-C

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

    Parameters

    makeupType

    kQueenBeautyMakeupType.

    isFeMale

    NO for male, YES for female, set YES here.

    alpha

    Specifies the alpha of makeup.

  • Set blend of makeup.

    Declaration

    Objective-C

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

    Parameters

    makeupType

    kQueenBeautyMakeupType.

    blend

    kQueenBeautyBlend.

  • Clear all makeup effect.

    Declaration

    Objective-C

    - (void)resetAllMakeupType;

“头发美化相关API”

  • Set hair color. Note: kQueenBeautyTypeHairColor should be enabled before setting it.

    Declaration

    Objective-C

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

    Parameters

    red

    [0,1]

    green

    [0,1]

    blue

    [0,1]

“贴纸相关API”

  • Add sticker.

    Declaration

    Objective-C

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

    Parameters

    materialPath

    Specifies the sticker resource file path that should be added.

  • Remove sticker.

    Declaration

    Objective-C

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

    Parameters

    materialPath

    Specifies the sticker resource file path that should be removed.

“抠图相关API”

  • Green/Blue Screen matting. Note: When this is turned on, the pure color background matting (setPureColorToBackground) will be disabled.

    Declaration

    Objective-C

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

    Parameters

    backgroundImagePath

    Specifies the background resource file path that needs to be replaced by green/blue screen. nil is disabled.

    blueScreenEnabled

    Set if blue screen matting.

    threshold

    Specifies the green/blue screen sensitivity, default is 1. Only takes effect when autoThresholdEnabled is NO.

    autoThresholdEnabled

    Whether to dynamically calculate the screen sensitivity based on the environment.

  • Pure color Screen matting. Note: When this is turned on, the pure color background matting (setGreenScreen) will be disabled.

    Declaration

    Objective-C

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

    Parameters

    backgroundImagePath

    Specifies the background resource file path that needs to be replaced by specifies color screen. nil is disabled.

    colorType

    Specifies the color type that should be matted, 0green, 1blue, 2cyan, 3purple, 4yellow, 5red, default is 0.

    threshold

    Specifies the closeness of color, [-1, 1], default is 0.

  • Choose process type for background segment.

    Declaration

    Objective-C

    - (void)setSegmentBackgroundProcessType:
        (kQueenBackgroundProcessType)backgroundProcessType;

    Parameters

    backgroundProcessType

    kQueenBackgroundProcessType, default is kQueenBackgroundBlur.

  • Choose performance mode for background segment. Note: Please call this method before using background segment function.

    Declaration

    Objective-C

    - (void)setSegmentPerformanceMode:(kQueenSegmentPerformanceMode)performanceMode;

    Parameters

    performanceMode

    kQueenSegmentPerformanceMode.

  • Set the foreground margins of the background segment.

    Declaration

    Objective-C

    - (void)setAISegmentForegroundPadding:(int)foregroundPadding;

    Parameters

    foregroundPadding

    The foreground margins, [0,15], default is 0.

“互动相关API”

  • AR writing/painting.

    Declaration

    Objective-C

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

    Parameters

    enabled

    YES/NO.

    mode

    1: write, 2: paint.

“数据处理”

  • If the detected face/body coordinates need to be flipped on the y-axis.

    Declaration

    Objective-C

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

    Parameters

    faceRenderFlipY

    Whether images that require key-positioned positions are rendered inverted, default is NO.

    faceInfoFlipY

    Whether the keypoint data is flipped, default is NO.

  • Process QEPixelBufferData.

    Declaration

    Objective-C

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

    Parameters

    pixelBufferData

    Data should be processed.

    Return Value

    kQueenResultCode.

  • Process QETextureData.

    Declaration

    Objective-C

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

    Parameters

    textureData

    Data should be processed.

    Return Value

    kQueenResultCode.

  • For image data analysis. Note: If processing textureData, this method should be called, otherwise this method should not be called.

    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

    Specifies the image raw data.

    format

    Specifies the color space.

    width

    Specifies the image width.

    height

    Specifies the image height.

    stride

    Specifies the stride (in pixels) of the image, i.e. the number of bytes per line, default is 0.

    intputAngle

    Specifies the rotation angle of the bufferIn by which the face/body (if any) in the bufferIn needs to be rotated clockwise to the frontal face/body. Examples are 0/90/180/270, default is 0. Note: Only takes effect if QueenEngineConfigInfo’s member variable autoSettingImgAngle is set to NO.

    outputAngle

    Specifies the rotation angle by which the detected frontal face/body needs to be rotated counterclockwise. Examples are 0/90/180/270, default is 0. Note: Only takes effect if QueenEngineConfigInfo’s member variable autoSettingImgAngle is set to NO. In general, the value set should be consistent with the inputAngle, so that the coordinate position of the recognized face/human body result fits the original image.

    flipAxis

    The direction in which the detected face/body coordinates need to be flipped, 0 do nothing,1 Flip on the x-axis, 2 Flip on the y-axis.

“调试相关”

  • Show key points for face.

    Declaration

    Objective-C

    - (void)showFaceDetectPoint:(BOOL)show;

    Parameters

    show

    YES/NO.

  • Show key points for body.

    Declaration

    Objective-C

    - (void)showBodyDetectPoint:(BOOL)show;

    Parameters

    show

    YES/NO.

  • Show key points for hand.

    Declaration

    Objective-C

    - (void)showHandDetectPoint:(BOOL)show;

    Parameters

    show

    YES/NO.

  • Show lines for face.

    Declaration

    Objective-C

    - (void)showMakeupLine:(BOOL)show;

    Parameters

    show

    YES/NO.

  • Show key points for ar writing/painting.

    Declaration

    Objective-C

    - (void)showARWritingDetectPoint:(BOOL)show;

    Parameters

    show

    YES/NO.