public static Result[] SearchSegmFree(NewImage QueryImage, ConcurrentDictionary <string, DocumentInfo> Dataset) { var myDSLPLibrary = new DoLF(); var myDSLPpoints = myDSLPLibrary.GetDSLPoints(QueryImage.Data, QueryImage.Width, QueryImage.Height, 3); var queryVector = myDSLPLibrary.CreateNormalizedDescriptorForSegmFree(myDSLPpoints); var results = new ConcurrentBag <Result>(); //Parallel.ForEach(Dataset.Keys, doc => foreach (var doc in Dataset.Keys) { var _results = myDSLPLibrary.DistanceSegmFree(queryVector, QueryImage.Width, QueryImage.Height, Dataset[doc].Descriptors); foreach (var r in _results) { results.Add(new Result { X = (short)r.Block[0], Y = (short)r.Block[1], Width = (short)r.Block[2], Height = (short)r.Block[3], Similarity = r.Similarity, Document = doc }); } } return(results.OrderBy(x => x.Similarity).ToArray()); }
public static float[] GetDescriptor(string ImageBase64) { using var memoryStream = new MemoryStream(Convert.FromBase64String(ImageBase64)) { Position = 0 }; Bitmap bmpImage = (Bitmap)Image.FromStream(memoryStream); var img = new NewImage(bmpImage); var myDSLPLibrary = new DoLF(); var myDSLPpoints = myDSLPLibrary.GetDSLPoints(img.Data, img.Width, img.Height, 3); return(myDSLPLibrary.CreateNormalizedDescriptorForSegmFree(myDSLPpoints)); }
public static ConcurrentDictionary <string, DocumentInfo> IndexingSegmBased(string[] Documents, ProgressBar myProgressBar) { var Dataset = new ConcurrentDictionary <string, DocumentInfo>(); Parallel.ForEach(Documents, doc => { var img = new NewImage(doc); var myDSLPLibrary = new DoLF(); var myDSLPpoints = myDSLPLibrary.GetDSLPoints(img.Data, img.Width, img.Height, 3); var myDocInfo = new DocumentInfo { Descriptors = myDSLPLibrary.CreateNormalizedDescriptorForSegmBased(myDSLPpoints, img.Width, img.Height), Width = img.Width, Height = img.Height }; Dataset.TryAdd(Path.GetFileNameWithoutExtension(doc), myDocInfo); myProgressBar.Increase(100d / Documents.Length); }); return(Dataset); }
public static Result[] SearchSegmBased(NewImage QueryImage, ConcurrentDictionary <string, DocumentInfo> Dataset) { var myDSLPLibrary = new DoLF(); var myDSLPpoints = myDSLPLibrary.GetDSLPoints(QueryImage.Data, QueryImage.Width, QueryImage.Height, 3); var queryVector = myDSLPLibrary.CreateNormalizedDescriptorForSegmBased(myDSLPpoints, QueryImage.Width, QueryImage.Height); var results = new ConcurrentBag <Result>(); Parallel.ForEach(Dataset.Keys, doc => { var r = myDSLPLibrary.DistanceSegmBased(queryVector, Dataset[doc].Descriptors); results.Add(new Result { X = 0, Y = 0, Width = Dataset[doc].Width, Height = Dataset[doc].Height, Similarity = r, Document = doc }); }); return(results.OrderBy(x => x.Similarity).ToArray()); }