/* * private void OnCreationCompleted(IAsyncResult r) * { * lock (locker) * { * try * { * NBiometricStatus status = _biometricClient.EndCreateTemplate(r); * if (status != NBiometricStatus.Ok) * { * MessageBox.Show(string.Format("The template was not extracted: {0}.", status)); * } * // EnableVerifyButton(); * } * catch (Exception ex) * { * Utils.ShowException(ex); * } * } * }*/ private string OpenImageTemplate(NFaceView faceView, out NSubject subject) { string savePath = Server.MapPath("~/image/");//指定上传文件在服务器上的保存路径; if (FileUpload1.PostedFile.FileName != null) { if (FileUpload1.HasFile) { //检查服务器上是否存在这个物理路径,如果不存在则创建 if (!System.IO.Directory.Exists(savePath)) { System.IO.Directory.CreateDirectory(savePath); } savePath = savePath + "\\" + FileUpload1.FileName; FileUpload1.SaveAs(savePath); } } subject = null; faceView.Face = null; // msgLabel.Text = string.Empty; string fileLocation = string.Empty; // openFileDialog.FileName = null; // openFileDialog.Title = @"Open Template"; // if (openFileDialog.ShowDialog() == DialogResult.OK) // load template { fileLocation = savePath; // Check if given file is a template try { subject = NSubject.FromFile(savePath); // EnableVerifyButton(); } catch { } // If file is not a template, try to load it as image if (subject == null) { // Create a face object NFace face = new NFace() { FileName = fileLocation }; faceView.Face = face; subject = new NSubject(); subject.Faces.Add(face); // Extract a template from the subject nle.CreateTemplate(subject); } } //subject.Dispose(); return(fileLocation); }
public ImageForm(PictureBox destinationImage) { InitializeComponent(); try { //Activating Biometrics Licenses IList <string> licenses = new List <string>(new [] { "FacesExtractor", "FacesBSS" }); AppUtils.ObtainLicenses(licenses); //Create a MegaMatcher Biometrics extractor Instance // extractor1 = new NFExtractor(); // matcher = new NFMatcher(); // currentImagesCaptured = getdestination; facesView = new NLView(); facesView.Click += new EventHandler(facesView_Click); facesView.Visible = true; facesView.Anchor = AnchorStyles.Left; facesView.Size.Height.Equals(467); facesView.Size.Width.Equals(350); facesView.Dock = DockStyle.Fill; target.Controls.Add(facesView); this._destinationImage = destinationImage; CropWidth = 350; CropHeight = 467; DestinationImageWidth = 176; DestinationImageHeight = 176; _nfView = new NFView { Height = 0, Width = 0 }; } catch (Exception ex) { MessageBox.Show(@"License", @"Biometric", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }