示例#1
0
		async  Task<ViewQueryResponse<string>> GetPersonListAsync ()
		{
			List<MyPerson> database = new List<MyPerson>();
			string sourceDirectory = @"/Users/chrisk/source/KiwiRest/RestFiles/App_Data/files";
			AfisEngine Afis = new AfisEngine();
			DateTime date1 = DateTime.Now;
			Console.WriteLine("Starting PersonList:  " + date1);
			WebClient client = new WebClient ();
			string uri = "http://localhost:5984/prints/_all_docs&include_docs=true";
			//			string data = client.DownloadString (uri);
			//			var fromJson = JsonSerializer.DeserializeFromString<AllDocs>(data);
			var myCouchClient = new MyCouch.MyCouchClient("http://localhost:5984/prints");
			ViewQueryResponse<string> result = null;
			try 
			{
				var queryView = new QueryViewRequest("_all_docs");
				queryView.Configure(query => query
					.IncludeDocs(true));
				result = await myCouchClient.Views.QueryAsync<string>(queryView);
			}
			catch (Exception e) {
			}

			return result;
		}
//		static AfisEngine Afis = new AfisEngine();

//		// Inherit from Fingerprint in order to add Filename field
//		[Serializable]
//		class MyFingerprint : Fingerprint
//		{
//			public string Filename;
//		}
//
//		// Inherit from Person in order to add Name field
//		[Serializable]
//		class MyPerson : Person
//		{
//			public string Name;
//		}

		// Take fingerprint image file and create Person object from the image
		public static MyPerson Enroll(string filename, string name, AfisEngine Afis)
		{
			Console.WriteLine("Enrolling {0}...", name);

			// Initialize empty fingerprint object and set properties
			MyFingerprint fp = new MyFingerprint();
			fp.Filename = filename;
			// Load image from the file
			Console.WriteLine(" Loading image from {0}...", filename);
			//            BitmapImage image = new BitmapImage(new Uri(filename, UriKind.RelativeOrAbsolute));
			Bitmap image = (Bitmap) Image.FromFile(@filename, true);
			//			Bitmap image = Bitmap.FromFile(@filename, true);

			fp.AsBitmap = image;
			// Above update of fp.AsBitmapSource initialized also raw image in fp.Image
			// Check raw image dimensions, Y axis is first, X axis is second
			Console.WriteLine(" Image size = {0} x {1} (width x height)", fp.Image.GetLength(1), fp.Image.GetLength(0));

			// Initialize empty person object and set its properties
			MyPerson person = new MyPerson();
			person.Name = name;
			person.Uuid = name;
			// Add fingerprint to the person
			person.Fingerprints.Add(fp);

			// Execute extraction in order to initialize fp.Template
			Console.WriteLine(" Extracting template...");
			Afis.Extract(person);
			// Check template size
			Console.WriteLine(" Template size = {0} bytes", fp.Template.Length);

			return person;
		}
示例#3
0
	     public static List<MyPerson> GetPersonList ()
		{
			List<MyPerson> database = new List<MyPerson>();
			string sourceDirectory = @"/Users/chrisk/source/KiwiRest/RestFiles/App_Data/files";
			AfisEngine Afis = new AfisEngine();
			DateTime date1 = DateTime.Now;
			Console.WriteLine("Starting PersonList:  " + date1);
			WebClient client = new WebClient ();
			string uri = "http://localhost:5984/prints/_all_docs&include_docs=true";
//			string data = client.DownloadString (uri);
//			var fromJson = JsonSerializer.DeserializeFromString<AllDocs>(data);
			var myCouchClient = new MyCouch.MyCouchClient("http://localhost:5984/prints");
			try 
			{
				var queryView = new QueryViewRequest("_all_docs");
				queryView.Configure(query => query
					.IncludeDocs(true));
			}
			catch (Exception e) {
			}

			try
			{
				var files = Directory.EnumerateFiles(sourceDirectory, "*.png");

				foreach (string currentFile in files)
				{
					DateTime date3 = DateTime.Now;
					Console.WriteLine("Processing " + currentFile + " at " + date3);
					string fileName = currentFile.Substring(sourceDirectory.Length + 1);
					//					Directory.Move(currentFile, Path.Combine(archiveDirectory, fileName));
					Guid g = Guid.NewGuid ();
					var guidStr = g.ToString ();
					MyPerson probe = SourceAfisIdentify.Enroll (currentFile, guidStr, Afis);
					Console.WriteLine("Adding " + guidStr);
					DateTime date4 = DateTime.Now;
					Console.WriteLine("Processed  " + currentFile + " at " + date4 + " uuid: " + guidStr);
					var diffInSeconds = (date4 - date3).TotalSeconds;
					Console.WriteLine("Finished " + guidStr + " at " + date4 + " Total time: " + diffInSeconds + " seconds");
					database.Add (probe);
				}
				DateTime date2 = DateTime.Now;
				var diffInSeconds2 = (date2 - date1).TotalSeconds;
				Console.WriteLine("Finished PersonList at " + date2 + " Total time: " + diffInSeconds2 + " seconds");
			}
			catch (Exception e)
			{
				Console.WriteLine(e.Message);
			}

			return database;
		}
