public void Dispose() { NLicense.ReleaseComponents(components); if (extractor != null) { extractor.Dispose(); } }
private bool createTemplate(Bitmap enrollmentBmp, bool largeTemplate, out NleDetectionDetails detDetails) { NLExtractor templateExtractor = new NLExtractor(); if (largeTemplate) { templateExtractor.TemplateSize = NleTemplateSize.Large; } else { templateExtractor.TemplateSize = NleTemplateSize.Medium; } NImage enrollmentImage = NImage.FromBitmap(enrollmentBmp); NGrayscaleImage enrollmentGrayscale = enrollmentImage.ToGrayscale(); NleDetectionDetails _detDetails = null; try { verifyLicense(); NleExtractionStatus extractionStatus; facialTemplate = templateExtractor.Extract(enrollmentGrayscale, out _detDetails, out extractionStatus); if (extractionStatus != NleExtractionStatus.TemplateCreated) { MessageBox.Show("Face Template Extraction Failed!\nPlease try again.\n" + extractionStatus.ToString()); detDetails = _detDetails; return(false); } else { detDetails = _detDetails; return(true); } } catch (Exception ex) { MessageBox.Show("" + ex); detDetails = null; return(false); } finally { NLicense.ReleaseComponents(Components); if (templateExtractor != null) { templateExtractor.Dispose(); } } }