a
554325746@qq.com
2019-12-25 603cb36a5123e46656b06a5deb8d7ac7ff81307f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package com.basic.security.manager;
 
import android.text.TextUtils;
 
import com.basic.security.model.HintRecognizeMessage;
import com.basic.security.model.ModelAdapter;
import com.basic.security.model.Sync;
import com.basic.security.utils.Constants;
 
public class HintRecognizeManager extends BaseManager {
    public static ModelAdapter hintRecognizeMessage;
 
    public static void initHintRecognize() {
        hintRecognizeMessage = HintRecognizeManager.findById("hint_recognize_message", HintRecognizeMessage.tableName);
        if (hintRecognizeMessage == null) {
            hintRecognizeMessage = new ModelAdapter(HintRecognizeMessage.tableName);
            hintRecognizeMessage.setString("head_up", "15");
            hintRecognizeMessage.setString("head_up_message", "请低头");
            hintRecognizeMessage.setString("head_down", "15");
            hintRecognizeMessage.setString("head_down_message", "请抬头");
            hintRecognizeMessage.setString("face_max", "15");
            hintRecognizeMessage.setString("face_max_message", "请正脸对准摄像头");
            hintRecognizeMessage.setString("face_min", "15");
            hintRecognizeMessage.setString("face_min_message", "请正脸对准摄像头");
            hintRecognizeMessage.setString("rotation_left", "15");
            hintRecognizeMessage.setString("rotation_left_message", "请正脸对准摄像头");
            hintRecognizeMessage.setString("rotation_right", "15");
            hintRecognizeMessage.setString("rotation_right_message", "请正脸对准摄像头");
            hintRecognizeMessage.setString("all_fit", "请调整人脸角度和距离");
            hintRecognizeMessage.setString("device_id", DeviceManager.getDeviceId());
            hintRecognizeMessage.setString("table", "hint_recognize_message");
            hintRecognizeMessage.setString(Sync.needSync, Constants.FALSE);
            BaseManager.save(hintRecognizeMessage);
        }
    }
 
    /*得到hint设置信息*/
    public static ModelAdapter getHintRecognizeMassage() {
        return hintRecognizeMessage;
    }
 
    public static double getHeadUpAngle() {
        getHintRecognizeMassage();
        if (hintRecognizeMessage != null) {
            try {
                return -Double.parseDouble(hintRecognizeMessage.getString("head_up"));
            } catch (Exception e) {
                System1.out.println(e.getMessage());
            }
        }
        return -10;
    }
 
    public static String getHeadUpAngleMessage() {
        getHintRecognizeMassage();
        if (hintRecognizeMessage != null && !TextUtils.isEmpty(hintRecognizeMessage.getString("head_up_message"))) {
            return hintRecognizeMessage.getString("head_up_message");
        } else {
            return "请抬头";
        }
    }
 
    public static double getHeadDownAngle() {
        getHintRecognizeMassage();
        if (hintRecognizeMessage != null && !TextUtils.isEmpty(hintRecognizeMessage.getString("head_down"))) {
            try {
                return Double.parseDouble(hintRecognizeMessage.getString("head_down"));
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
        }
        return 15;
    }
 
    public static String getHeadDownAngleMessage() {
        getHintRecognizeMassage();
        if (hintRecognizeMessage != null && !TextUtils.isEmpty(hintRecognizeMessage.getString("head_down_message"))) {
            return hintRecognizeMessage.getString("head_down_message");
        } else {
            return "请低头";
        }
    }
 
    public static double getFaceMaxAngle() {
        getHintRecognizeMassage();
        if (hintRecognizeMessage != null && !TextUtils.isEmpty(hintRecognizeMessage.getString("face_max"))) {
            try {
                String face_max = hintRecognizeMessage.getString("face_max");
                if (!TextUtils.isEmpty(face_max)) {
                    return Double.parseDouble(face_max);
                }
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
        }
        return 0.2;
    }
 
    public static String getFaceMaxAngleMessage() {
        getHintRecognizeMassage();
        if (hintRecognizeMessage != null && !TextUtils.isEmpty(hintRecognizeMessage.getString("face_max_message"))) {
            return hintRecognizeMessage.getString("face_max_message");
        } else {
            return "请向后站";
        }
    }
 
    public static double getFaceMinAngle() {
        getHintRecognizeMassage();
        if (hintRecognizeMessage != null && !TextUtils.isEmpty(hintRecognizeMessage.getString("face_min"))) {
            try {
                return Double.parseDouble(hintRecognizeMessage.getString("face_min"));
            } catch (NumberFormatException e) {
            }
        }
        return 0.2;
    }
 
    public static String getFaceMinAngleMessage() {
        getHintRecognizeMassage();
        if (hintRecognizeMessage != null && !TextUtils.isEmpty(hintRecognizeMessage.getString("face_min_message"))) {
            return hintRecognizeMessage.getString("face_min_message");
        } else {
            return "请向前站";
        }
    }
 
    public static double getLeftRotationAngle() {
        getHintRecognizeMassage();
        if (hintRecognizeMessage != null && !TextUtils.isEmpty(hintRecognizeMessage.getString("rotation_left"))) {
            try {
                return -Double.parseDouble(hintRecognizeMessage.getString("rotation_left"));
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
        }
        return -10;
    }
 
    public static String getLeftRotationMessage() {
        getHintRecognizeMassage();
        if (hintRecognizeMessage != null && !TextUtils.isEmpty(hintRecognizeMessage.getString("rotation_left_message"))) {
            return hintRecognizeMessage.getString("rotation_left_message");
        } else {
            return "请向左看";
        }
    }
 
    public static double getRightRotationAngle() {
        getHintRecognizeMassage();
        if (hintRecognizeMessage != null && !TextUtils.isEmpty(hintRecognizeMessage.getString("rotation_right"))) {
            try {
                return Double.parseDouble(hintRecognizeMessage.getString("rotation_right"));
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
        }
        return 10;
    }
 
    public static String getRightRotationMessage() {
        getHintRecognizeMassage();
        if (hintRecognizeMessage != null && !TextUtils.isEmpty(hintRecognizeMessage.getString("rotation_right_message"))) {
            return hintRecognizeMessage.getString("rotation_right_message");
        } else {
            return "请向右看";
        }
    }
 
    public static String getAllFit() {
//        System1.out.println("HintRecognizeManager.getAllFit " + FrameUtil.getFrames());
        getHintRecognizeMassage();
        if (hintRecognizeMessage != null && !TextUtils.isEmpty(hintRecognizeMessage.getString("all_fit"))) {
            return hintRecognizeMessage.getString("all_fit");
        } else {
            return "";
        }
    }
 
    public static void saveHintRecognize(ModelAdapter hintRecognize) {
        hintRecognizeMessage = hintRecognize;
        BaseManager.save(hintRecognize);
    }
}