Exemple #1
0
        /// <summary>
        /// This method shows a <see cref="WebcamPropertiesDlg"/>
        /// to modify the current <see cref="CaptureDeviceProperties"/>
        /// and afterwards reinitializes the webcam.
        /// </summary>
        public void ShowConfigureDialog(bool restartCamera)
        {
            if (this.dxCapture == null)
            {
                return;
            }

            WebcamPropertiesDlg dialog = new WebcamPropertiesDlg(this.dxCapture);

            //dialog.Properties = this.properties;
            //dialog.ShouldPreview = true;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                // Update properties
                // Validation check is within dialog
                this.properties = dialog.Properties;
                this.properties.PreviewWindow = this;
            }

            if (restartCamera)
            {
                // Restart webcam
                this.InitializeWebcam(this.properties);
                this.RunGraph();
            }
        }
Exemple #2
0
        ///////////////////////////////////////////////////////////////////////////////
        // Construction and Initializing methods                                     //
        ///////////////////////////////////////////////////////////////////////////////
        #region CONSTRUCTION

        /// <summary>
        /// Initializes an instance of the <see cref="DXCapture"/> class
        /// with the given <see cref="CaptureDeviceProperties"/>
        /// </summary>
        /// <param name="properties">A <see cref="CaptureDeviceProperties"/> containing the options
        /// for the DirectShow graph.</param>
        public DXCapture(CaptureDeviceProperties properties)
        {
            this.captureDeviceProperties = properties;
            this.CheckFramerateAndSize(
                this.captureDeviceProperties.VideoInputDevice,
                properties.FrameRate,
                properties.VideoSize);
            this.CreateGraph();
        }
Exemple #3
0
        /// <summary>
        /// This method creates a new <see cref="DXCapture"/>
        /// with the given <see cref="CaptureDeviceProperties"/>
        /// </summary>
        /// <param name="captureProperties">A <see cref="CaptureDeviceProperties"/>
        /// to use for creating the underlying <see cref="DXCapture"/></param>
        private void InitializeWebcam(CaptureDeviceProperties captureProperties)
        {
            if (this.DesignMode)
            {
                return;
            }

            if (captureProperties == null)
            {
                // We dont want to initialize a webcam
                return;
            }

            if (captureProperties.VideoInputDevice.Name == "OgamaScreenCapture Filter")
            {
                // We dont want to initialize a webcam with the
                // ScreenCapture Filter
                return;
            }

            if (this.dxCapture != null)
            {
                this.dxCapture.Dispose();
            }

            // If this control is attached use itself for previewing
            // otherwise use the given preview window
            if (this.Parent != null)
            {
                captureProperties.PreviewWindow = this;
            }

            this.dxCapture = new DXCapture(captureProperties);

            // Check the current valid CaptureMode
            //CaptureMode available = CaptureMode.None;
            //if ((captureProperties.CaptureMode & CaptureMode.Video) == CaptureMode.VideoPreview)
            //{
            //  available |= CaptureMode.Video;
            //}

            //if (audioDevice != null)
            //{
            //  available |= CaptureMode.Audio;
            //}

            this.OnWebcamAvailable(new CaptureModeEventArgs(captureProperties.CaptureMode));
        }
Exemple #4
0
        private void RebuildDXCapture(CaptureDeviceProperties captureProperties)
        {
            if (this.dxCapture != null)
            {
                this.dxCapture.Dispose();
            }

            if (!this.DesignMode)//this.shouldPreview &&
            {
                captureProperties.PreviewWindow = this.panelPreview;
            }
            else
            {
                captureProperties.PreviewWindow = null;
            }

            this.dxCapture = new DXCapture(captureProperties);
            this.dxCapture.ShowPreviewWindow();
            //this.dxCapture.Start();
        }
Exemple #5
0
        ///////////////////////////////////////////////////////////////////////////////
        // Methods and Eventhandling for Background tasks                            //
        ///////////////////////////////////////////////////////////////////////////////
        #region BACKGROUNDWORKER
        #endregion //BACKGROUNDWORKER

        ///////////////////////////////////////////////////////////////////////////////
        // Methods for doing main class job                                          //
        ///////////////////////////////////////////////////////////////////////////////
        #region PRIVATEMETHODS

        /// <summary>
        /// This method initializes the webcam with default values
        /// for video and audio capturing.
        /// </summary>
        private void InitializeCustomComponents()
        {
            this.properties = new CaptureDeviceProperties();
            //this.stopWatch = new Stopwatch();
            if (DirectShowDevices.Instance.Cameras.Count > 0)
            {
                this.properties.VideoInputDevice = DirectShowDevices.Instance.Cameras[0];
            }

            DsDevice[] videoCompressors = DsDevice.GetDevicesOfCat(FilterCategory.VideoCompressorCategory);
            foreach (DsDevice compressor in videoCompressors)
            {
                if (compressor.Name.Contains("Microsoft Video 1"))
                {
                    this.properties.VideoCompressor = compressor.Name;
                    break;
                }
            }

            DsDevice[] audioInputDevices = DsDevice.GetDevicesOfCat(FilterCategory.AudioInputDevice);
            if (audioInputDevices.Length > 0)
            {
                this.properties.AudioInputDevice = audioInputDevices[0].Name;
            }

            DsDevice[] audioCompressors = DsDevice.GetDevicesOfCat(FilterCategory.AudioCompressorCategory);
            foreach (DsDevice compressor in audioCompressors)
            {
                if (compressor.Name == "PCM")
                {
                    this.properties.AudioCompressor = compressor.Name;
                    break;
                }
            }

            this.properties.FrameRate   = 10;
            this.properties.VideoSize   = new Size(320, 240);
            this.properties.CaptureMode = CaptureMode.AudioVideoPreview;
        }
