示例#1
0
        public Form1()
            :base("GDI Video", 10, 10, 640, 480)
        {
            // Show a dialog box on the screen so the user
            // can select which camera to use if they have
            // multiple attached.
            CaptureDeviceDescription capDescription = new CaptureDeviceDescription();
            CameraSelection camForm = new CameraSelection();
            camForm.ShowDialog();

            //// Get the chosen configuration from the dialog 
            //// and use it to create a capture device.
            object config = camForm.SetupPage.GetConfiguration();
            m_CaptureDevice = (VideoCaptureDevice)capDescription.CreateVideoSource(config);

            // Another way to get a hold of a capture device
            //m_CaptureDevice = VideoCaptureDevice.CreateCaptureDeviceFromIndex(0, 320, 240);
            m_CamControl = new CameraControl(m_CaptureDevice);

            //Console.WriteLine("Capabilities: {0}", m_CaptureDevice.Capabilities.Count);
            // Let the capture device know what function to call
            // whenever a frame is received.
            m_CaptureDevice.NewFrame += OnFrameReceived;

            // Start the capture device on its own thread
            m_CaptureDevice.Start();

            fStick = new Joystick(winmm.JOYSTICKID1);
            dispatcher = new TimedDispatcher(1.0 / 2, OnJoystickDispatch, null);
            dispatcher.Start();

        }
        /// 开关摄像机
        public void CameraSwitch(object sender, EventArgs e)
        {
            if (_captureBinded == false) //如果没有绑定摄像头则绑定
            {
                try
                {
                    if (_deviceList.Count <= 0) //没有检测到设备
                    {
                        MessageBox.Show("没有检测到设备!");
                        return;
                    }

                    //只有一个设备或者两个设备选框中的选项相同,只打开一个镜头
                    if (_deviceList.Count == 1 || (_controlPane.comboBox_LCam.SelectedIndex == _controlPane.comboBox_RCam.SelectedIndex))
                    {
                        _captureDeviceL = new VideoCaptureDevice(_deviceList[0].Monikerstring);//连接摄像头。
                        _captureDeviceL.VideoResolution = _captureDeviceL.VideoCapabilities[_controlPane.comboBox_lCapability.SelectedIndex];
                        _captureDeviceL.NewFrame       += VideoSource_NewFrameL;
                        _captureDeviceL.Start();
                    }
                    else //打开两个设备
                    {
                        _captureDeviceL = new VideoCaptureDevice(_deviceList[_controlPane.comboBox_LCam.SelectedIndex].Monikerstring);//连接摄像头。
                        _captureDeviceL.VideoResolution = _captureDeviceL.VideoCapabilities[_controlPane.comboBox_lCapability.SelectedIndex];
                        _captureDeviceL.NewFrame       += VideoSource_NewFrameL;

                        _captureDeviceR = new VideoCaptureDevice(_deviceList[_controlPane.comboBox_RCam.SelectedIndex].Monikerstring);//连接摄像头。
                        _captureDeviceR.VideoResolution = _captureDeviceR.VideoCapabilities[_controlPane.comboBox_rCapability.SelectedIndex];
                        _captureDeviceR.NewFrame       += VideoSource_NewFrameR;

                        _captureInProgress = true;
                        _captureDeviceL.Start();
                        _captureDeviceR.Start();
                    }

                    _captureBinded = true;
                }
                catch (NullReferenceException excpt)
                {
                    MessageBox.Show(excpt.Message);
                }
            }
            else //摄像头已经绑定
            {
                if (_captureInProgress)
                {
                    _captureDeviceL?.SignalToStop();
                    _captureDeviceR?.SignalToStop();
                }
                else
                {
                    _captureDeviceL?.Start();
                    _captureDeviceR?.Start();
                }
                _captureInProgress = !_captureInProgress;
            }
        }
        public bool Play()
        {
            if (cam == null)
            {
                return(false);
            }
            if (cam != null && !cam.IsRunning)
            {
                try
                {
                    cam?.Start();
                }
                catch
                {
                    Init("");
                    cam?.Start();
                }
            }


            return(true);
        }
