private void process_folder(string path)
        {
            var files = Directory.GetFiles(path).Where(x => x.EndsWith(".png") || x.EndsWith(".jpg") || x.EndsWith(".jpeg") || x.EndsWith(".bmp") || x.EndsWith(".webp"));
            var total = files.Count();
            var count = 0;

            Parallel.ForEach(files,
                             x =>
            {
                iss.AppendImage(x);
                Extends.Post(() =>
                {
                    var cc          = Interlocked.Increment(ref count);
                    StatusText.Text = $"이미지 파일 분석 중 ... [{cc.ToString("#,#")}/{total.ToString("#,#")}] ({(cc / (double)total * 100.0).ToString("#0.00")} %) {x}";
                });
            });
            var result = new List <(string, ulong[])>();

            foreach (var kv in iss.Hashs)
            {
                result.Add((kv.Key, kv.Value));
            }
            var fn = $"iss-{System.IO.Path.GetFileName(path)}-{DateTime.Now.Ticks}.iss";

            File.WriteAllText(fn, JsonConvert.SerializeObject(result));
            Extends.Post(() => StatusText.Text = $"'{fn}' 파일로 분석 결과가 자동저장 되었습니다.");
        }
예제 #2
0
        static void ProcessTest(string[] args)
        {
            switch (args[0])
            {
            case "1":
            {
                var iss = new ImageSoftSimilarity();
                //foreach (var file in Directory.GetFiles(@"C:\Users\rollrat\Desktop\새 폴더"))
                //    if (file.EndsWith(".png"))
                //        iss.AppendImage(file);

                Parallel.ForEach(Directory.GetFiles(@"C:\Users\rollrat\Desktop\새 폴더").Where(x => x.EndsWith(".png")),
                                 //new ParallelOptions { MaxDegreeOfParallelism = 2 },
                                 (x) =>
                    {
                        iss.AppendImage(x);
                    });

                //iss.FindForSoft(ImageSoftSimilarity.MakeSoftHash(@"C:\Users\rollrat\Desktop\새 폴더\1577170523.png"), 20);
            }
            break;

            case "2":
            {
                var iss = new ImageSoftSimilarity();
                Parallel.ForEach(Directory.GetFiles(@"C:\Users\rollrat\Desktop\새 폴더").Where(x => x.EndsWith(".png") || x.EndsWith(".jpg")),
                                 //new ParallelOptions { MaxDegreeOfParallelism = 4 },
                                 x => iss.AppendImage(x));

                var clustered = iss.Clustering();
            }
            break;
            }
        }
예제 #3
0
        static void ProcessSoftClustering(string[] args)
        {
            var iss = new ImageSoftSimilarity();

            Console.Instance.WriteLine("이미지들을 해싱하는 중...");
            using (var progressBar = new Console.ConsoleProgressBar())
            {
                var files    = Directory.GetFiles(args[0]).Where(x => x.EndsWith(".png") || x.EndsWith(".jpg") || x.EndsWith(".jpeg") || x.EndsWith(".webp") || x.EndsWith(".bmp"));
                int counts   = files.Count();
                int complete = 0;
                Parallel.ForEach(files,
                                 x =>
                {
                    iss.AppendImage(x);
                    progressBar.SetProgress(Interlocked.Increment(ref complete) / (float)counts * 100);
                });
            }
            List <List <string> > clustered;

            using (var progressBar = new Console.ConsoleProgressBar())
            {
                Console.Instance.WriteLine("클러스터링 중...");
                //clustered = iss.Clustering(x =>
                //{
                //    progressBar.SetProgress(x.Item1 / (float)x.Item2 * 100);
                //});
            }
            //clustered.RemoveAll(x => x.Count == 1);
            //Console.Instance.WriteLine(clustered);
        }