コード例 #1
0
ファイル: GtHelper.cs プロジェクト: zyh329/adas
 public static TestImage[] ParseGt(string testPath)
 {
     var dict = new Dictionary<string, TestImage>();
     string gtfullpath = Path.Combine(testPath, GtFilename);
     if (!File.Exists(gtfullpath))
     {
         return null;
     }
     using (var reader = new StreamReader(new FileStream(gtfullpath, FileMode.Open, FileAccess.Read)))
     {
         while (!reader.EndOfStream)
         {
             string line = reader.ReadLine();
             if (line == null)
                 continue;
             string[] info = line.Split(new[] { ';' });
             if (info.Length < 5)
                 continue;
             string name = info[0];
             int x1 = int.Parse(info[1]);
             int y1 = int.Parse(info[2]);
             int x2 = int.Parse(info[3]);
             int y2 = int.Parse(info[4]);
             var signClass = int.Parse(info[5]);
             if (AllowedSignType.Contains(signClass))
             {
                 if (!dict.ContainsKey(name))
                     dict[name] = new TestImage(name);
                 var area = new Rectangle(x1, y1, x2 - x1, y2 - y1);
                 dict[name].SignsAreas.Add(area);
             }
         }
     }
     return dict.Values.ToArray();
 }
コード例 #2
0
ファイル: GtHelper.cs プロジェクト: zyh329/adas
        public static TestImage[] ParseGt(string testPath)
        {
            var    dict       = new Dictionary <string, TestImage>();
            string gtfullpath = Path.Combine(testPath, GtFilename);

            if (!File.Exists(gtfullpath))
            {
                return(null);
            }
            using (var reader = new StreamReader(new FileStream(gtfullpath, FileMode.Open, FileAccess.Read)))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    if (line == null)
                    {
                        continue;
                    }
                    string[] info = line.Split(new[] { ';' });
                    if (info.Length < 5)
                    {
                        continue;
                    }
                    string name      = info[0];
                    int    x1        = int.Parse(info[1]);
                    int    y1        = int.Parse(info[2]);
                    int    x2        = int.Parse(info[3]);
                    int    y2        = int.Parse(info[4]);
                    var    signClass = int.Parse(info[5]);
                    if (AllowedSignType.Contains(signClass))
                    {
                        if (!dict.ContainsKey(name))
                        {
                            dict[name] = new TestImage(name);
                        }
                        var area = new Rectangle(x1, y1, x2 - x1, y2 - y1);
                        dict[name].SignsAreas.Add(area);
                    }
                }
            }
            return(dict.Values.ToArray());
        }