示例#4
0
        private AForgeCapture(string name, string deviceMoniker)
        {
            this.Name = name;
            this.Uuid = deviceMoniker;

            var width = Picture.Width;
            var height = Picture.Height;

            device = new VideoCaptureDevice(deviceMoniker);
            var caps = device.VideoCapabilities
                             .Where(c => c.FrameSize.Width == width && c.FrameSize.Height == height)
                             .OrderByDescending(c => c.FrameSize.Width * c.FrameSize.Height * c.MaxFrameRate).First();

            this.Width = caps.FrameSize.Width;
            this.Height = caps.FrameSize.Height;
            device.DesiredFrameRate = caps.MaxFrameRate;
            device.DesiredFrameSize = caps.FrameSize;
            device.NewFrame += new NewFrameEventHandler(OnNewFrameEvent);
            device.Start();
        }
示例#5
0
 // Hàm bật camera đã có ở camera đã thiết lập
 public void Start(VideoCaptureDevice camera)
 {
     camera.Start();
 }
示例#6
0
 protected void btnstart_Click(object sender, EventArgs e)
 {
     videoCaptureDevice           = new VideoCaptureDevice(filterInfoCollection[combocam.SelectedIndex].MonikerString);
     videoCaptureDevice.NewFrame += VideoCaptureDevice_NewFrame;
     videoCaptureDevice.Start();
 }
示例#7
0
 public void StartVideoCapture()
 {
     deviceVideo?.Start();
     deviceVideoIr?.Start();
 }
示例#8
0
 /// <summary>
 /// Turns on the web cam for recording and capturing images
 /// </summary>
 public void cam_Start()
 {
     cam.Start();
 }
示例#9
0
 private void button1_Click(object sender, EventArgs e)
 {
     FinalVideo           = new VideoCaptureDevice(VideoCaptureDevices[comboBox1.SelectedIndex].MonikerString);
     FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
     FinalVideo.Start();
 }
示例#10
0
 private void btnDetect_Click(object sender, System.EventArgs e)
 {
     device           = new VideoCaptureDevice(filter[cboDevice.SelectedIndex].MonikerString);
     device.NewFrame += Device_newFrame;
     device.Start();
 }
 private void button1_Click(object sender, EventArgs e)
 {
     kamera           = new VideoCaptureDevice(webcamsayisi[kameraBox.SelectedIndex].MonikerString);
     kamera.NewFrame += new NewFrameEventHandler(kullanilacakcihaz_NewFrame);
     kamera.Start(); // Kamera görüntüsü başlatılır.
 }
示例#12
0
 private void button2_Click(object sender, EventArgs e)
 {
     aygıt           = new VideoCaptureDevice(aygıtlar[0].MonikerString);
     aygıt.NewFrame += Video;
     aygıt.Start();
 }
示例#13
0
 //Quét mã
 void Scan()
 {
     results = new List <string>();
     VideoCaptureDevice.Start();
 }
