Exemple #1
0
        public static Task <string> GetResquest()
        {
            Task <string> task = Task.Run(() =>
            {
                string Resp = null;

                try
                {
                    DirectoryInfo dir = new DirectoryInfo(@"C:\DataCaptcha");

                    Bitmap image1 = new Bitmap(dir.FullName + "\\55499\\0f645d1d-7f21-45df-a2e8-adaf5e00159a.jpg");

                    Parallel.ForEach(dir.GetDirectories(), (currentDir, stateDir) =>
                    {
                        Parallel.ForEach(currentDir.GetFiles(), (currentFile, stateFile) =>
                        {
                            Bitmap image2 = new Bitmap(currentFile.FullName);

                            float Similarity = MethodImagenFilter.GetSimilarity(image1, image2);

                            if (Similarity > 0.95f)
                            {
                                Resp = currentFile.FullName;

                                stateDir.Break();
                                stateFile.Break();
                            }
                            else if (Similarity < 0.50f)
                            {
                                stateFile.Break();
                            }
                        });
                    });
                }
                catch (Exception ex)
                {
                    Resp = null;
                }

                return(Resp);
            });

            return(task);
        }