void Initialize() { if (firstActive) { throw new VideoGrabberException("已經呼叫過 BeginGrabber() 方法了!"); } firstActive = true; if (!DsUtils.IsCorrectDirectXVersion()) { EndGrabber(); throw new VideoGrabberException("系統未安裝 DirectX 8.1 以後的版本!"); } /* * //if( ! DsDevice.GetDevicesOfCat( FilterCategory.VideoInputDevice, out capDevices ) ) * if( (capDevices = DsDevice.GetDevicesOfCat( FilterCategory.VideoInputDevice )) == null ) * { * EndGrabber(); * throw new VideoGrabberException("未偵測到視訊裝置!"); * } * * DsDevice dev = null; * if( capDevices.Length == 1 ) * dev = capDevices[0] as DsDevice; * else * { * DeviceSelector selector = new DeviceSelector( capDevices ); * selector.ShowDialog( this ); * dev = selector.SelectedDevice; * } */ if (capDevice == null) { DeviceSelector selector = new DeviceSelector( ); if (selector.Devices.Length > 1) { selector.ShowDialog(this); } capDevice = selector.SelectedDevice; if (capDevice == null) { EndGrabber(); throw new VideoGrabberException("無法取得視訊裝置!"); } } if (!StartupVideo(capDevice.Mon)) { EndPreview(); EndGrabber(); throw new VideoGrabberException("無法初始化設定視訊裝置!"); } }
void Initialize() { if (firstActive) { throw new VideoGrabberException("已經呼叫過 BeginGrabber() 方法了!"); } firstActive = true; if (!DsUtils.IsCorrectDirectXVersion()) { EndGrabber(); throw new VideoGrabberException("系統未安裝 DirectX 8.1 以後的版本!"); } if (capDevice == null) { if ((capDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice)) == null) { EndGrabber(); throw new VideoGrabberException("未偵測到視訊裝置!"); } if (capDevices.Length >= 1) { capDevice = capDevices[0] as DsDevice; } else { DeviceSelector selector = new DeviceSelector(); selector.ShowDialog(this); capDevice = selector.SelectedDevice; } } if (capDevice == null) { EndGrabber(); throw new VideoGrabberException("無法取得視訊裝置!"); } if (!StartupVideo(capDevice.Mon)) { EndGrabber(); throw new VideoGrabberException("無法初始化設定視訊裝置!"); } grabberThread = new Thread(new ThreadStart(Processing)); }