private void Form1_Load(object sender, EventArgs e) { HImage img = new HImage(@"D:\12.bmp"); hWndCrtl.AddIconicVar(img); hWndCrtl.AddText("测试", 20, 20); hWndCrtl.Repaint(); }
public void ShowResult(HWndCtrl hWndCtrl, List <ToolBase> runToolList, bool runningResultFlag) { if (runningResultFlag == false) { hWndCtrl.ShowNg(); if (IniStatus.Instance.SaveNgImage == 1) { DateTime dt = DateTime.Now; string timeNow = dt.ToString("yyyy_MM_dd_HH_mm_ss_fff"); string project = Path.GetFileNameWithoutExtension(UserSetting.Instance.ProjectPath); string NGImagePath = "D:\\data\\" + project + "\\NgImage\\" + "\\工具组" + settingIndex + "\\"; SaveImage(NGImagePath + timeNow + ".png", runToolList[0].ImageTestOut); } } else { hWndCtrl.ShowOK(); if (IniStatus.Instance.SaveOkImage == 1) { DateTime dt = DateTime.Now; string timeNow = dt.ToString("yyyy_MM_dd_HH_mm_ss_fff"); string project = Path.GetFileNameWithoutExtension(UserSetting.Instance.ProjectPath); string NGImagePath = "D:\\data\\" + project + "\\OKImage\\" + "\\工具组" + settingIndex + "\\"; SaveImage(NGImagePath + timeNow + ".png", runToolList[0].ImageTestOut); } } HTuple showStart1; HOperatorSet.CountSeconds(out showStart1); hWndCtrl.ChangeGraphicSettings(Mode.LINESTYLE, new HTuple()); hWndCtrl.AddIconicVar(runToolList[0].ImageTestOut); foreach (ToolBase item in runToolList) { try { item.ShowResult(hWndCtrl); if (item.Message != null && item.Message.Length > 0) { Util.Notify(string.Format("工具{0}_{1}", item.Name, item.Message)); } } catch (Exception ex) { Util.Notify(string.Format("工具{0}显示异常", item.Name)); //("工具{0}显示异常{1}", item.Name,e.message)); Util.WriteLog(this.GetType(), ex); } } hWndCtrl.Repaint(); }
private void DisplayCalib(HImage image) { if (ho_Caltab == null) { ho_Caltab = new HObject(); ho_Caltab.GenEmptyObj(); } ho_Caltab.Dispose(); HOperatorSet.GetCalibDataObservContours(out ho_Caltab, CalibDataID, "caltab", 0, 0, index); HTuple hv_Row, hv_Column, hv_Index, hv_Pose; HOperatorSet.GetCalibDataObservPoints(CalibDataID, 0, 0, index, out hv_Row, out hv_Column, out hv_Index, out hv_Pose); if (ho_Cross == null) { ho_Cross = new HObject(); ho_Cross.GenEmptyObj(); } ho_Cross.Dispose(); HOperatorSet.GenCrossContourXld(out ho_Cross, hv_Row, hv_Column, 30, 0.785398); mView.ClearList(); if (image != null && image.IsInitialized()) { mView.AddIconicVar(image); } if (ho_Caltab != null && ho_Caltab.IsInitialized()) { mView.ChangeGraphicSettings(Mode.COLOR, "green"); mView.ChangeGraphicSettings(Mode.LINEWIDTH, 3); mView.AddIconicVar(ho_Caltab); } if (ho_Cross != null && ho_Cross.IsInitialized()) { mView.ChangeGraphicSettings(Mode.COLOR, "blue"); mView.ChangeGraphicSettings(Mode.LINEWIDTH, 2); mView.AddIconicVar(ho_Cross); } mView.AddText(index.ToString(), 100, 100, 80, "green"); mView.Repaint(); }
private void Camera_ImageEvent(object sender, ImageEventArgs e) { if (e.Command == Command.ExtTrigger) { //硬件触发 TrigerRun(e, 1000, e.CameraIndex, true); } else if (e.Command == Command.Grab) { //软触发 TriggerRun(e, e.SettingIndex, 1000); } else { //#if DEBUG // Util.Notify(string.Format("显示图像线程ID:{0}", Thread.CurrentThread.ManagedThreadId)); //#endif //测试模式---如果换了工具组,就将上个正在测试的工具关闭。---很重要。 if (autoUnit.IsTestMode) { if (e.CameraIndex != autoUnit.toolShowUnit1.GetCameraIndex(autoUnit.CurrentSettingIndex)) { if (CameraManger.CameraDic.ContainsKey(e.CameraIndex)) { if (CameraManger.CameraDic[e.CameraIndex].IsContinuousShot) { CameraManger.CameraDic[e.CameraIndex].ContinuousShotStop(); } } return; } TrigerRun(e, 1, autoUnit.CurrentSettingIndex, false); } //在线测试模式 else ///连续采集图像,直接显示 { if (ImageRunFinishSignal.WaitOne(1)) { autoUnit.Invoke(new Action(() => { //显示图像 HWndCtrl hWndCtrl = cameraShowUnit.HWndUnit.HWndCtrl; HTuple t0; HOperatorSet.CountSeconds(out t0); hWndCtrl.ClearList(); hWndCtrl.AddIconicVar(e.CameraImage); hWndCtrl.Repaint(); //Application.DoEvents();//不要使用liscence,否则不对就会造成卡顿严重//高帧率下显示会卡顿 string cameraInfo = CameraManger.CameraDic[e.CameraIndex].GetCameraAcqInfo(); cameraShowUnit.HWndUnit.CameraMessage = string.Format("相机{0} {1}", e.CameraIndex, cameraInfo); ImageRunFinishSignal.Set(); e.Dispose(); })); } else { e.Dispose(); //if (this.InvokeRequired) //{ // Thread.Sleep(10); //} } }//连续采集图像,直接显示 } }