예제 #1
0
        //        enum FingerListEnum { li, lm, lr, ll, ri, rm, rr, rl, lt, rt }
        public UInt32 run(String regionName)
        {
            var matcher = new BioProcessor.BioProcessor();

            try {
                matcher.enrollProbeTemplate(_fingerList, _probeTemplate);

                byte[][] buffer = new byte[10][];
                //int rowNumber = 0;
                UInt32 retcode = 0;
                foreach (KeyValuePair<string, object> item in _cache.GetObjectsInRegion(regionName))
                {
                    //if (_gender == 1 && Regex.IsMatch(item.Key, "m$") ||
                    //    _gender == 2 && Regex.IsMatch(item.Key, "w$") ||
                    //    _gender == 0)

                    if (_gender == 1 && item.Key.EndsWith("m") ||
                        _gender == 2 && item.Key.EndsWith("w") ||
                        _gender == 0)
                    {

                        //short numOfMatches = 0;
                        bool matched = false;
                        //rowNumber++;
                        //continue;
                        //if (rowNumber % 1000 == 0)
                        //    Console.WriteLine("Region name: {0}, row number: {1}", regionName, rowNumber);

                        //if (_ct.IsCancellationRequested)
                        //{
                        _ct.ThrowIfCancellationRequested();
                        //}

                        //int i = 0;
                        //if (Regex.Replace(item.Key, ".$", "") == "20005140")
                            //matched = true;

                        matched = matcher.match(_fingerList, item.Value as byte[][]);
                        if (matched)
                        {
                            retcode = UInt32.Parse(Regex.Replace(item.Key, ".$", ""));
                            break;
                        }
                    }
                }

                return retcode;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
            finally
            {
                matcher.CleanBiometrics();
            }
        }
예제 #2
0
        public int iterateCache(String regionName)
        {
            Stopwatch st = new Stopwatch();
            st.Start();

            var matcher = new BioProcessor.BioProcessor();
            matcher.enrollProbeTemplate(_probeTemplate);

            byte[][] buffer = new byte[10][];
            int rowNumber = 0;
            int retcode = 0;
            foreach (KeyValuePair<string, object> item in _cache.GetObjectsInRegion(regionName))
            {
                short numOfMatches = 0;
                bool matched = false;
                rowNumber++;
                //continue;
                //if (rowNumber % 1000 == 0)
                //    Console.WriteLine("Region name: {0}, row number: {1}", regionName, rowNumber);

                if (_ct.IsCancellationRequested)
                {
                    _ct.ThrowIfCancellationRequested();
                }

                //if (item.Key == "123")
                //if( false)
                {
                    buffer = item.Value as byte[][];
                    //for (int i = 0; i < buffer.Length; i++)
                    foreach(string finger in _fingerList)
                    {
                        FingerListEnum f = (FingerListEnum)Enum.Parse(typeof(FingerListEnum), finger);
                        if (buffer[(int)f] != null && (buffer[(int)f]).Length != 0)
                        {
                            matched = matcher.match(buffer[(int)f]);
                            if (matched)
                            {
                                numOfMatches++;
                            }
                        }
                    }

                    if (_fingerList.Count == numOfMatches)
                    {
                        retcode = int.Parse(item.Key);
                        break;
                    }
                }
            }

            //Console.WriteLine("====== Region name: {0}, row number: {1}", regionName, rowNumber);

            st.Stop();
            Console.WriteLine(" ----- Region name \"{0}\",  time elapsed: {1}", regionName, st.Elapsed);

            return retcode;
        }