示例#14
0
文件: Rating.cs 项目: ipgip/rating
        private void Form1_Load(object sender, EventArgs e)
        {
            #region AForge
            if (Convert.ToBoolean(Decoration["Camera"] ?? false))
            {
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage;
                videodevices         = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                device = new VideoCaptureDevice();

                if (device.IsRunning)
                {
                    device.Stop();
                    pictureBox1.Image = null;
                    pictureBox1.Invalidate();
                }
                else
                {
                    device           = new VideoCaptureDevice(videodevices[0].MonikerString);
                    device.NewFrame += CapturePicture;
                    //flg.Reset();
                    device.Start();
                }
            }
            #endregion
            #region Decor
            if (File.Exists(Decoration["LeftTop"]?.ToString()))
            {
                LeftTop.Image = Image.FromFile(Decoration["LeftTop"].ToString());
            }
            if (File.Exists(Decoration["Top"]?.ToString()))
            {
                Top.Image = Image.FromFile(Decoration["Top"].ToString());
            }
            if (File.Exists(Decoration["RightTop"]?.ToString()))
            {
                RightTop.Image = Image.FromFile(Decoration["RightTop"].ToString());
            }
            if (File.Exists(Decoration["Left"]?.ToString()))
            {
                Left.Image = Image.FromFile(Decoration["Left"].ToString());
            }
            if (File.Exists(Decoration["Right"]?.ToString()))
            {
                Right.Image = Image.FromFile(Decoration["Right"].ToString());
            }
            if (File.Exists(Decoration["LeftBottom"]?.ToString()))
            {
                LeftBottom.Image = Image.FromFile(Decoration["LeftBottom"].ToString());
            }
            if (File.Exists(Decoration["Bottom"]?.ToString()))
            {
                Bottom.Image = Image.FromFile(Decoration["Bottom"].ToString());
            }
            if (File.Exists(Decoration["RightBottom"]?.ToString()))
            {
                LeftBottom.Image = Image.FromFile(Decoration["LeftBottom"].ToString());
            }

            if (File.Exists(Decoration["Banner"]?.ToString()))
            {
                Banner.Image = Image.FromFile(Decoration["Banner"].ToString());
            }
            #endregion
            #region Ответы
            A = new int[Q.Count()];// ответы

            tableLayoutPanel1.RowCount = Q.Count();
            tableLayoutPanel1.RowStyles.Clear();
            for (int i = 0; i < tableLayoutPanel1.RowCount; i++)
            {
                tableLayoutPanel1.RowStyles.Add(
                    new RowStyle(
                        SizeType.Absolute,
                        (int)(tableLayoutPanel1.Height / tableLayoutPanel1.RowCount)));
            }
            int c = 0;
            foreach (Questions q in Q)
            {
                TableLayoutPanel Tp1 = new TableLayoutPanel()
                {
                    RowCount    = 2,
                    ColumnCount = q.Answers,
                    Dock        = DockStyle.Fill
                };
                Tp1.ColumnStyles.Clear();
                for (int i = 0; i < q.Answers; i++)
                {
                    //ColumnStyle C = new ColumnStyle(SizeType.Percent, 50f); //?????
                    ColumnStyle C = new ColumnStyle(SizeType.Percent, Tp1.Width / q.Answers); //?????
                    Tp1.ColumnStyles.Add(C);
                }
                for (int i = 0; i < Tp1.RowCount; i++)
                {
                    RowStyle R = new RowStyle(SizeType.Absolute, Tp1.Height / Tp1.RowCount);
                    Tp1.RowStyles.Add(R);
                }
                Tp1.Controls.Add(new Label()
                {
                    Text      = q.Question,
                    Font      = new Font(SystemFonts.DefaultFont.FontFamily, 14f, FontStyle.Bold),
                    TextAlign = ContentAlignment.MiddleLeft,
                    Dock      = DockStyle.Fill
                }, 0, 0);

                Tp1.SetColumnSpan(Tp1.GetControlFromPosition(0, 0), q.Answers);
                for (int i = 1; i < q.Answers + 1; i++)
                {
                    PictureBox p = new PictureBox
                    {
                        // Dock = (!q.Logical) ? DockStyle.None : (i == 1) ? DockStyle.Right : DockStyle.Left,
                        Image = Image.FromFile((!q.Logical) ?
                                               (File.Exists(Decoration[$"B{i}"]?.ToString()) ? Decoration[$"B{i}"].ToString() : $"{i}.jpg") :
                                               (File.Exists(Decoration[$"L{i}"]?.ToString()) ? Decoration[$"L{i}"].ToString() : $"l{i}.jpg")),
                        Name     = $"{i}",
                        Tag      = c,
                        SizeMode = PictureBoxSizeMode.StretchImage
                    };
                    p.Click += P_Click;
                    Tp1.Controls.Add(p);
                }
                tableLayoutPanel1.Controls.Add(Tp1);
                c++;
            }
            #endregion
        }
示例#15
0
 private void button1_Click(object sender, EventArgs e)
 {
     _FinalFrame           = new VideoCaptureDevice(_CaptureDevece[comboBox1.SelectedIndex].MonikerString);
     _FinalFrame.NewFrame += new NewFrameEventHandler(FinalFrame_NewFrame);
     _FinalFrame.Start();
 }
