package com.yuxue.enumtype;


/**
 * 车牌颜色
 * @author yuxue
 * @date 2020-05-08 12:38
 */
public enum PlateColor {

    BLUE("BLUE","蓝牌", 100, 130), 
    GREEN("GREEN","绿牌", 38, 100), 
    YELLOW("YELLOW","黄牌", 15, 40),
    BLACK("BLACK", "黑牌", 0, 180),
    UNKNOWN("UNKNOWN","未知", 0, 0);

    public final String code;
    public final String desc;

    // opencv颜色识别的HSV中各个颜色所对应的H的范围： Orange 0-22 Yellow 22- 38 Green 38-75 Blue 75-130
    //新增黑牌H范围0-180，S范围0-255，V范围0-46
    public final int minH;
    public final int maxH;

    PlateColor(String code, String desc, int minH, int maxH) {
        this.code = code;
        this.desc = desc;
        this.minH = minH;
        this.maxH = maxH;
    }

    public static String getDesc(String code) {
        PlateColor[] enums = values();
        for (PlateColor type : enums) {
            if (type.code().equals(code)) {
                return type.desc();
            }
        }
        return null;
    }

    public static String getCode(String desc) {
        PlateColor[] enums = values();
        for (PlateColor type : enums) {
            if (type.desc().equals(desc)) {
                return type.code();
            }
        }
        return null;
    }


    public String code() {
        return this.code;
    }

    public String desc() {
        return this.desc;
    }

}
