Пример #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;
            }

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

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


            _Camera.OutputVideoSizeChanged += Camera_OutputVideoSizeChanged;
        }