示例#16
0
        private void Form2_Load(object sender, EventArgs e)
        {
            this.TopMost = true;

            this.FormBorderStyle = FormBorderStyle.None;

            this.WindowState = FormWindowState.Maximized;

            //
            if (webcam != "ON")
            {
                filterInfoCollection          = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                captureDevice                 = new VideoCaptureDevice(filterInfoCollection[0].MonikerString);
                captureDevice.VideoResolution = captureDevice.VideoCapabilities[2];
                captureDevice.NewFrame       += CaptureDevice_NewFrame;
                captureDevice.Start();
                timer4.Start();
            }
            webcam = "ON";

            //timer2.Enabled = true;
            timer3.Enabled = true;

            this.label1.Dock    = System.Windows.Forms.DockStyle.Fill;
            this.label2.Visible = false;
            this.da_btn.Visible = false;
            this.nu_btn.Visible = false;

            this.textBox1.Enabled = false;
            this.textBox1.Visible = false;

            this.ruta_label.Text      = "Ruta: " + Form1.ruta;
            this.schimb_label.Text    = "Schimbul: " + Form1.sch;
            this.transport_label.Text = "Transport: " + Form1.tran;
            string modification = File.GetLastWriteTime("Rute.sqlite").ToString("dd-MM-yyyy HH:mm:ss");

            this.upload_label.Text = "Versiune date: " + modification;

            //this.textBox1.Location = new System.Drawing.Point(this.Width / 2 - label1.Size.Width / 4, this.Height / 2 + 50);

            //this.textBox1.Size = new System.Drawing.Size(label1.Size.Width / 2, 20);

            this.pictureBox.Location = new System.Drawing.Point(this.Width / 2 - pictureBox.Size.Width / 2, this.Height / 2 - pictureBox.Size.Width / 4 + 50);

            /*sqlLiteCon.Open();
             * SQLiteDataReader sqlDataReader = new SQLiteCommand("SELECT locuri, locuri_rezerva FROM autobuz WHERE autobuz='" + Form1.tran + "'", sqlLiteCon).ExecuteReader();
             * bool flag1 = sqlDataReader.Read();
             * if (flag1)
             * {
             *  nr_locuri = Convert.ToInt32(sqlDataReader.GetValue(0).ToString());
             *  nr_locuri_rezerva = Convert.ToInt32(sqlDataReader.GetValue(1).ToString());
             *
             * }
             * sqlLiteCon.Close();
             *
             * locuri_bus = new int[nr_locuri];
             *
             * for (int i = 0, nr = 1; i < nr_locuri; i++, nr += 1)
             * {
             *  locuri_bus[i] = nr;
             * }
             *
             * locuri_rezerva = new int[nr_locuri_rezerva];
             *
             * for (int i = 0, nr = locuri_bus[locuri_bus.Length - 1] + 1; i < nr_locuri_rezerva; i++, nr += 1)
             * {
             *  locuri_rezerva[i] = nr;
             * }*/
        }
示例#17
0
 private void Detection()
 {
     device           = new VideoCaptureDevice(filter[cbDevice.SelectedIndex].MonikerString);
     device.NewFrame += Device_NewFrame;
     device.Start();
 }
 public void Start()
 {
     _videoDevice.Start();
 }
示例#19
0
 private void StartWebcam()
 {
     webcam = new VideoCaptureDevice(availableWebcams[ComboBoxWebcams.SelectedIndex].MonikerString);
     webcam.Start();
     webcam.NewFrame += new NewFrameEventHandler(webcam_NewFrame);
 }
示例#20
0
 private void ProbeVideoDevice()
 {
     videoCaptureDevice.NewFrame += CaptureVideoDeviceNewFrameProbe;
     videoCaptureDevice.Start();
 }
