public void LoadCalibration()
        {
            if (!File.Exists("Calibration.txt")) return;

            using (var reader = new StreamReader(File.OpenRead("Calibration.txt")))
            {
                var readLine = reader.ReadLine();
                if (readLine == null) return;
                var coords = readLine.Split(';');

                if (CalibrationBoxes == null)
                    CalibrationBoxes = new List<CalibrationPoint>();

                CalibrationBoxes.Clear();
                if (coords.GetLength(0) > 23) // new calibration
                {
                    for (var i = 0; i < 12; i++)
                    {
                        var r = new CalibrationPoint(i, new Point(int.Parse(coords[i * 2]), int.Parse(coords[i * 2 + 1])));
                        CalibrationBoxes.Add(r);

                    }
                }
            }
        }
Beispiel #2
0
        public void LoadCalibration()
        {
            if (!File.Exists("Calibration.txt"))
            {
                return;
            }

            using (var reader = new StreamReader(File.OpenRead("Calibration.txt")))
            {
                var readLine = reader.ReadLine();
                if (readLine == null)
                {
                    return;
                }
                var coords = readLine.Split(';');

                if (CalibrationBoxes == null)
                {
                    CalibrationBoxes = new List <CalibrationPoint>();
                }

                CalibrationBoxes.Clear();
                if (coords.GetLength(0) > 23) // new calibration
                {
                    for (var i = 0; i < 12; i++)
                    {
                        var r = new CalibrationPoint(i, new Point(int.Parse(coords[i * 2]), int.Parse(coords[i * 2 + 1])));
                        CalibrationBoxes.Add(r);
                    }
                }
            }
        }
        protected void DrawCalibrationPoints(IEnumerable <Point> calibration)
        {
            Form1.OcrCalibrator.CalibrationBoxes = new List <CalibrationPoint>();
            var i = 0;

            foreach (var c in calibration)
            {
                var r = new CalibrationPoint(i, c);
                Form1.OcrCalibrator.CalibrationBoxes.Add(r);
                i++;
            }
        }
 private void ManualCalibrate()
 {
     Form1.OcrCalibrator.CalibrationBoxes = new List<CalibrationPoint>();
     var p = new Point(30, 30);
     tb_description.Text = "Point 1: " + new CalibrationPoint().CalibrationDescriptions[0];
     for (var i = 0; i < 12; i++)
     {
         var cb = new CalibrationPoint(i, new Point(p.X+(50*(i+1)), p.Y));
         Form1.OcrCalibrator.CalibrationBoxes.Add(cb);
     }
     FillRawData();
     _drawPoints = true;
     pb_calibratorBox.Refresh();
 }
        private void ManualCalibrate()
        {
            Form1.OcrCalibrator.CalibrationBoxes = new List <CalibrationPoint>();
            var p = new Point(30, 30);

            tb_description.Text = "Point 1: " + new CalibrationPoint().CalibrationDescriptions[0];
            for (var i = 0; i < 12; i++)
            {
                var cb = new CalibrationPoint(i, new Point(p.X + (50 * (i + 1)), p.Y));
                Form1.OcrCalibrator.CalibrationBoxes.Add(cb);
            }
            FillRawData();
            _drawPoints = true;
            pb_calibratorBox.Refresh();
        }
        private static void AlignCalibrationBoxesWhereRelevant(List <CalibrationPoint> calibrationBoxes)
        {
            for (int i = 3; i < 11; i++)
            {
                calibrationBoxes[i] = new CalibrationPoint
                                          (i, new Point(calibrationBoxes[i].Position.X,
                                                        calibrationBoxes[2].Position.Y));
            }

            calibrationBoxes[11] = new CalibrationPoint
                                       (11, new Point(calibrationBoxes[2].Position.X,
                                                      calibrationBoxes[11].Position.Y));

            calibrationBoxes[1] = new CalibrationPoint
                                      (1, new Point(calibrationBoxes[5].Position.X,
                                                    calibrationBoxes[1].Position.Y));
        }
        private void Pb_calibratorBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (Form1.OcrCalibrator.CalibrationBoxes == null)
            {
                return;
            }

            //Detect if mouse if over a calibration point
            foreach (var cb in Form1.OcrCalibrator.CalibrationBoxes)
            {
                if (cb.Hitbox.Contains(e.Location))
                {
                    _selCalibrationPoint = cb;

                    //update textbox and refimage
                    UpdateDescriptions(cb);

                    _isMouseDown = true;
                    break;
                }
            }
        }
 private void UpdateDescriptions(CalibrationPoint cb)
 {
     pb_example.Image    = cb.Example;
     tb_description.Text = cb.Description;
 }
        private static void AlignCalibrationBoxesWhereRelevant(List<CalibrationPoint> calibrationBoxes )
        {
            for (int i = 3; i < 11; i++)
                calibrationBoxes[i] = new CalibrationPoint
                    (i,new Point(calibrationBoxes[i].Position.X,
                            calibrationBoxes[2].Position.Y));

            calibrationBoxes[11] = new CalibrationPoint
                (11,new Point(calibrationBoxes[2].Position.X,
                    calibrationBoxes[11].Position.Y));

            calibrationBoxes[1] = new CalibrationPoint
                (1,new Point(calibrationBoxes[5].Position.X,
                        calibrationBoxes[1].Position.Y));
        }
        private void Pb_calibratorBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (Form1.OcrCalibrator.CalibrationBoxes == null)
                return;

            //Detect if mouse if over a calibration point
            foreach (var cb in Form1.OcrCalibrator.CalibrationBoxes)
            {
                if (cb.Hitbox.Contains(e.Location))
                {
                    _selCalibrationPoint = cb;

                    //update textbox and refimage
                    UpdateDescriptions(cb);

                    _isMouseDown = true;
                    break;
                }
            }
        }
 protected void DrawCalibrationPoints(IEnumerable<Point> calibration)
 {
     Form1.OcrCalibrator.CalibrationBoxes = new List<CalibrationPoint>();
     var i = 0;
     foreach (var c in calibration)
     {
         var r = new CalibrationPoint(i, c);
         Form1.OcrCalibrator.CalibrationBoxes.Add(r);
         i++;
     }
 }
 private void UpdateDescriptions(CalibrationPoint cb)
 {
     pb_example.Image = cb.Example;
     tb_description.Text = cb.Description;
 }