Esempio n. 1
0
        /// <summary>
        /// Initializes camera, builds and runs graph for control.
        /// </summary>
        /// <param name="moniker">Moniker (device identification) of camera.</param>
        /// <param name="resolution">Resolution of camera's output.</param>
        public void SetCamera(IMoniker moniker, Resolution resolution)
        {
            // Close current if it was opened
            CloseCamera();

            if (moniker == null)
            {
                return;
            }

            // Create camera object
            _Camera = new Camera();

            if (!string.IsNullOrEmpty(_DirectShowLogFilepath))
            {
                _Camera.DirectShowLogFilepath = _DirectShowLogFilepath;
            }

            // select resolution
            //ResolutionList resolutions = Camera.GetResolutionList(moniker);

            if (resolution != null)
            {
                _Camera.Resolution = resolution;
            }
            else
            {
                // When there is no resolution has been specified, try to find the best one

                ResolutionList resolution_list = Camera.GetResolutionList(moniker);

                foreach (Resolution res in resolution_list)
                {
                    if (res.CompareTo(resolution) == 1)       // update resolution whenever res is larger than resolution (null is the smallest)
                    {
                        resolution = res;
                    }
                }
                _Camera.Resolution = resolution;
            }

            // Initialize
            _Camera.Initialize(this, moniker);

            // Build and Run graph
            _Camera.BuildGraph();
            _Camera.RunGraph();


            _Camera.OutputVideoSizeChanged += Camera_OutputVideoSizeChanged;
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes camera, builds and runs graph for control.
        /// </summary>
        /// <param name="moniker">Moniker (device identification) of camera.</param>
        /// <param name="resolution">Resolution of camera's output.</param>
        public void SetCamera(IMoniker moniker, Resolution resolution)
        {
            // Close current if it was opened
            CloseCamera();

            if (moniker == null)
            {
                return;
            }

            // Create camera object
            _Camera = new Camera();

            if (!string.IsNullOrEmpty(_DirectShowLogFilepath))
            {
                _Camera.DirectShowLogFilepath = _DirectShowLogFilepath;
            }

            // select resolution
            //ResolutionList resolutions = Camera.GetResolutionList(moniker);

            if (resolution != null)
            {
                _Camera.Resolution = resolution;
            }

            // Initialize
            _Camera.Initialize(this, moniker);

            // Build and Run graph
            _Camera.BuildGraph();
            _Camera.RunGraph();


            _Camera.OutputVideoSizeChanged += Camera_OutputVideoSizeChanged;
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes camera, builds and runs graph for control.
        /// </summary>
        /// <param name="moniker">Moniker (device identification) of camera.</param>
        /// <param name="resolution">Resolution of camera's output.</param>
        public void SetCamera(IMoniker moniker, Resolution resolution)
        {
            // Close current if it was opened
            CloseCamera();

            if (moniker == null)
                return;

            // Create camera object
            _Camera = new Camera();

            if (!string.IsNullOrEmpty(_DirectShowLogFilepath))
                _Camera.DirectShowLogFilepath = _DirectShowLogFilepath;

            // select resolution
            //ResolutionList resolutions = Camera.GetResolutionList(moniker);

            if (resolution != null)
            {
                _Camera.Resolution = resolution;
            }

            // Initialize
            _Camera.Initialize(this, moniker);

            // Build and Run graph
            _Camera.BuildGraph();
            _Camera.RunGraph();


            _Camera.OutputVideoSizeChanged += Camera_OutputVideoSizeChanged;
        }