示例#21
0
 private void btnContinue_Click(object sender, EventArgs e)
 {
     cam           = new VideoCaptureDevice(webcam[comboBox1.SelectedIndex].MonikerString); //cam e comboboxtan seçilmiş olanı kameraya atar
     cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);                                //
     cam.Start();                                                                           // kamerayı başlatır.
 }
        private void button1_Click(object sender, EventArgs e)
        {
            if (videoSource.IsRunning == true)
            {
                videoSource.Stop();
                pictureBox1.Image = null;
                pictureBox1.Invalidate();

                if (_accelerometer != null || DEBUG)
                {
                    // ReadingChanged based
                    _accelerometer.ReadingChanged -= AcclReadingChanged;
                    _gyrometer.ReadingChanged     -= GyroReadingChanged;
                    // Timer based
                    //IMUTimer.Enabled = false;
                    writerCSV.Close();
                    //IMUTimer.Dispose();
                }
            }
            else
            {
                /*****************  Camera handler  ******************************/
                videoSource = new VideoCaptureDevice(videoDevices[comboBox1.SelectedIndex].MonikerString);
                try
                {
                    //Check if the video device provides a list of supported resolutions
                    if (videoSource.VideoCapabilities.Length > 0)
                    {
                        string highestSolution = "0;0";
                        //Search for the highest resolution
                        for (int i = 0; i < videoSource.VideoCapabilities.Length; i++)
                        {
                            if (
                                videoSource.VideoCapabilities[i].FrameSize.Width > Convert.ToInt32(highestSolution.Split(';')[0]) &&
                                videoSource.VideoCapabilities[i].AverageFrameRate >= 20 &&
                                videoSource.VideoCapabilities[i].FrameSize.Height < 500
                                )
                            {
                                highestSolution = videoSource.VideoCapabilities[i].FrameSize.Width.ToString() + ";" + i.ToString();
                            }
                        }
                        //Set the highest resolution as active
                        videoSource.VideoResolution = videoSource.VideoCapabilities[Convert.ToInt32(highestSolution.Split(';')[1])];
                    }
                }
                catch { }

                Thread threadCamera = new Thread(() => CameraThread())
                {
                    Priority = ThreadPriority.Highest
                };
                threadCamera.Start();

                // set NewFrame event handler
                //videoSource.NewFrame += new NewFrameEventHandler(VideoSource_NewFrame);

                // make timestamped folder for this record session
                string parentPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
                timeStampFolder = nanoTime().ToString();
                string folderPath = System.IO.Path.Combine(parentPath, timeStampFolder);
                System.IO.Directory.CreateDirectory(folderPath);

                videoSource.Start();

                /*****************  IMU handler  ******************************/
                if (_accelerometer != null)
                {
                    // create csv file for this record session
                    String fileName = "imu0.csv";
                    String filePath = System.IO.Path.Combine(folderPath, fileName);
                    writerCSV = new StreamWriter(new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None, bufferSize: 4096, useAsync: true));
                    writerCSV.WriteLine("timestamp" + "," + "omega_x" + "," + "omega_y" + "," + "omega_z" + "," + "alpha_x" + "," + "alpha_y" + "," + "alpha_z");

                    // Establish the report interval
                    _accelerometer.ReportInterval = _acclDesiredReportInterval;
                    _gyrometer.ReportInterval     = _gyroDesiredReportInterval;


                    // based on ReadingChanged
                    _accelerometer.ReadingChanged += AcclReadingChanged;
                    _gyrometer.ReadingChanged     += GyroReadingChanged;

                    // based on periodical timer
                    //IMUTimer.Enabled = true;
                }
                if (DEBUG)
                {
                    // create csv file for this record session
                    String fileName = "imu0.csv";
                    String filePath = System.IO.Path.Combine(folderPath, fileName);
                    writerCSV = new StreamWriter(new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None, bufferSize: 4096, useAsync: true));
                    writerCSV.WriteLine("timestamp" + "," + "omega_x" + "," + "omega_y" + "," + "omega_z" + "," + "alpha_x" + "," + "alpha_y" + "," + "alpha_z");

                    //IMUTimer.Enabled = true;
                    InitializeTimer();
                }
            }
        }
