示例#1
0
        public void IndexFiles(FileInfo[] imageFiles, BackgroundWorker IndexBgWorker, object argument = null)
        {
            List <CEDDRecord> listOfRecords = new List <CEDDRecord>();

            double[] ceddDiscriptor = null;
            int      totalFileCount = imageFiles.Length;
            CEDD     cedd           = new CEDD();

            for (int i = 0; i < totalFileCount; i++)
            {
                var fi = imageFiles[i];
                using (Bitmap bmp = new Bitmap(Image.FromFile(fi.FullName)))
                {
                    ceddDiscriptor = cedd.Apply(bmp);
                }

                CEDDRecord record = new CEDDRecord
                {
                    Id             = i,
                    ImageName      = fi.Name,
                    ImagePath      = fi.FullName,
                    CEDDDiscriptor = ceddDiscriptor
                };
                listOfRecords.Add(record);
                IndexBgWorker.ReportProgress(i);
            }
            BinaryAlgoRepository <List <CEDDRecord> > repo = new BinaryAlgoRepository <List <CEDDRecord> >();

            repo.Save(listOfRecords);
        }
示例#2
0
        public void IndexFiles(FileInfo[] imageFiles, BackgroundWorker IndexBgWorker, object argument = null)
        {
            BKTree <CEDDTreeNode> ceddtree = new BKTree <CEDDTreeNode>();

            double[] ceddDiscriptor = null;
            int      totalFileCount = imageFiles.Length;
            CEDD     cedd           = new CEDD();

            for (int i = 0; i < totalFileCount; i++)
            {
                var fi = imageFiles[i];
                using (Bitmap bmp = new Bitmap(Image.FromFile(fi.FullName)))
                {
                    ceddDiscriptor = cedd.Apply(bmp);
                }

                CEDDTreeNode ceddTreeNode = new CEDDTreeNode
                {
                    Id             = i,
                    ImageName      = fi.Name,
                    ImagePath      = fi.FullName,
                    CEDDDiscriptor = ceddDiscriptor
                };
                ceddtree.add(ceddTreeNode);
                IndexBgWorker.ReportProgress(i);
            }
            CEDDRepository <BKTree <CEDDTreeNode> > repo = new CEDDRepository <BKTree <CEDDTreeNode> >();

            repo.Save(ceddtree);
            CacheHelper.Remove("CeddIndexTree");
        }
示例#3
0
        public double[] GetCeddDescriptorForImage(Stream file)
        {
            double[] ceddDiscriptor = null;
            CEDD     cedd           = new CEDD();

            using (Bitmap bmp = new Bitmap(file))
            {
                ceddDiscriptor = cedd.Apply(bmp);
            }
            return(ceddDiscriptor);
        }
示例#4
0
        public void IndexFilesAsync(FileInfo[] imageFiles, BackgroundWorker IndexBgWorker, object argument = null)
        {
            ConcurrentBag <CEDDRecord> listOfRecords = new ConcurrentBag <CEDDRecord>();

            double[] ceddDiscriptor = null;
            int      totalFileCount = imageFiles.Length;
            CEDD     cedd           = new CEDD();

            int i = 0; long nextSequence;
            //In the class scope:
            Object lockMe = new Object();

            Parallel.ForEach(imageFiles, currentImageFile =>
            {
                var fi = currentImageFile;
                using (Bitmap bmp = new Bitmap(Image.FromFile(fi.FullName)))
                {
                    ceddDiscriptor = cedd.Apply(bmp);
                }

                lock (lockMe)
                {
                    nextSequence = i++;
                }

                CEDDRecord record = new CEDDRecord
                {
                    Id             = nextSequence,
                    ImageName      = fi.Name,
                    ImagePath      = fi.FullName,
                    CEDDDiscriptor = ceddDiscriptor
                };
                listOfRecords.Add(record);
                IndexBgWorker.ReportProgress(i);
            });
            BinaryAlgoRepository <List <CEDDRecord> > repo = new BinaryAlgoRepository <List <CEDDRecord> >();

            repo.Save(listOfRecords.ToList());
        }