Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            CHONG_TYPE chong_type = CHONG_TYPE.BIAO_KE_CHONG;

            //DetectHoG.CropChong(chong_type);

            //DetectHoG.NormalizeChong(chong_type);
            //DetectHoG.NormalizeChongWithRotation(chong_type);

            //DetectHoG.SampleStatistics(chong_type);

            //DetectHoG.NegativePatches(chong_type);

            DetectHoG.TrainDetection(chong_type);
            //DetectHoG.ToSingleVector(chong_type);
            //DetectHoG.BootStrapDetection(chong_type);
            //DetectHoG.TrainVerification(chong_type);
            //DetectHoG.TrainFinalDecision();

            //DetectHoG.TrainVerify();
            //DetectHoG.TrainVerifySingleChong();

            //DetectHoG.BootStrap(CHONG_TYPE.CHUI_XI_GUAN_CHONG);
            //DetectHoG.BootStrap(CHONG_TYPE.ZHONG_CHONG);
            //DetectHoG.BootStrap(CHONG_TYPE.BIAO_KE_CHONG);
            //DetectHoG.BootStrapNegatives();

            //CompareResults();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                System.Console.WriteLine("Usage: WaterTest <test_image_folder>");
                return;
            }
            dataFolder = args[0];
            if (!System.IO.Directory.Exists(dataFolder))
            {
                System.Console.WriteLine("Can not find " + dataFolder);
                return;
            }

            hog = new WaterLib.DetectHoG();

            //Evaluate(CHONG_TYPE.CHUI_XI_GUAN_CHONG);
            //Evaluate(CHONG_TYPE.DAN_ZHI_LUN_CHONG);
            //Evaluate(CHONG_TYPE.ZHU_WEN_LUN_CHONG);
            Evaluate(CHONG_TYPE.BIAO_KE_CHONG);
            Evaluate(CHONG_TYPE.ZHONG_CHONG);
            EvaluateNegatives();
        }
Ejemplo n.º 3
0
        static void Evaluate(CHONG_TYPE chongType)
        {
            string image_folder = "";

            switch (chongType)
            {
            case CHONG_TYPE.ZHONG_CHONG: image_folder = Path.Combine(dataFolder, @"Zhong\Original"); break;

            case CHONG_TYPE.BIAO_KE_CHONG: image_folder = Path.Combine(dataFolder, @"BiaoKe\Original"); break;

            case CHONG_TYPE.CHUI_XI_GUAN_CHONG: image_folder = Path.Combine(dataFolder, @"ChuiXiGuan\Original"); break;

            case CHONG_TYPE.DAN_ZHI_LUN_CHONG: image_folder = Path.Combine(dataFolder, @"DanZhiLun\Original"); break;

            case CHONG_TYPE.ZHU_WEN_LUN_CHONG: image_folder = Path.Combine(dataFolder, @"ZhuWenLun\Original"); break;
            }
            if (!Directory.Exists(image_folder))
            {
                return;
            }

            string ret_folder = image_folder.Replace("Original", "result");

            if (Directory.Exists(ret_folder))
            {
                Directory.Delete(ret_folder, true); System.Threading.Thread.Sleep(500);
            }
            Directory.CreateDirectory(ret_folder);

            int    gt_count_total = 0, auto_count_total = 0, gt_count, auto_count;
            string evaluation_file = ret_folder.Replace("result", "evaluation.txt");

            List <Sample> samples = DetectHoG.LoadSamples(chongType, dataFolder.TrimEnd(new char[] { '\\' }) + @"\");

            using (StreamWriter sw = new StreamWriter(evaluation_file))
            {
                sw.WriteLine("Filename\tGT Count\tAuto Count");
                for (int i = 0; i < samples.Count; i++)
                {
                    Sample sample = samples[i]; string file = sample.imageFile;
                    System.Console.WriteLine("Processing " + file);

                    Image <Gray, byte>      image = new Image <Gray, byte>(file);
                    WaterLib.DetectResult[] result = hog.DetectWithRotationModels(image);

                    gt_count = sample.xs.Count; auto_count = 0;
                    if (result != null)
                    {
                        for (int k = 0; k < result.Length; k++)
                        {
                            System.Drawing.Rectangle rect = result[k].rect;
                            image.Draw(rect, new Gray(255), 3);
                            image.Draw(result[k].chong_type.ToString() + " " + result[k].score.ToString("f2"), new System.Drawing.Point(rect.Left + 3, rect.Bottom - 3), FontFace.HersheyPlain, 1, new Gray(255), 1);

                            if (result[k].chong_type == chongType)
                            {
                                auto_count++;
                            }
                        }
                    }

                    gt_count_total   += gt_count;
                    auto_count_total += auto_count;

                    image.Save(file.Replace("original", "result"));
                    sw.WriteLine("{0}\t{1}\t{2}", Path.GetFileNameWithoutExtension(file), gt_count, auto_count);
                }
                sw.WriteLine("{0}\t{1}\t{2}", "Total", gt_count_total, auto_count_total);
            }
        }