/*-------------------------------------------------------------------------------------------------------*/ public VideoScreen() { InitializeComponent(); cameraControl = new Camera_NET.CameraControl(); _CameraChoice = new CameraChoice(); InitializeDirectShow(); }
// On load of Form private void FormVerySimple_Load(object sender, EventArgs e) { // Camera choice CameraChoice _CameraChoice = new CameraChoice(); // Get List of devices (cameras) _CameraChoice.UpdateDeviceList(); // To get an example of camera and resolution change look at other code samples if (_CameraChoice.Devices.Count > 0) { // Device moniker. It's like device id or handle. // Run first camera if we have one var camera_moniker = _CameraChoice.Devices[0].Mon; // Set selected camera to camera control with default resolution cameraControl.SetCamera(camera_moniker, null); } }
public IHardwareProxy LoadFromHardwareId(string hardwareId) { if(string.IsNullOrEmpty(hardwareId)) return null; string[] parts = hardwareId.Split("|".ToCharArray()); if (parts.Length < 2) return null; Guid id = new Guid(parts[0]); string resstr = parts[1]; CameraChoice cams = new CameraChoice(); cams.UpdateDeviceList(); IMoniker moniker= null; foreach (var camera_device in cams.Devices) { if(camera_device.Mon!=null) { Guid camid; camera_device.Mon.GetClassID(out camid); if(camid == id) { moniker = camera_device.Mon; break; } } } if (moniker == null) return null; ResolutionList resolutions = Camera.GetResolutionList(moniker); if (resolutions == null) return null; RotateFlipType rotation = RotateFlipType.RotateNoneFlipNone; if (parts.Length >= 3) rotation = (RotateFlipType)Enum.Parse(typeof(RotateFlipType),parts[2],true); for (int index = 0; index < resolutions.Count; index++) { if (resstr == resolutions[index].ToString()) { NetCameraProxy proxy = new NetCameraProxy(); proxy.SetCamera(moniker, resolutions[index]); proxy.Rotation = rotation; return proxy; } } return null; }