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(); }
private void BtnTakePhoto_Click(object sender, EventArgs e) { try { var frm = new CameraSelection(); frm.StartPosition = FormStartPosition.CenterParent; if (frm.ShowDialog() == DialogResult.OK) { if (frm.CAMERA != null) { isChangePhoto = true; picPhoto.Image = frm.CAMERA; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// -------------------------------------------------------- // Button handling // -------------------------------------------------------- private void openWebcamClick(object sender, RoutedEventArgs e) { StopTracking(); if (cam_sec == null) { cam_sec = new CameraSelection(); } else { cam_sec = new CameraSelection(cam_sec.cams); cam_sec.Visibility = System.Windows.Visibility.Visible; } // Set the icon Uri iconUri = new Uri("logo1.ico", UriKind.RelativeOrAbsolute); cam_sec.Icon = BitmapFrame.Create(iconUri); if (!cam_sec.no_cameras_found) { cam_sec.ShowDialog(); } if (cam_sec.camera_selected) { int cam_id = cam_sec.selected_camera.Item1; int width = cam_sec.selected_camera.Item2; int height = cam_sec.selected_camera.Item3; SequenceReader reader = new SequenceReader(cam_id, width, height); processing_thread = new Thread(() => ProcessingLoop(reader)); processing_thread.Name = "Webcam processing"; processing_thread.Start(); } }
private void btnReadCard_Click(object sender, EventArgs e) { try { var frm = new CameraSelection(); frm.StartPosition = FormStartPosition.CenterParent; if (frm.ShowDialog() == DialogResult.OK) { if (frm.CAMERA != null) { isChangeCardPhoto = true; picCard.Image = frm.CAMERA; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } #region === Old === //try //{ // var frm = new CardSelection(); // frm.StartPosition = FormStartPosition.CenterParent; // if (frm.ShowDialog() == DialogResult.OK) // { // if (frm.READ_CARD_STATUS) // { // if (frm.CARD_TYPE == "PID") // { // //บัตรประชาชน // txtFirstName.Text = frm.CARD.TH_FIRST_NAME; // txtLastName.Text = frm.CARD.TH_LAST_NAME; // txtIDCard.Text = frm.CARD.NO; // picCard.Image = (Image)frm.CARD.PHOTO; // CARD_IMAGE = frm.CARD.CARD_IMAGE; // BYTE_IMAGE = frm.CARD.BYTE_IMAGE; // isChangeCardPhoto = true; // var data = _blService.GetBlackListByIdCard(txtIDCard.Text); // if (data.TRN_BLACKLIST == null) // { // MessageBox.Show("อ่านข้อมูลจากบัตรประชาชน เรียบร้อย!!!"); // } // else // { // var blData = data.TRN_BLACKLIST; // var msg = "เลขบัตรประชาชน : " + blData.ID_CARD + Environment.NewLine + "ชื่อ-สกุล : " + blData.FIRST_NAME + " " + blData.LAST_NAME; // msg += Environment.NewLine + "เหตุผล : " + blData.REASON; // msg += Environment.NewLine + "ณ วันที่ : " + blData.UPDATED_DATE; // MessageBox.Show(msg, "บุคคล Blacklist", MessageBoxButtons.OK, MessageBoxIcon.Error); // //this.Close(); // } // } // else // { // //ใบขับขี่ // txtFirstName.Text = frm.DID.FIRST_NAME_EN; // txtLastName.Text = frm.DID.LAST_NAME_EN; // txtIDCard.Text = frm.DID.NO; // var data = _blService.GetBlackListByIdCard(txtIDCard.Text); // if (data.TRN_BLACKLIST == null) // { // MessageBox.Show("อ่านข้อมูลจากใบขับขี่ เรียบร้อย!!!"); // } // else // { // var blData = data.TRN_BLACKLIST; // var msg = "เลขบัตรประชาชน : " + blData.ID_CARD + Environment.NewLine + "ชื่อ-สกุล : " + blData.FIRST_NAME + " " + blData.LAST_NAME; // msg += Environment.NewLine + "เหตุผล : " + blData.REASON; // msg += Environment.NewLine + "ณ วันที่ : " + blData.UPDATED_DATE; // MessageBox.Show(msg, "บุคคล Blacklist", MessageBoxButtons.OK, MessageBoxIcon.Error); // //this.Close(); // } // } // } // } //} //catch (Exception ex) //{ // MessageBox.Show(ex.Message); //} #endregion }