示例#4
0
        static void Main(string[] args)
        {
            //var t = HexString2.Split().Select(s => Convert.ToByte(s, 16)).ToArray();
            var t = StringToByteArray(HexFromTemplate);

            var afisEngine = new AfisEngine();
            var enrollPrint = new Fingerprint { AsIsoTemplate = t };
            var enrollPerson = new Person(enrollPrint);
            var verifyPrint = new Fingerprint { AsIsoTemplate = t };
            var verifyPerson = new Person(verifyPrint);

            var matchScore = afisEngine.Verify(enrollPerson, verifyPerson);

            Console.WriteLine("Template length: {0}", enrollPrint.Template.Length);
            Console.WriteLine("Matching Score: {0}", matchScore);
            Console.WriteLine("Finished");
            Console.ReadLine();
        }
示例#5
0
        public UpdateFingerPrint(uint scannerAddr, string username)
        {
            InitializeComponent();
            lblStatus.Text = String.Empty;
            lblTargetUsername.Text = "Tên người dùng: " + username;

            fingerImageFile = null;

            _person1 = null;
            _person2 = null;

            afis = new AfisEngine();

            cbxFingerPosition.DataSource = FingerPositionDictionary.getList();
            cbxFingerPosition.DisplayMember = "Value";
            cbxFingerPosition.ValueMember = "Key";

            cbxFingerPosition.SelectedIndex = 5;

            _scannerAddr = scannerAddr;

            backgroundWorker.RunWorkerAsync();
        }
示例#6
0
        public Home()
        {
            //init for client info
            username = MainForm.username;
            loginTime = MainForm.loginTime.ToShortTimeString();
            deviceCount = "0";

            try
            {
                UserInfoTableAdapter userInfoTA = new UserInfoTableAdapter();
                int? userCount_ = userInfoTA.GetCount();
                if (userCount_ == null)
                {
                    userCount_ = 0;
                }
                userCount = userCount_.Value.ToString();

                int? fingerPrintCount_ = (int?)userInfoTA.GetUsingFingerPrintCout();
                if (fingerPrintCount_ == null)
                {
                    fingerPrintCount_ = 0;
                }
                fingerPrintCount = fingerPrintCount_.Value.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi khi tải dữu liệu.");
                Log.ErrorLog(ex.Message);
            }

            transactionCount = "0";
            transactionToServerCount = "0";

            InitializeComponent();

            ReloadClientInfo();

            afis = new AfisEngine();
            afis.Threshold = 25;

            fingerPrintDB = null;
            lastUpdatedFingerPrintDB = null;

            bwLoadFingerPrints = new BackgroundWorker();
            bwLoadFingerPrints.DoWork += new DoWorkEventHandler(bwLoadFingerPrints_DoWork);
            bwLoadFingerPrints.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwLoadFingerPrints_RunWorkerCompleted);

            //invisible the HorizontalScroll
            this.flpnlDevices.HorizontalScroll.Maximum = 0;
            this.flpnlDevices.AutoScroll = false;
            this.flpnlDevices.VerticalScroll.Visible = false;
            this.flpnlDevices.AutoScroll = true;

            devices = new List<DeviceModel>();
            pnlDeviceList = new List<Panel>();
            usingMealSetList = new List<KeyValuePair<int, string>>();

            usingMealSetList.Add(new KeyValuePair<int, string>(0, "<<Không có>>"));
        }
示例#7
0
        /// <summary>
        ///     Verify a candidates fingerprint
        /// </summary>
        /// <param name="c">The candidate to compare against</param>
        /// <param name="fp">The provided fingerprint</param>
        /// <returns>A float from 0 to 100 which represents the strength of the fingerprint match. Higher is better.</returns>
        public static float VerifyFingerprint(Candidate c, Fingerprint fp)
        {
            var afis = new AfisEngine();

            var test = new Person(fp);
            afis.Extract(test);

            var candidate = new Person(c.Fingerprint);

            return afis.Verify(candidate, test);
        }
示例#8
0
        /// <summary>
        ///     Packs the candidate to a MessagePack objects
        ///     This method should not be called directly, use serialize instead.
        /// </summary>
        /// <param name="packer">The packer</param>
        /// <param name="options">The packer options</param>
        public void PackToMessage(Packer packer, PackingOptions options)
        {
            // pack the header for the amount of items in the map
            packer.PackMapHeader(MapCount);

            packer.Pack("DCS");
            packer.Pack(Dcs);

            packer.Pack("DAC");
            packer.Pack(Dac);

            packer.Pack("DAD");
            packer.Pack(Dad);

            packer.Pack("DBD");
            packer.Pack(Dbd.ToString(DateFormat, CultureInfo.InvariantCulture));

            packer.Pack("DBB");
            packer.Pack(Dbb.ToString(DateFormat, CultureInfo.InvariantCulture));

            packer.Pack("DBC");
            packer.Pack((int) Dbc);

            packer.Pack("DAY");
            packer.Pack(Day.AnsiFormat());

            packer.Pack("DAU");
            packer.Pack(Dau.AnsiFormat);

            packer.Pack("DAG");
            packer.Pack(Dag);

            packer.Pack("DAI");
            packer.Pack(Dai);

            packer.Pack("DAJ");
            packer.Pack(Daj);

            packer.Pack("DAK");
            packer.Pack(Dak.AnsiFormat);

            packer.Pack("DCG");
            packer.Pack(Dcg);

            // pack image
            packer.Pack("ZAA");
            var imageConverter = new ImageConverter();
            packer.Pack((byte[]) imageConverter.ConvertTo(Image, typeof (byte[])));

            // pack fingerprint
            packer.Pack("ZAB");

            if (Fingerprint.Image != null) {
                var afis = new AfisEngine();
                var p = new Person(Fingerprint);
                afis.Extract(p);
            }
            if (Fingerprint.AsIsoTemplate != null) packer.Pack(Fingerprint.AsIsoTemplate);
        }