private void Settingdetectsection_Load(object sender, EventArgs e) { try { videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); if (videoDevices.Count == 0) { throw new ApplicationException(); } int i = 0; foreach (FilterInfo device in videoDevices) { if (device.Name == "USB2.0 Camera") { devicename = device.Name; VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[i].MonikerString); videoSource.VideoResolution = videoSource.VideoCapabilities[0]; framewidth = videoSource.VideoResolution.FrameSize.Width / 320; frameheight = videoSource.VideoResolution.FrameSize.Height / 240; videoSource.DesiredFrameSize = new Size(320, 240); videoSource.DesiredFrameRate = 1; videPlayer.VideoSource = videoSource; videPlayer.Start(); } i++; } neededboxes = methodtemp.getsettinglist().Count; settingdetectsectionneededvaluelabel.Text = neededboxes.ToString(); for (int j = 0; j < methodtemp.getsettinglist().Count; j++) { TabPage tab = new TabPage(); tab.Name = ((Settingentity)methodtemp.getsettinglist()[j]).getparamatername(); tab.Text = ((Settingentity)methodtemp.getsettinglist()[j]).getparamatername(); Settingimagedetection tempentity = new Settingimagedetection(this, ((Settingentity)methodtemp.getsettinglist()[j]).getparamatername(), framewidth, frameheight); tempentity.TopLevel = false; tab.Controls.Add(tempentity); this.tabControl1.TabPages.Add(tab); tempentity.Show(); tabControl1.SelectedIndex = 0; tabControl1_SelectedIndexChanged(null, null); } } catch (ApplicationException) { videoDevices = null; } }
public void settingdetectsectionload(string tempdevicename) { try { videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); if (videoDevices.Count == 0) { throw new ApplicationException(); } int i = 0; foreach (FilterInfo device in videoDevices) { if (device.Name == tempdevicename) { devicename = device.Name; VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[i].MonikerString); videoSource.VideoResolution = videoSource.VideoCapabilities[resolution]; videoSource.DesiredFrameSize = new Size(320, 240); videoSource.DesiredFrameRate = 1; videPlayer.VideoSource = videoSource; videPlayer.Start(); } i++; } for (int j = 0; j < methodtemp.getsettinglist().Count; j++) { TabPage tab = new TabPage(); tab.Name = ((Settingentity)methodtemp.getsettinglist()[j]).getparamatername(); tab.Text = ((Settingentity)methodtemp.getsettinglist()[j]).getparamatername(); Settingimagedetection tempentity = new Settingimagedetection(this, ((Settingentity)methodtemp.getsettinglist()[j]).getparamatername(), framewidth, frameheight); tempentity.TopLevel = false; tab.Controls.Add(tempentity); this.tabControl1.TabPages.Add(tab); tempentity.Show(); } } catch (ApplicationException) { videoDevices = null; } }