Exemplo n.º 1
0
        public static void test_json()
        {
            Features f = new Features();
            f.imagefile = "somefile.png";
            f.intlines = new List<IntLineFeature>();
            for (int i = 0; i < 3; ++i)
            {
                var l = new IntLineFeature();
                l.id = i;
                l.line.p.X = i;
                l.line.p.Y = i * 2;
                l.line.q.X = i + 10;
                l.line.q.Y = i * 2 + 10;
                f.intlines.Add(l);
            }
            string json = f.ToString();
            Console.WriteLine(json);

            Features g = Features.FromString(json);
            Console.WriteLine(string.Format("file: {0} line[1].p.X: {1} line[2].q.Y: {2}", g.imagefile, g.intlines[1].line.p.X, g.intlines[2].line.q.Y));

            bool same = json == g.ToString();
            Console.WriteLine(string.Format("same json: {0}", same));
            System.IO.File.WriteAllText("test.features.json", json);
        }
Exemplo n.º 2
0
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         String json = System.IO.File.ReadAllText(openFileDialog1.FileName);
         features = Features.FromString(json);
         pictureBox.Refresh();
     }
 }
Exemplo n.º 3
0
 private void MarkingForm_Load(object sender, EventArgs e)
 {
     pictureBox.Image = image;
     pictureBox.Size = new Size(pictureBox.Image.Width, pictureBox.Image.Height);
     pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
     ActiveControl = pictureBox;
     if (features == null)
     {
         features = new Features();
     }
 }
Exemplo n.º 4
0
 public static Features FromString(string json)
 {
     var reader = new JsonReader();
     dynamic contents = reader.Read(json);
     Features f = new Features();
     f.imagefile = contents.imagefile;
     //try
     {
         f.intlines = new List<IntLineFeature>();
         foreach (dynamic l in contents.intlines)
         {
             IntLineFeature lf = new IntLineFeature();
             lf.id = l.id;
             int[] line = l.line;
             lf.line.p.X = l.line[0];
             lf.line.p.Y = line[1];
             lf.line.q.X = line[2];
             lf.line.q.Y = line[3];
             f.intlines.Add(lf);
         }
     }
     //catch { } //FIXME: catch the right thing
     return f;
 }