示例#23
0
            public CameraControl(AppWindow owner)
            {
                picBox = new PictureBox()
                {
                    BorderStyle = BorderStyle.Fixed3D,
                    Location    = new Point(2, 2)
                };
                this.Controls.Add(picBox);

                camerasList = new ComboBox()
                {
                    Text = "Select camera",
                    //DropDownStyle = ComboBoxStyle.DropDownList,
                };
                camerasList.DropDown += delegate
                {
                    cameras = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                    camerasList.Items.Clear();
                    foreach (FilterInfo cam in cameras)
                    {
                        camerasList.Items.Add(cam.Name);
                    }
                };
                camerasList.SelectedIndexChanged += delegate
                {
                    if (device != null && device.IsRunning)
                    {
                        device.Stop();
                    }

                    device           = new VideoCaptureDevice(cameras[camerasList.SelectedIndex].MonikerString);
                    device.NewFrame += (sender, eventargs) =>
                    {
                        currentBitmap = (Bitmap)eventargs.Frame.Clone();
                        //picBox.Image = bitmap;
                        picBox.Image = new Bitmap(currentBitmap, picBox.Size);
                    };
                    device.Start();
                };
                this.Controls.Add(camerasList);

                btnCaptureRestart = new Button()
                {
                    BackColor = owner.DarkColor,
                    ForeColor = owner.LightColor,
                    Text      = "Capture"
                };
                this.Controls.Add(btnCaptureRestart);
                btnCaptureRestart.Click += delegate
                {
                    if (capture)
                    {
                        if (device != null && device.IsRunning)
                        {
                            device.Stop();
                            CapturedBitmap         = new Bitmap(currentBitmap, picBox.Size);
                            btnCaptureRestart.Text = "Again";
                            capture = !capture;
                        }
                    }
                    else
                    {
                        if (device != null && !device.IsRunning)
                        {
                            device.Start();
                            btnCaptureRestart.Text = "Capture";
                            capture = !capture;
                        }
                    }
                };

                this.SizeChanged += delegate
                {
                    picBox.Width               = this.Width - 4;
                    picBox.Height              = this.Height - 30;
                    camerasList.Width          = this.Width / 2;
                    camerasList.Location       = new Point(2, picBox.Bottom + 2);
                    btnCaptureRestart.Width    = this.Width / 4;
                    btnCaptureRestart.Location = new Point(this.Width - (btnCaptureRestart.Width + 2), camerasList.Top);
                };

                this.Disposed += delegate
                {
                    if (device != null && device.IsRunning)
                    {
                        device.Stop();
                    }
                };
            }
示例#24
0
        private void BtnStart_Click_1(object sender, EventArgs e)
        {
            if (cam.IsRunning == false)
            {
                cam.Start();
            }
            if (txtName.Text == "" || txtID.Text == "")    //Name or Id is empty
            {
                MessageBox.Show("Vui Lòng Điền Đầy Đủ Thông Tin !!!");
            }

            else
            {
                click = click + 1;

                if (click >= 6)                 //take more than 5 pics, break
                {
                    MessageBox.Show("Bạn đã chụp đủ 5 ảnh !!!");
                }
                else
                {
                    string B64         = ConvertImageToBase64String(bitmap);
                    string server_ip   = "192.168.1.12";
                    string server_path = "http://" + server_ip + ":8000/capture?name=" + txtName.Text + "&id=" + txtID.Text + "&pic=" + click.ToString();
                    string receive     = sendPOST(server_path, B64);

                    Graphics newGraphics = Graphics.FromImage(bitmap);

                    String[] val = receive.Split(',');
                    // Draw it
                    Pen blackPen = new Pen(Color.Green, 6);

                    if (int.Parse(val[1]) == 0)           //Id is existed
                    {
                        MessageBox.Show("ID này đã tồn tại, vui lòng nhập ID khác");
                        click = click - 1;
                    }
                    else if (int.Parse(val[0]) == 0)       //Can't detect face
                    {
                        MessageBox.Show("Không nhận được mặt, mời bạn chụp lại" + val[0]);
                        click = click - 1;
                    }
                    else              //display saved images(display only faces)
                    {
                        // Create rectangle.
                        Rectangle rect = new Rectangle(int.Parse(val[1]), int.Parse(val[2]), int.Parse(val[3]), int.Parse(val[4]));

                        Bitmap target = new Bitmap(rect.Width, rect.Height);

                        using (Graphics g = Graphics.FromImage(target))
                        {
                            g.DrawImage(bitmap, new Rectangle(0, 0, target.Width, target.Height),
                                        rect,
                                        GraphicsUnit.Pixel);
                            switch (click)
                            {
                            case 1:
                                ptImage1.Image = target;
                                break;

                            case 2:
                                ptImage2.Image = target;
                                break;

                            case 3:
                                ptImage3.Image = target;
                                break;

                            case 4:
                                ptImage4.Image = target;
                                break;

                            case 5:
                                ptImage5.Image = target;
                                break;
                            }
                        }
                    }
                }
            }
        }
 private void btnStart_Click(object sender, EventArgs e)
 {
     videoCaptureDevice           = new VideoCaptureDevice(filterInfoCollection[cmbKamera.SelectedIndex].MonikerString);
     videoCaptureDevice.NewFrame += VideoCaptureDevice_NewFrame;
     videoCaptureDevice.Start();
 }
