Score
0
Watch 2 Star 19 Fork 8

OAL / TengineKitAndroidApache-2.0

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
Clone or download
Api.md 8.70 KB
Copy Edit Web IDE Raw Blame History
crusoekid authored 2020-08-13 15:56 . update

API

The located Function under com.tenginekit.

init

Parameter

  • context: context in activity,
  • config: AndroidConfig is the config of work
    Face.init(Context context, AndroidConfig config);

For example, set the default configuration like this.

    Face.init(context,
            AndroidConfig
                .create()
                .setCameraMode()
                .setDefaultFunc()
                .setDefaultInputImageFormat()
                .setInputImageSize(previewWidth, previewHeight)
                .setOutputImageSize(OutputWidth, OutputHeight)
        );

AndoridConfig

.create() First create an AndroidConfig.

Configuration mode:

.setNormalMode() Set to normal mode
.setCameraMode() Set to camera mode(This mode will automatically rotate the picture according to the front and rear camera)
.setHandleMode(HandleMode mHandleMode) Parameter transmission mode setting mode

    public enum HandleMode{
        Normal, // Normal mode
        Camera // Camera mode
    }

Configure input picture format:

.setDefaultInputImageFormat() Set the default picture format (YUV_NV21)
.setInputImageFormat(ImageFormat imageFormat) Parameter transmission mode to set input picture format

    public enum ImageFormat
    {
        YUV_NV21,
        RGB,
        RGBA,
        GRAY
    }

Configure input and output:

.setInputImageSize(int w, int h) Input width and height (preview_w, preview_h)
.setOutputImageSize() Output width and height (display size)

Configuration function (functions are based on image detection):

.setDefaultFunc() Set default functions (face detection and key points)
.openFunc(Func func) Pass parameter setting function (image detection must be set to AndroidConfig.Func.Detect or AndroidConfig.Func.BlazeFace)

    public enum Func
    {
        Detect,
        Landmark,
        Attribution,
        BlazeFace,
        FaceMesh,
    }

Tips:BlazeFace, FaceMesh models are from Google,The project address is:https://github.com/google/mediapipe

get detect infos

Since all functions are based on face detection, first create an object of Face.FaceDetect. Detect detection will be faster, BlazeFace will be more accurate and the angle can be larger (BlazeFace is based on the Google model). Will eventually return a FaceDetectInfo list;

Parameter

  • imageData: Input data
    Face.FaceDetect faceDetect = Face.detect(imageData);
    List<FaceDetectInfo> faceDetectInfos = faceDetect.getDetectInfos();

get landmark infos

The face key point function is based on face detection, so the landmark information acquisition method should be based on the Face.FaceDetect object created earlier. Finally returns a FaceLandmarkInfo list;

    List<LandmarkInfo> landmarkInfos = faceDetect.landmark2d();;

get 3D landmark infos(This feature is based on Google model)

The face key point function is based on face detection, so the 3d landmark information acquisition method should be based on the Face.FaceDetect object created earlier. Finally returns a FaceLandmark3dInfo list;

    List<FaceLandmark3dInfo> landmarkInfos = faceDetect.landmark3d();;

get attribution infos

The attribute function is based on face detection, so the method of obtaining attribute information is based on the Face.FaceDetect object created earlier. Finally returns a FaceAttributionInfo list;

    List<AttributionInfo> attributionInfos = faceDetect.attribution();

switch camera

Switching cameras is only useful when in camera mode.

Parameter

  • back:Whether it is a rear camera
    Face.Camera.switchCamera(boolean back); 

set rotation

Setting rotation is only useful in camera mode.

Parameter

  • ori: Rotation angle (vertical to 0°)
  • isScreenRotate: whether the display area follows rotation
  • outputW: show width
  • outputH: show height
    Face.Camera.setRotation(int ori, boolean isScreenRotate, int outputW, int outputH);

release

    FaceManager.getInstance().release();

Data structure

FaceDetectInfo

Parameter name Parameter type Comment
top int Distance display upper edge distance
bottom int Distance display bottom edge distance
left int Distance shows the distance of the left edge
right int Distance display right edge distance
width int Face rect width
height int Face rect height

.asRect() is a method in FaceDetectInfo, which can directly return an object of class Rect.

FaceLandmarkInfo

Parameter name Parameter type Comment
landmarks List Face key point information 212 points
pitch float Human face pitch direction corner
yaw float Human face yaw direction corner
roll float Human face roll direction corner
leftEyeClose float Left eye closure confidence 0~1
rightEyeClose float Right eye closure confidence 0~1
mouseClose float Mouth closure confidence 0~1
mouseOpenBig float Open mouth Big confidence 0~1

FaceLandmark3dInfo

Parameter name Parameter type Comment
landmarks List Face key point information 468 points

FaceAttributionInfo

Parameter name Parameter type Comment
age int Age
isMan boolean Is it male
smile int Smile degree0~100
glasses boolean Whether to wear glasses
beatyOfManLook int Face value from a male perspective
beautyOfWomanLook int Face value from a female perspective

FaceLandmarkPoint

Parameter name Parameter type Comment
x float Point x position
y float Point y position

ImageHandleApi

Parameter

  • bitmap: Android picture
  • inputX1: input the upper left corner of the picture x
  • inputY1: input image in the upper left corner y
  • inputX2: Enter the bottom right corner of the picture x
  • inputY2: Enter the lower right corner of the picture y
  • ouputW: width of output picture
  • outputH: the height of the output picture
  • rotation: rotation angle
  • mirror: whether to mirror
    synchronized static public Bitmap convertImage(Bitmap bitmap,
                                    int inputX1, int inputY1, int inputX2, int inputY2,
                                    int outputW, int outputH, int rotation, boolean mirror);

Parameter

  • data: input picture byte data
  • imageOutputFormat: output image format
  • ouputW: width of output picture
  • outputH: the height of the output picture
  • rotation: rotation angle
  • mirror: whether to mirror
    synchronized static public byte[] convertCameraYUVData(byte[] data,
                                    AndroidConfig.ImageFormat imageOutputFormat,
                                    int inputW, int inputH,
                                    int outputW, int outputH, int rotation, boolean mirror

Parameter

  • data: input picture byte data
  • inputW: input picture width
  • inputH: input image height
  • ouputW: width of output picture
  • outputH: the height of the output picture
  • rotation: rotation angle
  • mirror: whether to mirror
    synchronized static public Bitmap convertCameraYUVData(byte[] data,
                                    int inputW, int inputH,
                                    int outputW, int outputH,
                                    int rotation, boolean mirror

Parameter

  • data: input picture byte data
  • imageInputFormat: input image format
  • imageOutputFormat: output image format
  • inputW: input picture width
  • inputH: input image height
  • inputX1: input the upper left corner of the picture x
  • inputY1: input image in the upper left corner y
  • inputX2: Enter the bottom right corner of the picture x
  • inputY2: Enter the lower right corner of the picture y
  • ouputW: width of output picture
  • outputH: the height of the output picture
  • rotation: rotation angle
  • mirror: whether to mirror
    synchronized static public byte[] convertImage(byte[] data,
                                    AndroidConfig.ImageFormat imageInputFormat, AndroidConfig.ImageFormat imageOutputFormat,
                                    int inputW, int inputH,
                                    int inputX1, int inputY1, int inputX2, int inputY2,
                                    int outputW, int outputH, int rotation, boolean mirror

Comment ( 0 )

Sign in for post a comment