public WFOVPanel(TIS.Imaging.ICImagingControl wfovContainer) { this.SetStyle(ControlStyles.Opaque, true); this.SetStyle(ControlStyles.DoubleBuffer, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.UserPaint, true); this.DoubleBuffered = true; this.wfovContainer = wfovContainer; }
private async Task <DeviceBatchScanVM> InitializeAsync(DeviceBatch batch) { return(await Task.Run(async() => { InstrumentService.LJVScanCoordinator.PurgeSubscribers(); InstrumentService.LJVScanCoordinator.SelectedCoordsDict = InstrumentService.LJVScanCoordinator.TheCoordsDictsDict["XinYan"]; theDeviceBatch = batch; //calculate presentTestCondition HashSet <string> testConditionsFromChildren = new HashSet <string>(); foreach (Device d in theDeviceBatch.Devices) { foreach (DeviceLJVScanSummary summary in d.DeviceLJVScanSummaries) { testConditionsFromChildren.Add(summary.TestCondition); } } int numberOfScans = testConditionsFromChildren.Count; int daysSinceFabrication = (DateTime.Now - theDeviceBatch.FabDate).Days; string presentTestCondition = string.Concat("t", numberOfScans + 1, ".", daysSinceFabrication); BatchScanSpec.TestCondition = presentTestCondition; Debug.WriteLine("presentTestCondition: " + presentTestCondition); //create sdsvms for each device foreach (Device d in theDeviceBatch.Devices) { var newSDSVM = await SingleDeviceScanVM.CreateAsync(d, ctx); newSDSVM.SaveDirectory = string.Concat(theDeviceBatch.FilePath, @"\", presentTestCondition); ScanVMs.Add(newSDSVM); } UpdateBatchScanSpec(); //CopyPreviousScanSpecs(); ScanVMs.OrderBy(x => x.TheDeviceVM.TheDevice.BatchIndex); ScanSelectedDevicesCommand = AsyncCommand.Create(token => ScanSelectedDevices(token)); string prCamModel = ConfigurationManager.AppSettings.Get("BatchTestSystem"); if (prCamModel == "BTS1") { delaysDict["Initialize"] = 50000; delaysDict["Swap"] = 42000; } else if (prCamModel == "BTS2") { delaysDict["Initialize"] = 17000; delaysDict["Swap"] = 23000; TheImagingControl = InstrumentService.LJVScanCoordinator.TheImagingControl; } else { Debug.WriteLine("BatchTestSystem needs to be properly set in App.Config"); } return this; }).ConfigureAwait(false)); }
private async Task <SingleDeviceScanVM> InitializeAsync(Device dev, DeviceBatchContext context) { return(await Task.Run(() => { TheDeviceVM = new DeviceVM(dev, ctx); RunVoltageSweepCommand = AsyncCommand.Create(token => ScanPixelAndProcessData(token)); TheLJVScanSummaryVM = new LJVScanSummaryVM(ctx); TheLJVScanSummaryVM.TheLJVScanSummary.Device = ctx.Devices.Where(x => x.DeviceId == TheDeviceVM.TheDevice.DeviceId).First(); TheLJVScanSummaryVM.TheLJVScanSummary.TestCondition = TheScanSpec.TestCondition; string bts = ConfigurationManager.AppSettings.Get("BatchTestSystem"); if (bts == "BTS2") { TheImagingControl = InstrumentService.LJVScanCoordinator.TheImagingControl; } return this; })); }
// // OpenSelectedDevice // // Open the device that has be stored in the registry last time, the // device selection dialog has been used. Call this sub in the beginning // of an application to restore the last used video capture device. // internal static bool OpenSelectedDevice(TIS.Imaging.ICImagingControl icImagingControl1) { string ActiveErrorHandler = ""; bool OpenSelectedDevice_temp = false; try { // On Error GoTo err_OpenSelectedDevice ActiveErrorHandler = "err_OpenSelectedDevice"; string VideoSource = ""; icImagingControl1.Device = Microsoft.VisualBasic.Interaction.GetSetting(DeviceSettings.CurrentProcessName().ToString(), REG_SECTION, REG_KEY_VIDEO_SOURCE, ""); // Restore settings if (icImagingControl1.VideoNormAvailable) { icImagingControl1.VideoNorm = Microsoft.VisualBasic.Interaction.GetSetting(DeviceSettings.CurrentProcessName().ToString(), REG_SECTION, REG_KEY_VIDEO_NORM, ""); } if (icImagingControl1.InputChannelAvailable) { icImagingControl1.InputChannel = Microsoft.VisualBasic.Interaction.GetSetting(DeviceSettings.CurrentProcessName().ToString(), REG_SECTION, REG_KEY_INPUT_CHANNEL, ""); } icImagingControl1.VideoFormat = Microsoft.VisualBasic.Interaction.GetSetting(DeviceSettings.CurrentProcessName().ToString(), REG_SECTION, REG_KEY_VIDEO_FORMAT, ""); if (icImagingControl1.DeviceFrameRateAvailable) { icImagingControl1.DeviceFrameRate = float.Parse(Microsoft.VisualBasic.Interaction.GetSetting(DeviceSettings.CurrentProcessName().ToString(), REG_SECTION, REG_KEY_FRAME_RATE, "")); } // No error occured, and device is present. Indicate success OpenSelectedDevice_temp = true; return(OpenSelectedDevice_temp); } catch { if (ActiveErrorHandler == "err_OpenSelectedDevice") { return(OpenSelectedDevice_temp); } } return(OpenSelectedDevice_temp); }
private void Window_Loaded(object sender, RoutedEventArgs e) { // Create the interop host control. System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost(); //playing with camera device TIS.Imaging.ICImagingControl ic = new TIS.Imaging.ICImagingControl(); gcc.ICUsbCamControl = ic; ic.Width = 250; ic.Height = 250; ic.BackColor = System.Drawing.Color.Red; ic.BackgroundImage = Goniometr.Properties.Resources.nocam; //ic.ShowDeviceSettingsDialog(); //ic.LiveStart(); host.Child = ic; this.icgrid.Children.Add(host); }
private async Task <SingleDeviceScanVM> ManualSweepInitializeAsync() { return(await Task.Run(() => { InstrumentService.LJVScanCoordinator.PurgeSubscribers(); TheDeviceVM = new DeviceVM(); TheLJVScanSummaryVM = new LJVScanSummaryVM(); TheLJVScanSummaryVM.TheLJVScanSummary.Device = TheDeviceVM.TheDevice; RunVoltageSweepCommand = AsyncCommand.Create(token => ScanPixelAndProcessData(token)); ScanAllPixelsCommand = AsyncCommand.Create(token => ScanAllPixels(token)); //InstrumentService.LJVScanCoordinator.VoltageSweepFinished += InstrumentService_VoltageSweepFinished; SelectedPixel = theDeviceVM.PixelsDict["SiteA"]; string bts = ConfigurationManager.AppSettings.Get("BatchTestSystem"); if (bts == "BTS2") { TheImagingControl = InstrumentService.LJVScanCoordinator.TheImagingControl; } return this; })); }
private void SetupDFKCam() { var TheImagingControl = new TIS.Imaging.ICImagingControl(); // Let IC Imaging Control fill the complete form. TheImagingControl.Dock = DockStyle.Fill; // Allow scaling. TheImagingControl.LiveDisplayDefault = false; if (TheImagingControl.DeviceValid) { TheImagingControl.LiveStop(); } TheImagingControl.ShowDeviceSettingsDialog(); if (TheImagingControl.DeviceValid) { TheImagingControl.LiveStart(); } InstrumentService.LJVScanCoordinator.TheImagingControl = TheImagingControl; }
// // SaveSelectedDevice // // Saves the device settings from icImagingControl1 to the registry // internal static void SaveSelectedDevice(TIS.Imaging.ICImagingControl icImagingControl1) { string ActiveErrorHandler = ""; try { // On Error GoTo err_SaveSelectedDevice ActiveErrorHandler = "err_SaveSelectedDevice"; if (icImagingControl1.DeviceValid) { Microsoft.VisualBasic.Interaction.SaveSetting(DeviceSettings.CurrentProcessName().ToString(), REG_SECTION, REG_KEY_VIDEO_SOURCE, icImagingControl1.Device); if (icImagingControl1.InputChannelAvailable) { Microsoft.VisualBasic.Interaction.SaveSetting(DeviceSettings.CurrentProcessName().ToString(), REG_SECTION, REG_KEY_INPUT_CHANNEL, icImagingControl1.InputChannel); } if (icImagingControl1.VideoNormAvailable) { Microsoft.VisualBasic.Interaction.SaveSetting(DeviceSettings.CurrentProcessName().ToString(), REG_SECTION, REG_KEY_VIDEO_NORM, icImagingControl1.VideoNorm); } Microsoft.VisualBasic.Interaction.SaveSetting(DeviceSettings.CurrentProcessName().ToString(), REG_SECTION, REG_KEY_VIDEO_FORMAT, icImagingControl1.VideoFormat); if (icImagingControl1.DeviceFrameRateAvailable) { Microsoft.VisualBasic.Interaction.SaveSetting(DeviceSettings.CurrentProcessName().ToString(), REG_SECTION, REG_KEY_FRAME_RATE, icImagingControl1.DeviceFrameRate.ToString()); } } } catch { if (ActiveErrorHandler == "err_SaveSelectedDevice") { } } }
public static bool Open() { try { int cameraCount = 0; if ((CameraFlag & CameraFlag.Basler) == CameraFlag.Basler) { //#region basler相机遍历查询 //List<Basler.Pylon.ICameraInfo> g_allCameras = Basler.Pylon.CameraFinder.Enumerate(); //if (g_allCameras.Count > 0) //{ // for (int i = 0; i < g_allCameras.Count; i++) // { // Basler.Pylon.Camera g_camera = new Basler.Pylon.Camera(g_allCameras[i]); // if (true == g_camera.IsOpen) // g_camera.Close(); // g_camera.Open(); // string id = g_camera.Parameters[Basler.Pylon.PLCamera.DeviceUserID].GetValue(); // int id1; // if (int.TryParse(id, out id1)) // { // if (CameraDic.Keys.Contains(id1) == false) // { // CameraDic.Add(id1, new BaslerCamera(g_camera, id1)); // cameraCount++; // } // } // else // { // Util.Notify("相机ID未设置"); // } // } //} //#endregion } if ((CameraFlag & CameraFlag.Hikvision) == CameraFlag.Hikvision) { #region 海康相机遍历枚举 MyCamera.MV_CC_DEVICE_INFO_LIST m_pDeviceList = new MyCamera.MV_CC_DEVICE_INFO_LIST(); int nRet; nRet = CameraOperator.EnumDevices(MyCamera.MV_GIGE_DEVICE | MyCamera.MV_USB_DEVICE, ref m_pDeviceList); if (0 == nRet && m_pDeviceList.nDeviceNum > 0) { for (int i = 0; i < m_pDeviceList.nDeviceNum; i++) { MyCamera.MV_CC_DEVICE_INFO device = (MyCamera.MV_CC_DEVICE_INFO)Marshal.PtrToStructure(m_pDeviceList.pDeviceInfo[i], typeof(MyCamera.MV_CC_DEVICE_INFO)); if (device.nTLayerType == MyCamera.MV_GIGE_DEVICE) { IntPtr buffer = Marshal.UnsafeAddrOfPinnedArrayElement(device.SpecialInfo.stGigEInfo, 0); MyCamera.MV_GIGE_DEVICE_INFO gigeInfo = (MyCamera.MV_GIGE_DEVICE_INFO)Marshal.PtrToStructure(buffer, typeof(MyCamera.MV_GIGE_DEVICE_INFO)); int key; if (int.TryParse(gigeInfo.chUserDefinedName, out key)) { if (CameraDic.Keys.Contains(key) == false) { CameraOperator m_pOperator = new CameraOperator(); //打开设备 nRet = m_pOperator.Open(ref device); //Util.Notify("打开相机"); if (MyCamera.MV_OK == nRet) { CameraDic.Add(key, new HikvisionCamera(m_pOperator, key)); cameraCount++; } } } else { Util.Notify("相机ID未设置"); } } else if (device.nTLayerType == MyCamera.MV_USB_DEVICE) { IntPtr buffer = Marshal.UnsafeAddrOfPinnedArrayElement(device.SpecialInfo.stUsb3VInfo, 0); MyCamera.MV_USB3_DEVICE_INFO usbInfo = (MyCamera.MV_USB3_DEVICE_INFO)Marshal.PtrToStructure(buffer, typeof(MyCamera.MV_USB3_DEVICE_INFO)); int key; if (int.TryParse(usbInfo.chUserDefinedName, out key)) { if (CameraDic.Keys.Contains(key) == false) { CameraOperator m_pOperator = new CameraOperator(); //打开设备 nRet = m_pOperator.Open(ref device); if (MyCamera.MV_OK == nRet) { CameraDic.Add(key, new HikvisionCamera(m_pOperator, key)); cameraCount++; } } else { Util.Notify("相机ID未设置"); } } } } } #endregion } if ((CameraFlag & CameraFlag.Mindvision) == CameraFlag.Mindvision) { #region 迈徳威视相机遍历枚举 CameraSdkStatus status; tSdkCameraDevInfo[] tCameraDevInfoList; status = MvApi.CameraEnumerateDevice(out tCameraDevInfoList); if (status == CameraSdkStatus.CAMERA_STATUS_SUCCESS) { if (tCameraDevInfoList != null && tCameraDevInfoList.Count() > 0)//此时iCameraCounts返回了实际连接的相机个数。如果大于1,则初始化第一个相机 { for (int i = 0; i < tCameraDevInfoList.Count(); i++) { IntPtr m_Grabber; status = MvApi.CameraGrabber_Create(out m_Grabber, ref tCameraDevInfoList[i]); if (status == CameraSdkStatus.CAMERA_STATUS_SUCCESS) { CameraHandle m_hCamera = 0; // 句柄 MvApi.CameraGrabber_GetCameraHandle(m_Grabber, out m_hCamera); byte[] pName = new byte[255]; MvApi.CameraGetFriendlyName(m_hCamera, pName); string str = System.Text.Encoding.ASCII.GetString(pName).Substring(0, 1); int key = -1; if (int.TryParse(str, out key) && CameraDic.Keys.Contains(key) == false) { CameraDic.Add(key, new MindCamera(m_hCamera, m_Grabber, key)); cameraCount++; } //else //{ // Util.Notify("相机ID未设置"); //} } } } } #endregion } if ((CameraFlag & CameraFlag.Microvision) == CameraFlag.Microvision) { #region 维视图像相机相机遍历枚举 //个数枚举 MVGigE.MVInitLib(); int CamNum = 0; MVSTATUS r = MVGigE.MVGetNumOfCameras(out CamNum); for (int i = 0; i < CamNum; i++) { IntPtr m_hCam; byte index = (byte)i; r = MVGigE.MVOpenCamByIndex(index, out m_hCam); if (m_hCam != IntPtr.Zero) { MVCamInfo pCamInfo; MVGigE.MVGetCameraInfo(index, out pCamInfo); string str = pCamInfo.mUserDefinedName; int key = -1; if (int.TryParse(str, out key) && CameraDic.Keys.Contains(key) == false) { CameraDic.Add(key, new MicrovisionCamera(m_hCam, key)); cameraCount++; } else { Util.Notify("相机ID未设置"); } } } #endregion } if ((CameraFlag & CameraFlag.ICImaging) == CameraFlag.ICImaging) { #region 美精相机遍历查询 TIS.Imaging.ICImagingControl cameraFind = new TIS.Imaging.ICImagingControl(); foreach (TIS.Imaging.Device Item in cameraFind.Devices) { string cameraName = Item.Name; int index1 = cameraName.IndexOf("["); if (index1 > -1) { string dat = cameraName.Substring(index1); string dat1 = dat.Replace("[", "").Replace("]", ""); int id1; if (int.TryParse(dat1, out id1)) { if (CameraDic.Keys.Contains(id1) == false) { TIS.Imaging.ICImagingControl cameraTmp = new TIS.Imaging.ICImagingControl(); cameraTmp.Device = Item.Name; bool x = cameraTmp.DeviceValid; CameraDic.Add(id1, new ICImagingCamera(cameraTmp, id1)); cameraCount++; } } } } #endregion } if ((CameraFlag & CameraFlag.DirectShow) == CameraFlag.DirectShow) { #region DirectShow相机 当前只支持一个相机 HFramegrabber framegrabber = new HFramegrabber(); //HTuple Information = null; //HTuple ValueList = null; //HOperatorSet.InfoFramegrabber("DirectShow", "info_boards",out Information,out ValueList); framegrabber.OpenFramegrabber("DirectShow", 1, 1, 0, 0, 0, 0, "default", 8, DirectShowColorSpace, -1, "false", DirectShowCameraType, DirectShowIndex, 0, -1); CameraDic.Add(1, new DirectShowCamera(framegrabber, 1)); #endregion } if ((CameraFlag & CameraFlag.DaHeng) == CameraFlag.DaHeng) { //#region 大恒相机 //List<IGXDeviceInfo> listGXDeviceInfo = new List<IGXDeviceInfo>(); //IGXFactory IGXFactory1 = IGXFactory.GetInstance(); //IGXFactory1.Init(); //IGXFactory1.UpdateDeviceList(200, listGXDeviceInfo); //foreach (var item in listGXDeviceInfo) //{ // string name = item.GetUserID(); // int key; // if (int.TryParse(name, out key)) // { // if (CameraDic.Keys.Contains(key) == false) // { // IGXDevice IGXDevice1 = null; // IGXDevice1 = IGXFactory1.OpenDeviceBySN(item.GetSN(), GX_ACCESS_MODE.GX_ACCESS_EXCLUSIVE); // CameraDic.Add(key, new DHCamera(IGXFactory1, IGXDevice1)); // } // } //} //#endregion } if ((CameraFlag & CameraFlag.Gige) == CameraFlag.Gige) { //#region Gige相机遍历查询 HTuple Information = null; HTuple ValueList = null; HOperatorSet.InfoFramegrabber("GigEVision", "info_boards", out Information, out ValueList); for (int i = 0; i < ValueList.Length; i++) { string valueTmp = ValueList[i]; string name = GetGigeValue(valueTmp, "user_name:"); string device = GetGigeValue(valueTmp, "device:"); if (name != null && device != null) { int id1; if (int.TryParse(name, out id1)) { if (CameraDic.Keys.Contains(id1) == false) { HFramegrabber grabber = new HFramegrabber(); grabber.OpenFramegrabber("GigEVision", 0, 0, 0, 0, 0, 0, "default", -1, "default", -1, "false", "default", device, 0, -1); CameraDic.Add(id1, new GigeCamera(grabber, id1)); cameraCount++; } } } } //List<ICameraInfo> g_allCameras = CameraFinder.Enumerate(); //if (g_allCameras.Count > 0) //{ // for (int i = 0; i < g_allCameras.Count; i++) // { // Basler.Pylon.Camera g_camera = new Basler.Pylon.Camera(g_allCameras[i]); // if (true == g_camera.IsOpen) // g_camera.Close(); // g_camera.Open(); // string id = g_camera.Parameters[PLCamera.DeviceUserID].GetValue(); // int id1; // if (int.TryParse(id, out id1)) // { // if (CameraDic.Keys.Contains(id1) == false) // { // CameraDic.Add(id1, new BaslerCamera(g_camera, id1)); // cameraCount++; // } // } // else // { // Util.Notify("相机ID未设置"); // } // } //} //#endregion } //打开相机 foreach (var item in CameraDic.Values) { item.Open(); Thread.Sleep(30); } if (CameraInitFinishEvent != null) { CameraInitFinishEvent(null, null); } //else //{ // Util.Notify("无相机连接"); // return false; //} } catch (Exception ex) { Util.WriteLog(typeof(CameraManger), ex); Util.Notify("相机打开出现异常"); Close(); return(false); } return(true); }
public void setCameraControllers(TIS.Imaging.ICImagingControl mainIC, TIS.Imaging.ICImagingControl sideIC) { mainCamera = new CameraController(mainIC, "cam1Config.xml"); sideCamera = new CameraController(sideIC, "cam2Config.xml"); }
public SaveVideoForm(TIS.Imaging.ICImagingControl ic) { InitializeComponent(); m_ImagingControl = ic; }
public WriteAvi(TIS.Imaging.ICImagingControl IC) { InitializeComponent(); ICControl = IC; }