public void ShowResult(HWndCtrl viewCtrl) { //搜索范围 viewCtrl.ChangeGraphicSettings(Mode.DRAWMODE, "margin"); if (SearchRegion != null && SearchRegion.IsInitialized()) { viewCtrl.ChangeGraphicSettings(Mode.COLOR, "blue"); viewCtrl.ChangeGraphicSettings(Mode.LINEWIDTH, 2); viewCtrl.AddIconicVar(SearchRegion); } //确保已有模板 if (createShapeModel.hShapeModel == null || !createShapeModel.hShapeModel.IsInitialized() || createShapeModel.createNewModelID) { if (!createShapeModel.CreateShapeModelAct(refImage)) { return; } } //获取仿射变换后的轮廓 HXLDCont modelXldCont = createShapeModel.ModelXLDCont; if (row.Length < 1) { return; } GenDetectionXLDResults(modelXldCont); if (resultXLDCont != null && resultXLDCont.IsInitialized()) { viewCtrl.ChangeGraphicSettings(Mode.COLOR, "blue"); viewCtrl.ChangeGraphicSettings(Mode.LINEWIDTH, 2); viewCtrl.AddIconicVar(resultXLDCont); } }
public void Show(HWndCtrl viewCtrl) { if (ResultRegion != null && ResultRegion.IsInitialized()) { viewCtrl.ChangeGraphicSettings(Mode.COLOR, "green"); viewCtrl.ChangeGraphicSettings(Mode.LINEWIDTH, 3); viewCtrl.AddIconicVar(ResultRegion); } if (FangDai_Region_Affines != null && FangDai_Region_Affines.IsInitialized()) { viewCtrl.ChangeGraphicSettings(Mode.COLOR, "blue"); viewCtrl.ChangeGraphicSettings(Mode.LINEWIDTH, 2); viewCtrl.AddIconicVar(FangDai_Region_Affines); } }
public void ShowImage(HWndCtrl viewCtrl) { if (ImageTestOut != null && ImageTestOut.IsInitialized()) { viewCtrl.AddIconicVar(ImageTestOut); } }
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 viewCtrl) { viewCtrl.ChangeGraphicSettings(Mode.DRAWMODE, "margin"); if (SearchRegion != null && SearchRegion.IsInitialized()) { viewCtrl.ChangeGraphicSettings(Mode.COLOR, "blue"); viewCtrl.ChangeGraphicSettings(Mode.LINEWIDTH, 2); viewCtrl.AddIconicVar(SearchRegion); } if (scan_regions != null && scan_regions.IsInitialized()) { viewCtrl.ChangeGraphicSettings(Mode.COLOR, "cyan"); viewCtrl.ChangeGraphicSettings(Mode.LINEWIDTH, 2); viewCtrl.AddIconicVar(scan_regions); } if (createShapeModel.hShapeModel == null || !createShapeModel.hShapeModel.IsInitialized() || createShapeModel.createNewModelID) { if (!createShapeModel.CreateShapeModelAct(refImage)) { return; } } HXLDCont modelXldCont = createShapeModel.ModelXLDCont; if (row.Length < 1) { return; } GenDetectionXLDResults(modelXldCont); if (resultXLDCont != null && resultXLDCont.IsInitialized()) { viewCtrl.ChangeGraphicSettings(Mode.COLOR, "blue"); viewCtrl.ChangeGraphicSettings(Mode.LINEWIDTH, 2); viewCtrl.AddIconicVar(resultXLDCont); } //GenDetectionRegionResult(createShapeModel.modelRegion); //if (resultRegion != null && resultRegion.IsInitialized()) //{ // viewCtrl.ChangeGraphicSettings(Mode.COLOR, "green"); // viewCtrl.ChangeGraphicSettings(Mode.LINEWIDTH, 2); // viewCtrl.AddIconicVar(resultRegion); //} }
public void Show(HWndCtrl viewCtrl) { if (Arrow != null && Arrow.IsInitialized()) { viewCtrl.ChangeGraphicSettings(Mode.COLOR, "green"); viewCtrl.ChangeGraphicSettings(Mode.DRAWMODE, "margin"); viewCtrl.ChangeGraphicSettings(Mode.LINEWIDTH, 2); viewCtrl.AddIconicVar(Arrow); } }
public void ShowShapeModel(HWndCtrl viewCtrl) { if (modelRegion == null || !modelRegion.IsInitialized()) { return; } if (ModelXLDCont == null || !ModelXLDCont.IsInitialized()) { return; } viewCtrl.ChangeGraphicSettings(Mode.DRAWMODE, "margin"); if (modelRegion != null && modelRegion.IsInitialized()) { viewCtrl.ChangeGraphicSettings(Mode.COLOR, "blue"); viewCtrl.ChangeGraphicSettings(Mode.LINEWIDTH, 2); viewCtrl.AddIconicVar(modelRegion); } if (modelXLDContAffine == null) { modelXLDContAffine = new HXLDCont(); } if (modelXLDContAffine != null && modelXLDContAffine.IsInitialized()) { modelXLDContAffine.Dispose(); } if (refCoordinates == null || refCoordinates.Length != 3) { return; } HHomMat2D homMat2D = new HHomMat2D(); homMat2D.VectorAngleToRigid(0.0, 0.0, 0.0, refCoordinates[0].D, refCoordinates[1].D, refCoordinates[2].D); modelXLDContAffine = homMat2D.AffineTransContourXld(ModelXLDCont); if (modelXLDContAffine != null && modelXLDContAffine.IsInitialized()) { viewCtrl.ChangeGraphicSettings(Mode.COLOR, "red"); viewCtrl.ChangeGraphicSettings(Mode.LINEWIDTH, 1); viewCtrl.AddIconicVar(modelXLDContAffine); } }
public void ShowGrabPoint(HWndCtrl viewCtrl) { if (GrabRowTarget != null && GrabRowTarget.Length > 0) { GrabXld.GenCrossContourXld(GrabRowTarget, GrabColTarget, 30, 0); } if (GrabXld != null && GrabXld.IsInitialized()) { viewCtrl.ChangeGraphicSettings(Mode.COLOR, "blue"); viewCtrl.ChangeGraphicSettings(Mode.LINEWIDTH, 2); viewCtrl.AddIconicVar(GrabXld); } }
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 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); //} } }//连续采集图像,直接显示 } }
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(); }