예제 #1
0
        public MainForm()
        {
            InitializeComponent();

              timer1.Tick += timer1_Tick;
              _camera = new Capture(VIDEODEVICE, VIDEOWIDTH, VIDEOHEIGHT, VIDEOBITSPERPIXEL, pictureBox2);

              string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
              _dataPath = Path.Combine(directoryName, "Data");

              if (!Directory.Exists(_dataPath))
              {
            Directory.CreateDirectory(_dataPath);
              }

              label2.Text = "Sensitivity: " + trackBar1.Value;

              var hotSpotsFileName = Path.Combine(directoryName, "hotspots.txt");
              if (File.Exists(hotSpotsFileName))
              {
            using (StreamReader reader = new StreamReader(hotSpotsFileName))
            {
              while (!reader.EndOfStream)
              {
            string line = reader.ReadLine();
            string[] data = line.Split(',');
            Rectangle rect = new Rectangle(Convert.ToInt32(data[0]), Convert.ToInt32(data[1]), Convert.ToInt32(data[2]), Convert.ToInt32(data[3]));
            HotSpot hotSpot = new HotSpot(rect);
            _hotSpots.Add(hotSpot);
            listView1.Items.Add(hotSpot.ToString());

              }
            }
              }
        }
예제 #2
0
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (_hotSpotMode == HotSpotMode.Start)
              {
            _hotSpotStartPoint = new Point(e.X, e.Y);
            _hotSpotMode = HotSpotMode.End;
            return;
              }

              if (_hotSpotMode == HotSpotMode.End)
              {
            int x = Math.Min(_hotSpotStartPoint.X, e.X);
            int y = Math.Min(_hotSpotStartPoint.Y, e.Y);
            int width = Math.Abs(_hotSpotStartPoint.X - e.X);
            int height = Math.Abs(_hotSpotStartPoint.Y - e.Y);
            HotSpot hotSpot = new HotSpot(new Rectangle(x, y, width, height));
            _hotSpots.Add(hotSpot);
            listView1.Items.Add(hotSpot.ToString());
            _hotSpotMode = HotSpotMode.None;
            return;
              }
        }