Exemple #6
0
    /// <summary>
    /// This method initializes the user canera on first start of the
    ///   presentation.
    /// </summary>
    /// <param name="value">
    /// A <see cref="CaptureDeviceProperties"/>
    ///   with the device and compressor to be used for the webcam.
    /// </param>
    private void InitializeUserCamera(CaptureDeviceProperties value)
    {
      if (value == null)
      {
        // No need to initalize
        return;
      }

      this.userCamera = new Webcam();
      this.userCamera.Properties = value;
    }
Exemple #7
0
    private void RebuildDXCapture(CaptureDeviceProperties captureProperties)
    {
      if (this.dxCapture != null)
      {
        this.dxCapture.Dispose();
      }

      if (!this.DesignMode)//this.shouldPreview && 
      {
        captureProperties.PreviewWindow = this.panelPreview;
      }
      else
      {
        captureProperties.PreviewWindow = null;
      }

      this.dxCapture = new DXCapture(captureProperties);
      this.dxCapture.ShowPreviewWindow();
      //this.dxCapture.Start();
    }
    ///////////////////////////////////////////////////////////////////////////////
    // Construction and Initializing methods                                     //
    ///////////////////////////////////////////////////////////////////////////////
    #region CONSTRUCTION

    /// <summary>
    /// Initializes a new instance of the ImageFromVectorGraphics class.
    /// </summary>
    /// <param name="newVideoProperties">A <see cref="CaptureDeviceProperties"/> with the properties to use for this object.</param>
    /// <param name="newSectionStartTime">A <see cref="long"/> with the start time of the video section.</param>
    /// <param name="newSectionEndTime">A <see cref="long"/> with the end time of the video section.</param>
    /// <param name="newVideoFramePusher">A <see cref="VideoFramePusher"/> that populates the image with a background video frame.</param>
    /// <param name="newImageRenderer">The <see cref="Ogama.Modules.Replay.ReplayPicture.RenderFrameHandler"/> that is the delegate to get the images from.</param>
    public ImageFromVectorGraphics(
      CaptureDeviceProperties newVideoProperties,
      long newSectionStartTime,
      long newSectionEndTime,
      VideoFramePusher newVideoFramePusher,
      Ogama.Modules.Replay.ReplayPicture.RenderFrameHandler newImageRenderer)
    {
      int fps = newVideoProperties.FrameRate;
      this.framesPerSecond = UNIT / fps;
      this.frameTimeSpan = (int)(1000f / fps);
      this.videoSize = newVideoProperties.VideoSize;
      this.sectionStartTime = newSectionStartTime;
      this.sectionEndTime = newSectionEndTime;
      this.videoFramePusher = newVideoFramePusher;
      this.imageRenderer = newImageRenderer;
    }
Exemple #9
0
    ///////////////////////////////////////////////////////////////////////////////
    // Construction and Initializing methods                                     //
    ///////////////////////////////////////////////////////////////////////////////
    #region CONSTRUCTION

    /// <summary>
    /// Initializes an instance of the <see cref="DXCapture"/> class
    /// with the given <see cref="CaptureDeviceProperties"/>
    /// </summary>
    /// <param name="properties">A <see cref="CaptureDeviceProperties"/> containing the options
    /// for the DirectShow graph.</param>
    public DXCapture(CaptureDeviceProperties properties)
    {
      this.captureDeviceProperties = properties;
      this.CheckFramerateAndSize(
        this.captureDeviceProperties.VideoInputDevice,
        properties.FrameRate,
        properties.VideoSize);
      this.CreateGraph();
    }
Exemple #10
0
    ///////////////////////////////////////////////////////////////////////////////
    // Methods and Eventhandling for Background tasks                            //
    ///////////////////////////////////////////////////////////////////////////////
    #region THREAD
    #endregion //THREAD

    ///////////////////////////////////////////////////////////////////////////////
    // Methods for doing main class job                                          //
    ///////////////////////////////////////////////////////////////////////////////
    #region PRIVATEMETHODS

    /// <summary>
    /// This method fills the <see cref="CaptureDeviceProperties"/> according to the current selections.
    /// </summary>
    /// <returns>The <see cref="CaptureDeviceProperties"/> according to the current selections.</returns>
    private CaptureDeviceProperties GetVideoProperties()
    {
      CaptureDeviceProperties currentProperties = new CaptureDeviceProperties();

      if (this.cbbVideoCompressor.SelectedItem != null)
      {
        currentProperties.VideoCompressor = this.cbbVideoCompressor.SelectedItem.ToString();
      }

      if (this.cbbAudioCompressor.SelectedItem != null)
      {
        currentProperties.AudioCompressor = this.cbbAudioCompressor.SelectedItem.ToString();
      }

      if (this.cbbVideoSize.SelectedItem != null)
      {
        string[] sizes = this.cbbVideoSize.SelectedItem.ToString().Split('x');
        currentProperties.VideoSize = new Size(Convert.ToInt32(sizes[0]), Convert.ToInt32(sizes[1]));
      }

      currentProperties.FrameRate = (int)this.nudFrameRate.Value;

      return currentProperties;
    }
