Example #1
0
        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());
        }
Example #2
0
        public static IEnumerable <int> Search(float[] QueryVector, int QueryWidth, int QueryHeight, float[] DocumentVector)
        {
            var myDSLPLibrary = new DoLF();

            return(myDSLPLibrary.DistanceSegmFree(QueryVector, QueryWidth, QueryHeight, DocumentVector)
                   .OrderBy(d => d.Similarity)
                   .SelectMany(d => new int[] {
                d.Block[0],
                d.Block[1],
                d.Block[2],
                d.Block[3],
                (int)Math.Round(10000 * d.Similarity)
            }));
        }