private void CameraGUI_Load(object sender, EventArgs e)
        {
            CameraContainer = new DirectX.Capture.Filters();
            try
            {
                int totalOfAvailableCameras = CameraContainer.VideoInputDevices.Count;

                for (int i = 0; i < totalOfAvailableCameras; i++)
                {
                    try
                    {
                        Camera = CameraContainer.VideoInputDevices[i];
                        if (Camera.Name.Contains("PC CAMERA") && Camera.MonikerString.Equals(CameraId))
                        {
                            CameraCaptureInfo = new DirectX.Capture.Capture(Camera, null);
                            CameraCaptureInfo.PreviewWindow         = this.picWebCam;
                            CameraCaptureInfo.FrameCaptureComplete += UpdateImage;
                            CameraCaptureInfo.CaptureFrame();
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
            }
        }
Beispiel #2
0
 public SecurityCamera(string Name, string RecordPath, DirectX.Capture.Filter VideoDevice, DirectX.Capture.Filter AudioDevice)
 {
     name        = Name;
     recordPath  = RecordPath;
     videoDevice = VideoDevice;
     audioDevice = AudioDevice;
 }
Beispiel #3
0
 public Capture(DirectX.Capture.Filter videoDevice, DirectX.Capture.Filter audioDevice)
 {
     if ((videoDevice == null) && (audioDevice == null))
     {
         throw new ArgumentException("The videoDevice and/or the audioDevice parameter must be set to a valid Filter.\n");
     }
     this.videoDevice = videoDevice;
     this.audioDevice = audioDevice;
     this.Filename = this.getTempFilename();
     this.createGraph();
 }
 protected void getFilters(Guid category)
 {
     object o = null;
     ICreateDevEnum enum2 = null;
     UCOMIEnumMoniker ppEnumMoniker = null;
     UCOMIMoniker[] rgelt = new UCOMIMoniker[1];
     try
     {
         int num2;
         Type typeFromCLSID = Type.GetTypeFromCLSID(Clsid.SystemDeviceEnum);
         if (typeFromCLSID == null)
         {
             throw new NotImplementedException("System Device Enumerator");
         }
         o = Activator.CreateInstance(typeFromCLSID);
         enum2 = (ICreateDevEnum) o;
         if (enum2.CreateClassEnumerator(ref category, out ppEnumMoniker, 0) != 0)
         {
             throw new NotSupportedException("No devices of the category");
         }
         while ((ppEnumMoniker.Next(1, rgelt, out num2) == 0) && (rgelt[0] != null))
         {
             DirectX.Capture.Filter filter = new DirectX.Capture.Filter(rgelt[0]);
             base.InnerList.Add(filter);
             Marshal.ReleaseComObject(rgelt[0]);
             rgelt[0] = null;
         }
         base.InnerList.Sort();
     }
     finally
     {
         enum2 = null;
         if (rgelt[0] != null)
         {
             Marshal.ReleaseComObject(rgelt[0]);
         }
         rgelt[0] = null;
         if (ppEnumMoniker != null)
         {
             Marshal.ReleaseComObject(ppEnumMoniker);
         }
         ppEnumMoniker = null;
         if (o != null)
         {
             Marshal.ReleaseComObject(o);
         }
         o = null;
     }
 }
        private void FormSetup_Load(object sender, EventArgs e)
        {
            try
            {
                CameraContainer         = new DirectX.Capture.Filters();
                totalOfAvailableCameras = CameraContainer.VideoInputDevices.Count;

                for (int i = 0; i < totalOfAvailableCameras; i++)
                {
                    try
                    {
                        Camera = CameraContainer.VideoInputDevices[i];
                        if (Camera.Name.Contains("PC CAMERA"))
                        {
                            if (leftRightFlag == 0)
                            {
                                CameraCaptureInfo1 = new DirectX.Capture.Capture(Camera, null);
                                cam1String         = Camera.MonikerString;
                                rtxtBoxCam1.Text   = Camera.MonikerString;
                            }
                            else
                            {
                                CameraCaptureInfo2 = new DirectX.Capture.Capture(Camera, null);
                                cam2String         = Camera.MonikerString;
                                rtxtBoxCam2.Text   = Camera.MonikerString;
                            }
                            if (leftRightFlag >= 1)
                            {
                                break;
                            }
                            leftRightFlag++;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }

                StartCam1();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
            }
        }
        private void frmFotografar_Load(object sender, EventArgs e)
        {
            btnSalvar.Enabled = false;

            CamContainer = new DirectX.Capture.Filters();
            try
            {
                int no_of_cam = CamContainer.VideoInputDevices.Count;

                for (int i = 0; i < no_of_cam; i++)
                {
                    try
                    {
                        // obtém o dispositivo de entrada do vídeo
                        Camera = CamContainer.VideoInputDevices[i];

                        // inicializa a Captura usando o dispositivo
                        CaptureInfo = new DirectX.Capture.Capture(Camera, null);

                        // Define a janela de visualização do vídeo
                        CaptureInfo.PreviewWindow = picWebCam;

                        // Capturando o tratamento de evento
                        CaptureInfo.FrameCaptureComplete += AtualizaImagem;

                        // Captura o frame do dispositivo

                        CaptureInfo.CaptureFrame();

                        // Se o dispositivo foi encontrado e inicializado então sai sem checar o resto
                        break;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            catch
            {
                MessageBox.Show("Ocorreu um erro interno. Tente novamente!");
            }
        }
Beispiel #7
0
        public void startTranslation(PictureBox window)
        {
            CamContainer = new DirectX.Capture.Filters();

            try
            {
                int no_of_cam = CamContainer.VideoInputDevices.Count;

                for (int i = 0; i < no_of_cam; i++)
                {
                    try
                    {
                        // get the video input device
                        Camera = CamContainer.VideoInputDevices[i];

                        // initialize the Capture using the video input device
                        CaptureInfo = new DirectX.Capture.Capture(Camera, null);

                        // set the input video preview window
                        CaptureInfo.PreviewWindow = window;

                        //set frame size
                        CaptureInfo.FrameSize = new Size(640, 480);

                        CaptureInfo.RenderPreview();

                        // Capturing complete event handler
                        CaptureInfo.FrameCaptureComplete += new DirectX.Capture.Capture.FrameCapHandler(RefreshImage);

                        // Capture the frame from input device
                        CaptureInfo.CaptureFrame();

                        // if device found and initialize properly then exit without
                        // checking rest of input device
                        break;
                    }
                    catch (Exception ex) { }
                }
            }
            catch (Exception ex) { }
        }
Beispiel #8
0
        private void WebCam_Load(object sender, EventArgs e)
        {
            CamContainer = new DirectX.Capture.Filters();
            try
            {
                int no_of_cam = CamContainer.VideoInputDevices.Count;

                for (int i = 0; i < no_of_cam; i++)
                {
                    try
                    {
                        // obtém o dispositivo de entrada do vídeo
                        Camera = CamContainer.VideoInputDevices[i];

                        // inicializa a Captura usando o dispositivo
                        CaptureInfo = new DirectX.Capture.Capture(Camera, null);

                        // Define a janela de visualização do vídeo
                        CaptureInfo.PreviewWindow = this.pictureBox1;

                        // Capturando o tratamento de evento
                        CaptureInfo.FrameCaptureComplete += AtualizaImagem;

                        // Captura o frame do dispositivo
                        CaptureInfo.CaptureFrame();

                        // Se o dispositivo foi encontrado e inicializado então sai sem checar o resto
                        break;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
            }
        }
Beispiel #9
0
        private void Form1_Load(object sender, EventArgs e)
        {
            CamContainer = new DirectX.Capture.Filters();

            try
            {
                int no_of_cam = CamContainer.VideoInputDevices.Count;

                for (int i = 0; i < no_of_cam; i++)
                {
                    try
                    {
                        Camera = CamContainer.VideoInputDevices[i];

                        CaptureInfo = new DirectX.Capture.Capture(Camera, null);

                        CaptureInfo.PreviewWindow = this.pictureBox1;

                        CaptureInfo.FrameCaptureComplete += RefreshImage;


                        CaptureInfo.Width  = 800;
                        CaptureInfo.Height = 600;

                        CaptureInfo.CaptureFrame();


                        break;
                    }
                    catch (Exception ex) { }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "No Video Device Found", "Error:");
            }
        }