554325746@qq.com
2019-08-07 2539f53391765abb74b6fe63f46e5a2c701e950f
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
package com.basic.security.manager;
 
import android.os.SystemClock;
 
import com.basic.security.activity.MainActivity;
import com.basic.security.base.BaseApplication;
import com.basic.security.manager.helper.rm.fragment.CurrentAccountSetting;
import com.basic.security.manager.helper.rm.fragment.CurrentAdminFaceLogin;
import com.basic.security.manager.helper.rm.base.CurrentBase;
import com.basic.security.manager.helper.rm.fragment.CurrentDoorAccessResult;
import com.basic.security.manager.helper.rm.fragment.CurrentHome;
import com.basic.security.manager.helper.rm.fragment.CurrentPersonManger;
import com.basic.security.manager.helper.rm.fragment.CurrentSignUpSuccess;
import com.basic.security.manager.helper.rm.fragment.CurrentSuAutoNicWaitDetail;
import com.basic.security.manager.helper.rm.fragment.CurrentSuAutoWaitIdCard;
import com.basic.security.manager.helper.rm.fragment.CurrentSuLoggedIcCompareSuccess;
import com.basic.security.manager.helper.rm.fragment.CurrentSuLoggedIcWaitFace;
import com.basic.security.manager.helper.rm.fragment.CurrentSuLoggedIcWaitIdCard;
import com.basic.security.manager.helper.rm.fragment.CurrentSuLoggedNicWaitDetail;
import com.basic.security.manager.helper.rm.fragment.CurrentSuLoggedNicWaitFace;
import com.basic.security.manager.helper.rm.fragment.CurrentSuLoggedWaitFace;
import com.basic.security.manager.helper.rm.fragment.CurrentSuAutoWaitAdmin;
import com.basic.security.manager.helper.rm.fragment.CurrentSuAutoWaitFace;
import com.basic.security.manager.helper.rm.fragment.CurrentVerifyIDCardSuccess;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
 
public class RecognizeManager {
    public static final Lock recongizeLock = new ReentrantLock();
    public static Map<Long, Map> trackerIdValidIdentityMap = new ConcurrentHashMap<>();
 
    public static List<CurrentBase> currentList = new ArrayList<>();
 
    public static void restartWaitFace() {
        if (recongizeLock.tryLock()) {
            try {
                CurrentBase.detectedResult = null;
                DetectResultManager.detectedResult = null;
                CompareFeatureResultManager.clear();
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                recongizeLock.unlock();
            }
        }
 
    }
 
    private static void makeChains() {
        currentList.add(new CurrentSuAutoWaitFace());
        currentList.add(new CurrentHome());
        currentList.add(new CurrentAdminFaceLogin());
        currentList.add(new CurrentSuLoggedNicWaitFace());
        currentList.add(new CurrentSuLoggedIcWaitFace());
        currentList.add(new CurrentAccountSetting());
        currentList.add(new CurrentSuAutoWaitAdmin());
        currentList.add(new CurrentSuAutoWaitIdCard());
        currentList.add(new CurrentSuLoggedIcWaitIdCard());
        currentList.add(new CurrentSuAutoNicWaitDetail());
        currentList.add(new CurrentSignUpSuccess());
        currentList.add(new CurrentPersonManger());
        currentList.add(new CurrentSuLoggedWaitFace());
        currentList.add(new CurrentSuLoggedNicWaitDetail());
        currentList.add(new CurrentSuLoggedIcCompareSuccess());
        currentList.add(new CurrentVerifyIDCardSuccess());
        currentList.add(new CurrentDoorAccessResult());
    }
 
    public static void processRecognizeResult() {
        new Thread(){
            public void run() {
                while(true) {
                    SystemClock.sleep(200);
                    CurrentBase.activity = (MainActivity) BaseApplication.getApplication().activity;
                    if (CurrentBase.activity != null && CurrentBase.activity.mainActivityInitComplete) {
                        makeChains();
                        break;
                    }
                }
                IdCardManager.startReadIdCard();
                while(true) {
                    try {
                        recongizeLock.lock();
                        if (MainActivity.faceDbInitComplete && CurrentBase.activity.shouldDetectFace()) {
                            CurrentBase.startNewDetectResult();
                            for (CurrentBase currentBase : currentList) {
                                if (currentBase.showFragment()) {
                                    break;
                                }
                            }
                        }
                        CurrentBase.activity.needTimeoutToBlank();
                        CurrentBase.showFragmentSuccess = false;
                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {
                        recongizeLock.unlock();
                    }
                    try {
                        if (CurrentBase.shouldSleepRecognizeThread) {
                            SystemClock.sleep(100);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }.start();
    }
 
}