package com.sensetime.demo.bean;

import android.graphics.Rect;

import com.sensetime.demo.SenseTimeMtc;

public enum FaceStatus {
    AI_STATUS_UNDEFINE(-1),
    AI_STATUS_UNKNOWN(0),
    AI_STATUS_NONLIVENESS(1),
    AI_STATUS_USER(2),
    AI_STATUS_STRANGER(3),
    AI_STATUS_ALREADY(4),
    AI_STATUS_VERIFY_PASS(5),
    AI_STATUS_VERIFY_FAILED(6);

    private int status;

    FaceStatus(int status) {
        this.status = status;
    }

    public int getStatus() {
        return status;
    }


    public static FaceStatus getByStatus(int status) {
        for (FaceStatus fs : values()) {
            if (fs.getStatus() == status) {
                return fs;
            }
        }
        return AI_STATUS_UNDEFINE;
    }

    public static Rect calcShowRect(Rect r) {
        SenseTimeMtc senseTimeMtc = SenseTimeMtc.getInstance();

        int right, left;
        if (SenseTimeMtc.getInstance().getIsIRRGBMode() == SenseTimeMtc.RGB && SenseTimeMtc.getInstance().getIsMirror() == 0x01) {
            // 左右非镜像
            right = (r.right + 5) * senseTimeMtc.getPreviewWidth() / 720;
            left = (r.left - 5) * senseTimeMtc.getPreviewWidth() / 720;
        } else {
            //左右镜像 before V3.0.0 TextureView
           /* if (SenseTimeMtc.getInstance().getmDeviceModule() == SenseTimeMtc.M30) {
                right = (r.right + 5) * senseTimeMtc.getPreviewWidth() / 720;
                left = (r.left - 5) * senseTimeMtc.getPreviewWidth() / 720;
            } else {
                right = (720 - (r.left - 5)) * senseTimeMtc.getPreviewWidth() / 720;
                left = (720 - (r.right + 5)) * senseTimeMtc.getPreviewWidth() / 720;
            }*/
            right = (720 - (r.left - 5)) * senseTimeMtc.getPreviewWidth() / 720;
            left = (720 - (r.right + 5)) * senseTimeMtc.getPreviewWidth() / 720;
        }

        int top = (r.top - 5) * senseTimeMtc.getPreviewHeight() / 1280;
        int bottom = (r.bottom + 5) * senseTimeMtc.getPreviewHeight() / 1280;

        return new Rect(left, top, right, bottom);//NOTE mirror image
//            return new Rect(r.left - 25, r.top - 45, r.right + 25, r.bottom + 20);
    }
}