Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                int agl = Convert.ToInt32(tbStep.Text.ToString().Trim());
                if (agl <= 0) { MessageBox.Show("Угол не верено задан."); return; }
                int step = Convert.ToInt32(360 / agl);
                if (step > 360) { MessageBox.Show("Угол не верено задан."); return; }
                label5.Text = Convert.ToString(step);

                string s = comboBox1.Text.ToString().Trim();
                string filename = "";
                if (cmbDevices.SelectedIndex != -1)
                {
                    PrimeraCamara = DeviceManager.GetDevice(cmbDevices.SelectedIndex);
                    string g = Guid.NewGuid().ToString();

                    System.IO.Directory.CreateDirectory(g);

                    System.Threading.Thread.Sleep(2000);
                    //------------table stepper
                    serialPort1.PortName = s; serialPort1.BaudRate = 9600;
                    serialPort1.Open();
                    serialPort1.Write("#" + Convert.ToString(agl) + ";");
                    serialPort1.Close();
                    System.Threading.Thread.Sleep(1000);

                    for (int i = 0; i < step; i++)
                    {
                        //------------web shot
                        filename = g + "\\shot_" + i.ToString() + ".jpg";

                        picCapture.Image = null;
                        picCapture.Image = PrimeraCamara.grabbmp();
                        PrimeraCamara.Stop();
                        picCapture.Image.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg);
                        Application.DoEvents();
                        if (activatecam())
                        {
                            System.Threading.Thread.Sleep(2000);
                            //------------table stepper
                            serialPort1.PortName = s; serialPort1.BaudRate = 9600;
                            serialPort1.Open();
                            serialPort1.Write("1");
                            serialPort1.Close();
                            System.Threading.Thread.Sleep(1000);
                        }

                    }
                    serialPort1.PortName = s; serialPort1.BaudRate = 9600;
                    serialPort1.Open();
                    serialPort1.Write("!");
                    serialPort1.Close();

                    MessageBox.Show("Завершено.");
                }
            }catch(Exception ex){MessageBox.Show("Ошибка."+ex.Message.ToString());}
        }
Esempio n. 2
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (cmbDevices.SelectedIndex != -1)
     {
         PrimeraCamara = DeviceManager.GetDevice(cmbDevices.SelectedIndex);
         picCapture.Image = null;
         picCapture.Image = PrimeraCamara.grabbmp();
         PrimeraCamara.Stop();
         picCapture.Image.Save("1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
         PrimeraCamara.Stop();
         activatecam();
     }
 }