SHARE
TWEET

Untitled

a guest May 19th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public Person? Clasify(byte [] image)
  2.         {
  3.             var featureVector = ExractFeatureVector(_waveletTransformer.Transform(image, _settings.Classficator.Ocataves, TransformFunction.Haar));
  4.  
  5.             var existingVectors = _personService
  6.                 .ReadAll(p => p.Include(o => o.Fingerprints).ThenInclude(o => o.Vector))
  7.                 .SelectMany(p => p.Fingerprints)
  8.                 .Select(f =>
  9.                             new {
  10.                                 Person =  f.Owner,
  11.                                 Vector = TransformFunction.Haar.GetFeatureVectorFiled(f.Vector),
  12.                                 Distance = CalculateDistance(TransformFunction.Haar.GetFeatureVectorFiled(f.Vector), featureVector)
  13.                             });
  14.  
  15.             return existingVectors?.OrderBy(v => v.Distance).Take(_settings.Classficator.K).GroupBy(v => v.Person).Max().Key;
  16.         }
  17.        
  18.         public Fingerprint Train(Fingerprint fingerprint)
  19.         {
  20.             var result = new FeatureVector();
  21.             foreach (var function in new TransformFunction[] { TransformFunction.Haar, TransformFunction.D4 })
  22.             {
  23.                 var value = _waveletTransformer.Transform(fingerprint.Image, _settings.Classficator.Ocataves, function);
  24.                 function.SetFeatureVectorField(result, ExractFeatureVector(value));
  25.                 _logger.LogInformation($"Vector generated for {fingerprint.Hand} - {fingerprint.Finger} for function {function.ToString()}.");
  26.             }
  27.             fingerprint.Vector = result;
  28.             return fingerprint;
  29.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top