示例#26
0
 private void btnkameraac_Click(object sender, EventArgs e)
 {
     cam           = new VideoCaptureDevice(wepcam[comboBox1.SelectedIndex].MonikerString);
     cam.NewFrame += new NewFrameEventHandler(cam_Newcam);
     cam.Start();
 }
 public void Bu_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     FinalFrame           = new VideoCaptureDevice(CaptureDevice[Camera_ComboBox.SelectedIndex].MonikerString);
     FinalFrame.NewFrame += new NewFrameEventHandler(FinalFrame_NewFrame);
     FinalFrame.Start();
 }
示例#28
0
private void button1_Click(object sender, EventArgs e)
{
    FinalVideo = new VideoCaptureDevice(VideoCaptureDevices[comboBox1.SelectedIndex].MonikerString);
    FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
    FinalVideo.Start();
}
示例#29
0
 private void button1_Click(object sender, EventArgs e)
 {
     videoCaptureDevice           = new VideoCaptureDevice(filterInfoCollection[comboBox1.SelectedIndex].MonikerString);
     videoCaptureDevice.NewFrame += FinalFrame_NewFrame;
     videoCaptureDevice.Start();
 }
示例#30
0
        public static void Run(MsgPack unpack_msgpack)
        {
            try
            {
                switch (unpack_msgpack.ForcePathObject("Packet").AsString)
                {
                case "webcam":
                {
                    switch (unpack_msgpack.ForcePathObject("Command").AsString)
                    {
                    case "getWebcams":
                    {
                        TempSocket?.Dispose();
                        TempSocket = new TempSocket();
                        if (TempSocket.IsConnected)
                        {
                            GetWebcams();
                        }
                        else
                        {
                            new Thread(() =>
                                    {
                                        try
                                        {
                                            TempSocket.Dispose();
                                            CaptureDispose();
                                        }
                                        catch { }
                                    }).Start();
                        }
                        break;
                    }

                    case "capture":
                    {
                        if (IsOn == true)
                        {
                            return;
                        }
                        if (TempSocket.IsConnected)
                        {
                            IsOn = true;
                            FilterInfoCollection videoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                            FinalVideo                 = new VideoCaptureDevice(videoCaptureDevices[0].MonikerString);
                            Quality                    = (int)unpack_msgpack.ForcePathObject("Quality").AsInteger;
                            FinalVideo.NewFrame       += CaptureRun;
                            FinalVideo.VideoResolution = FinalVideo.VideoCapabilities[unpack_msgpack.ForcePathObject("List").AsInteger];
                            FinalVideo.Start();
                        }
                        else
                        {
                            new Thread(() =>
                                    {
                                        try
                                        {
                                            CaptureDispose();
                                            TempSocket.Dispose();
                                        }
                                        catch { }
                                    }).Start();
                        }
                        break;
                    }

                    case "stop":
                    {
                        new Thread(() =>
                                {
                                    try
                                    {
                                        CaptureDispose();
                                    }
                                    catch { }
                                }).Start();
                        break;
                    }
                    }
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Webcam switch" + ex.Message);
            }
        }
示例#31
0
 public Webcam()
 {
     capture           = new VideoCaptureDevice(webcam[0].MonikerString);
     capture.NewFrame += new NewFrameEventHandler(capture_NewFrame);
     capture.Start();
 }
示例#32
0
 private void retakePic_Click(object sender, EventArgs e)
 {
     videoCaptureDevice.Start();
     takePic.Show();
     retakePic.Hide();
 }
示例#33
0
 private void startButton_Click(object sender, EventArgs e)
 {
     _device           = new VideoCaptureDevice(_filter[deviceComboBox.SelectedIndex].MonikerString);
     _device.NewFrame += DeviceNewFrame;
     _device.Start();
 }