Exemple #11
0
    /// <summary>
    /// This method creates a new <see cref="DXCapture"/>
    /// with the given <see cref="CaptureDeviceProperties"/>
    /// </summary>
    /// <param name="captureProperties">A <see cref="CaptureDeviceProperties"/>
    /// to use for creating the underlying <see cref="DXCapture"/></param>
    private void InitializeWebcam(CaptureDeviceProperties captureProperties)
    {
      if (this.DesignMode)
      {
        return;
      }

      if (captureProperties == null)
      {
        // We dont want to initialize a webcam
        return;
      }

      if (captureProperties.VideoInputDevice.Name == "OgamaScreenCapture Filter")
      {
        // We dont want to initialize a webcam with the
        // ScreenCapture Filter
        return;
      }

      if (this.dxCapture != null)
      {
        this.dxCapture.Dispose();
      }

      // If this control is attached use itself for previewing
      // otherwise use the given preview window
      if (this.Parent != null)
      {
        captureProperties.PreviewWindow = this;
      }

      this.dxCapture = new DXCapture(captureProperties);

      // Check the current valid CaptureMode
      //CaptureMode available = CaptureMode.None;
      //if ((captureProperties.CaptureMode & CaptureMode.Video) == CaptureMode.VideoPreview)
      //{
      //  available |= CaptureMode.Video;
      //}

      //if (audioDevice != null)
      //{
      //  available |= CaptureMode.Audio;
      //}

      this.OnWebcamAvailable(new CaptureModeEventArgs(captureProperties.CaptureMode));
    }
Exemple #12
0
    ///////////////////////////////////////////////////////////////////////////////
    // Methods and Eventhandling for Background tasks                            //
    ///////////////////////////////////////////////////////////////////////////////
    #region BACKGROUNDWORKER
    #endregion //BACKGROUNDWORKER

    ///////////////////////////////////////////////////////////////////////////////
    // Methods for doing main class job                                          //
    ///////////////////////////////////////////////////////////////////////////////
    #region PRIVATEMETHODS

    /// <summary>
    /// This method initializes the webcam with default values
    /// for video and audio capturing.
    /// </summary>
    private void InitializeCustomComponents()
    {
      this.properties = new CaptureDeviceProperties();
      //this.stopWatch = new Stopwatch();
      if (DirectShowDevices.Instance.Cameras.Count > 0)
      {
        this.properties.VideoInputDevice = DirectShowDevices.Instance.Cameras[0];
      }

      DsDevice[] videoCompressors = DsDevice.GetDevicesOfCat(FilterCategory.VideoCompressorCategory);
      foreach (DsDevice compressor in videoCompressors)
      {
        if (compressor.Name.Contains("Microsoft Video 1"))
        {
          this.properties.VideoCompressor = compressor.Name;
          break;
        }
      }

      DsDevice[] audioInputDevices = DsDevice.GetDevicesOfCat(FilterCategory.AudioInputDevice);
      if (audioInputDevices.Length > 0)
      {
        this.properties.AudioInputDevice = audioInputDevices[0].Name;
      }

      DsDevice[] audioCompressors = DsDevice.GetDevicesOfCat(FilterCategory.AudioCompressorCategory);
      foreach (DsDevice compressor in audioCompressors)
      {
        if (compressor.Name == "PCM")
        {
          this.properties.AudioCompressor = compressor.Name;
          break;
        }
      }

      this.properties.FrameRate = 10;
      this.properties.VideoSize = new Size(320, 240);
      this.properties.CaptureMode = CaptureMode.AudioVideoPreview;
    }
Exemple #13
0
    /// <summary>
    /// This method shows a <see cref="WebcamPropertiesDlg"/>
    /// to modify the current <see cref="CaptureDeviceProperties"/>
    /// and afterwards reinitializes the webcam.
    /// </summary>
    public void ShowConfigureDialog(bool restartCamera)
    {
      if (this.dxCapture == null)
      {
        return;
      }

      WebcamPropertiesDlg dialog = new WebcamPropertiesDlg(this.dxCapture);
      //dialog.Properties = this.properties;
      //dialog.ShouldPreview = true;

      if (dialog.ShowDialog() == DialogResult.OK)
      {
        // Update properties
        // Validation check is within dialog
        this.properties = dialog.Properties;
        this.properties.PreviewWindow = this;
      }

      if (restartCamera)
      {
        // Restart webcam
        this.InitializeWebcam(this.properties);
        this.RunGraph();
      }
    }