/// <summary> /// This method is invoked if changes occur in the HWndCtrl instance /// or the ROIController. In either case, the HALCON /// window needs to be updated/repainted. /// </summary> public void UpdateViewData(int val) { switch (val) { case ROIController.EVENT_CHANGED_ROI_SIGN: case ROIController.EVENT_DELETED_ACTROI: case ROIController.EVENT_DELETED_ALL_ROIS: case ROIController.EVENT_UPDATE_ROI: ModelContour = null; DetectionContour = null; bool genROI = roiController.defineModelROI(); ModelRegion = roiController.getModelRegion(); mAssistant.setModelROI(ModelRegion); CreateModelGraphics(); if (!genROI) { mView.repaint(); } break; case HWndCtrl.ERR_READING_IMG: MessageBox.Show("Problem occured while reading file! \n" + mView.exceptionText, "Matching assistant", MessageBoxButtons.OK, MessageBoxIcon.Information); break; default: break; } }
private void Act_Source(HImage image, HTuple angle, int i) { HObject temp = new HObject(); temp.GenEmptyObj(); HTuple dist_PZT_temp, pZTOkNg_temp; HTuple hv_Rows1, hv_Cols1, hv_Rows2, hv_Cols2; PZT_Detection_ext(Pzt_Region_Affine, image, out temp, new HTuple(mesureNumber), angle[i], new HTuple(mes_width), new HTuple(sigma), new HTuple(threshold), new HTuple(dist_STD), out dist_PZT_temp, out pZTOkNg_temp, out hv_Rows1, out hv_Cols1, out hv_Rows2, out hv_Cols2); if (pZTOkNg.Length == 0) { dist_PZT = dist_PZT_temp; pZTOkNg = pZTOkNg_temp; } else { dist_PZT = dist_PZT.TupleConcat(dist_PZT_temp); pZTOkNg = pZTOkNg.TupleConcat(pZTOkNg_temp); } if (temp != null && temp.IsInitialized()) { HXLD temp2 = new HXLD(temp); Arrow = Arrow.ConcatObj(temp2); temp.Dispose(); temp2.Dispose(); } }
////////////////////////////////////////////////////////////////////////////// // DisplayResults() - This method is used in/as a delegate. It is invoked // from the main GUI thread ////////////////////////////////////////////////////////////////////////////// public void DisplayResults() { int i; resultDataMutex.WaitOne(); // CriticalSect HTuple time = resultData.timeNeeded; // CriticalSect HTuple decodedDataStrings = resultData.decodedData; // CriticalSect HImage image = resultData.resultImg; // CriticalSect HTuple resultHandle = resultData.resultHandle; // CriticalSect HXLD symbolXLDs = resultData.symbolData; // CriticalSect containerIsFreeEvent.Set(); // CriticalSect resultDataMutex.ReleaseMutex(); // CriticalSect window.DispObj(image); window.DispObj(symbolXLDs); mainForm.procTimeLabel.Text = time.TupleString(".1f") + " ms"; mainForm.procTimeLabel.Refresh(); for (i = 0; i < resultHandle.Length; i++) { mainForm.imageDataLabel.Text = decodedDataStrings[i].S; mainForm.imageDataLabel.Refresh(); } image.Dispose(); symbolXLDs.Dispose(); }
/// <summary> /// Inspect beads in an image, as defined by the bead inspection model. /// Instance represents: Handle of the bead inspection model to be used. /// </summary> /// <param name="image">Image to apply bead inspection on.</param> /// <param name="rightContour">The detected right contour of the beads.</param> /// <param name="errorSegment">Detected error segments</param> /// <param name="errorType">Types of detected errors.</param> /// <returns>The detected left contour of the beads.</returns> public HXLD ApplyBeadInspectionModel( HImage image, out HXLD rightContour, out HXLD errorSegment, out HTuple errorType) { IntPtr proc = HalconAPI.PreCall(1983); this.Store(proc, 0); HalconAPI.Store(proc, 1, (HObjectBase)image); HalconAPI.InitOCT(proc, 1); HalconAPI.InitOCT(proc, 2); HalconAPI.InitOCT(proc, 3); HalconAPI.InitOCT(proc, 0); int err1 = HalconAPI.CallProcedure(proc); HXLD hxld; int err2 = HXLD.LoadNew(proc, 1, err1, out hxld); int err3 = HXLD.LoadNew(proc, 2, err2, out rightContour); int err4 = HXLD.LoadNew(proc, 3, err3, out errorSegment); int procResult = HTuple.LoadNew(proc, 0, err4, out errorType); HalconAPI.PostCall(proc, procResult); GC.KeepAlive((object)this); GC.KeepAlive((object)image); return(hxld); }
private void AffineTransModelContour(HShapeModel model, HRegion modelRegion) { if (model != null && modelRegion != null) { try { //获取金字塔第一层轮廓 HXLDCont modelContour = model.GetShapeModelContours(1); double num3, num4; modelRegion.AreaCenter(out num3, out num4); HHomMat2D matd = new HHomMat2D(); matd.VectorAngleToRigid(0.0, 0.0, 0.0, num3, num4, 0.0); HXLD affterAffineModelXLD = matd.AffineTransContourXld(modelContour); if (info.IsShowModelXLD) { Window.SetColor("green"); affterAffineModelXLD.DispXld(Window.Window); } } catch (Exception e) { WriteErrorLog("VisionTool", e.ToString()); } } }
/// <summary> /// Create a model to inspect beads or adhesive in images. /// Modified instance represents: Handle for using and accessing the bead inspection model. /// </summary> /// <param name="beadContour">XLD contour specifying the expected bead's shape and position.</param> /// <param name="targetThickness">Optimal bead thickness. Default: 50</param> /// <param name="thicknessTolerance">Tolerance of bead's thickness with respect to TargetThickness. Default: 15</param> /// <param name="positionTolerance">Tolerance of the bead's center position. Default: 15</param> /// <param name="polarity">The bead's polarity. Default: "light"</param> /// <param name="genParamName">Names of the generic parameters that can be adjusted for the bead inspection model. Default: []</param> /// <param name="genParamValue">Values of the generic parameters that can be adjusted for the bead inspection model. Default: []</param> public void CreateBeadInspectionModel( HXLD beadContour, int targetThickness, int thicknessTolerance, int positionTolerance, string polarity, string genParamName, int genParamValue) { this.Dispose(); IntPtr proc = HalconAPI.PreCall(1985); HalconAPI.Store(proc, 1, (HObjectBase)beadContour); HalconAPI.StoreI(proc, 0, targetThickness); HalconAPI.StoreI(proc, 1, thicknessTolerance); HalconAPI.StoreI(proc, 2, positionTolerance); HalconAPI.StoreS(proc, 3, polarity); HalconAPI.StoreS(proc, 4, genParamName); HalconAPI.StoreI(proc, 5, genParamValue); HalconAPI.InitOCT(proc, 0); int err = HalconAPI.CallProcedure(proc); int procResult = this.Load(proc, 0, err); HalconAPI.PostCall(proc, procResult); GC.KeepAlive((object)this); GC.KeepAlive((object)beadContour); }
/// <summary> /// A helper method to ensure that a HALCON HXLD is correctly disposed when assigned a new value. /// </summary> /// <param name="from">The source HXLD.</param> /// <param name="to">The destination HXLD.</param> /// <exception cref="ArgumentNullException">from must not be null.</exception> /// <exception cref="System.ArgumentNullException">from must not be null.</exception> public static void HCopy(this HXLD from, ref HXLD to) { try { if (@from == null) { throw new ArgumentNullException(nameof(from)); } if (to == null) { to = new HXLD(); } to.Dispose(); to = @from.CopyObj(1, -1); } finally { if (@from != null) { @from.Dispose(); } } }
/// <summary> /// Create a model to inspect beads or adhesive in images. /// Modified instance represents: Handle for using and accessing the bead inspection model. /// </summary> /// <param name="beadContour">XLD contour specifying the expected bead's shape and position.</param> /// <param name="targetThickness">Optimal bead thickness. Default: 50</param> /// <param name="thicknessTolerance">Tolerance of bead's thickness with respect to TargetThickness. Default: 15</param> /// <param name="positionTolerance">Tolerance of the bead's center position. Default: 15</param> /// <param name="polarity">The bead's polarity. Default: "light"</param> /// <param name="genParamName">Names of the generic parameters that can be adjusted for the bead inspection model. Default: []</param> /// <param name="genParamValue">Values of the generic parameters that can be adjusted for the bead inspection model. Default: []</param> public HBeadInspectionModel( HXLD beadContour, HTuple targetThickness, HTuple thicknessTolerance, HTuple positionTolerance, string polarity, HTuple genParamName, HTuple genParamValue) { IntPtr proc = HalconAPI.PreCall(1985); HalconAPI.Store(proc, 1, (HObjectBase)beadContour); HalconAPI.Store(proc, 0, targetThickness); HalconAPI.Store(proc, 1, thicknessTolerance); HalconAPI.Store(proc, 2, positionTolerance); HalconAPI.StoreS(proc, 3, polarity); HalconAPI.Store(proc, 4, genParamName); HalconAPI.Store(proc, 5, genParamValue); HalconAPI.InitOCT(proc, 0); int err = HalconAPI.CallProcedure(proc); HalconAPI.UnpinTuple(targetThickness); HalconAPI.UnpinTuple(thicknessTolerance); HalconAPI.UnpinTuple(positionTolerance); HalconAPI.UnpinTuple(genParamName); HalconAPI.UnpinTuple(genParamValue); int procResult = this.Load(proc, 0, err); HalconAPI.PostCall(proc, procResult); GC.KeepAlive((object)this); GC.KeepAlive((object)beadContour); }
public void UpdateViewData(int val) { switch (val) { case ViewROI.ROIController.EVENT_CHANGED_ROI_SIGN: case ViewROI.ROIController.EVENT_DELETED_ACTROI: case ViewROI.ROIController.EVENT_UPDATE_ROI: bool genROI = view1.roiController.defineModelROI(); ModelRoi = view1.roiController.getModelRegion(); if (ModelRoi == null) { return; } if (!TemplateParam.CreateShapeModel(CurrentImage, ModelRoi)) { Logger.PopError("模板创建失败!", true); return; } view1.ResetWindow(); view1.AddViewObject(CurrentImage); view1.SetDraw("blue", "margin"); view1.AddViewObject(ModelRoi); HXLD ModelContour = new HXLD(); TemplateParam.GetShapeModelContour(out ModelContour); view1.SetDraw("green", "margin"); view1.AddViewObject(ModelContour); view1.Repaint(); break; } }
private void Act_Engine(HImage image, HTuple Angle, int i) { PTZ_Detection_ProcedureCall.SetInputIconicParamObject("R", image); PTZ_Detection_ProcedureCall.SetInputIconicParamObject("RegionPZT_T", Pzt_Region_Affine); PTZ_Detection_ProcedureCall.SetInputCtrlParamTuple("mesureNumber", new HTuple(mesureNumber)); PTZ_Detection_ProcedureCall.SetInputCtrlParamTuple("mes_width", new HTuple(mes_width)); PTZ_Detection_ProcedureCall.SetInputCtrlParamTuple("threshold", new HTuple(threshold)); PTZ_Detection_ProcedureCall.SetInputCtrlParamTuple("dist_STD", new HTuple(dist_STD)); PTZ_Detection_ProcedureCall.SetInputCtrlParamTuple("dist_max", new HTuple(dist_max)); PTZ_Detection_ProcedureCall.SetInputCtrlParamTuple("angle", Angle[i]); PTZ_Detection_ProcedureCall.SetInputCtrlParamTuple("sigma", new HTuple(sigma)); PTZ_Detection_ProcedureCall.Execute(); if (pZTOkNg.Length == 0) { dist_PZT = (PTZ_Detection_ProcedureCall.GetOutputCtrlParamTuple("dist_PZT")); pZTOkNg = (PTZ_Detection_ProcedureCall.GetOutputCtrlParamTuple("pZTOkNg")); } else { dist_PZT = dist_PZT.TupleConcat(PTZ_Detection_ProcedureCall.GetOutputCtrlParamTuple("dist_PZT")); pZTOkNg = pZTOkNg.TupleConcat(PTZ_Detection_ProcedureCall.GetOutputCtrlParamTuple("pZTOkNg")); } HXLD temp = new HXLD(); temp = PTZ_Detection_ProcedureCall.GetOutputIconicParamXld("Arrow"); if (temp != null && temp.IsInitialized()) { Arrow = Arrow.ConcatObj(temp); temp.Dispose(); } }
////////////////////////////////////////////////////////////////////////////// // IPRun() - The thread function IPRun performs the image processing. // It waits for the grabbing thread to indicate a new image in the // image list. After calling the operator FindDataCode2D, the // result values are stored in the ResultContainer instance // resultData, which can be entered only after the previous result // values were displayed (containerIsFree-event). ////////////////////////////////////////////////////////////////////////////// public void IPRun() { // ------------------- INIT ---------------- HDataCode2D reader = new HDataCode2D("Data Matrix ECC 200", new HTuple(), new HTuple()); reader.SetDataCode2dParam("default_parameters", "enhanced_recognition"); // ----------- WAIT FOR EVENTS --------------- while (newImgEvent.WaitOne()) { newImgMutex.WaitOne(); // CriticalSect HImage image = (HImage)imgList[0]; // CriticalSect imgList.Remove(image); // CriticalSect newImgMutex.ReleaseMutex(); // CriticalSect HTuple t1 = HSystem.CountSeconds(); HTuple decodedDataStrings, resultHandle; HXLD symbolXLDs = reader.FindDataCode2d(image, new HTuple(), new HTuple(), out resultHandle, out decodedDataStrings); HTuple t2 = HSystem.CountSeconds(); containerIsFreeEvent.WaitOne(); resultDataMutex.WaitOne(); // CriticalSect resultData.timeNeeded = (1000 * (t2 - t1)); // CriticalSect resultData.decodedData = decodedDataStrings; // CriticalSect resultData.resultImg = image; // CriticalSect resultData.resultHandle = resultHandle; // CriticalSect resultData.symbolData = symbolXLDs; // CriticalSect containerIsFreeEvent.Reset(); // CriticalSect resultDataMutex.ReleaseMutex(); // CriticalSect newResultEvent.Set(); mainForm.Invoke(delegateDisplay); if (delegatedStopEvent.WaitOne(0, true)) { break; } } // -------- RESET/CLOSE ALL HANDLES --------- mainForm.threadAcq.Join(); mainForm.Invoke(delegateControlReset); reader.Dispose(); newResultEvent.Reset(); return; }
public void DisplayXLD(HXLD XLD) { if (XLD != null) { hXLD = XLD; HOperatorSet.SetSystem("flush_graphic", "false"); Window.ClearWindow(); HOperatorSet.SetSystem("flush_graphic", "true"); Window.DispXld(XLD); } }
/// <summary> /// Send an XLD object over a socket connection. /// Instance represents: Socket number. /// </summary> /// <param name="XLD">XLD object to be sent.</param> public void SendXld(HXLD XLD) { IntPtr proc = HalconAPI.PreCall(330); this.Store(proc, 0); HalconAPI.Store(proc, 1, (HObjectBase)XLD); int procResult = HalconAPI.CallProcedure(proc); HalconAPI.PostCall(proc, procResult); GC.KeepAlive((object)this); GC.KeepAlive((object)XLD); }
/// <summary> /// Receive an XLD object over a socket connection. /// Instance represents: Socket number. /// </summary> /// <returns>Received XLD object.</returns> public HXLD ReceiveXld() { IntPtr proc = HalconAPI.PreCall(329); this.Store(proc, 0); HalconAPI.InitOCT(proc, 1); int err = HalconAPI.CallProcedure(proc); HXLD hxld; int procResult = HXLD.LoadNew(proc, 1, err, out hxld); HalconAPI.PostCall(proc, procResult); GC.KeepAlive((object)this); return(hxld); }
public bool PZT_Detection_Act(HImage image, List <HHomMat2D> Mat2Ds, HTuple Angle) { try { if (!bIsInitial) { Initial_PZT_Detection(); } if (Pzt_Region == null || !Pzt_Region.IsInitialized()) { return(false); } if (Mat2Ds == null || Mat2Ds.Count() < 1) { return(false); } if (Arrow == null) { Arrow = new HXLD(); } if (Arrow != null && Arrow.IsInitialized()) { Arrow.Dispose(); } Arrow.GenEmptyObj(); dist_PZT = new HTuple(); pZTOkNg = new HTuple(); for (int i = 0; i < Mat2Ds.Count(); i++) { if (Pzt_Region_Affine != null && Pzt_Region_Affine.IsInitialized()) { Pzt_Region_Affine.Dispose(); } Pzt_Region_Affine = Mat2Ds[i].AffineTransRegion(Pzt_Region, "nearest_neighbor"); Act_Engine(image, Angle, i); //Act_Source(image, Angle, i); } } catch { return(false); } return(true); }
public void Close() { if (Pzt_Region_Affine != null && Pzt_Region_Affine.IsInitialized()) { Pzt_Region_Affine.Dispose(); } Pzt_Region_Affine = null; if (Arrow != null && Arrow.IsInitialized()) { Arrow.Dispose(); } Arrow = null; if (Pzt_Region != null && Pzt_Region.IsInitialized()) { Pzt_Region.Dispose(); } Pzt_Region = null; Pzt_ROIList.Clear(); Pzt_ROIList = null; }
public void SerializeCheck() { if (Pzt_Region_Affine != null && Pzt_Region_Affine.IsInitialized()) { Pzt_Region_Affine.Dispose(); } Pzt_Region_Affine = null; if (Arrow != null && Arrow.IsInitialized()) { Arrow.Dispose(); } Arrow = null; if (Pzt_Region != null && !Pzt_Region.IsInitialized()) { Pzt_Region = null; } using (Stream objectStream = new MemoryStream()) { System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); formatter.Serialize(objectStream, this); } }
/// <summary> /// 加载匹配模版 /// </summary> /// <param name="strModelPath"></param> /// <returns></returns> public bool LoadModel(string strModelPath) { try { if (!File.Exists(strModelPath)) { SetStatusText("未找到匹配模版,请自己创建模版"); return(false); } roiController.reset(); DetectionContour = null; mAssistant.reset(); if (mAssistant.loadShapeModel(strModelPath)) { //解析后轮廓数据 ModelContour = mAssistant.getLoadedModelContour(); //CreateModelGraphics(); mView.repaint(); } return(true); } catch { return(false); } }
/********************************************************************/ /********************************************************************/ private void loadImage(object sender, System.EventArgs e) { if(openFileDialog1.ShowDialog() == DialogResult.OK) { locked = true; DetectionContour = null; DispPyramidTrackBar.Enabled = false; DispPyramidTrackBar.Value = 1; DispPyramidUpDown.Enabled = false; DispPyramidUpDown.Value = 1; locked = false; FindAlwaysCheckBox.Checked = false; if(!mAssistant.setImage(openFileDialog1.FileName)) return; mView.resetAll(); if(mAssistant.onExternalModelID) ModelContour = mAssistant.getLoadedModelContour(); // to add ROI instances to the display as well if(tabControl.SelectedIndex != 0) { tabControl.SelectedIndex = 0; } else { changeWindowMode(1); CreateModelGraphics(); mView.repaint(); } } }
/********************************************************************/ /********************************************************************/ private void loadModelbutton_Click(object sender, System.EventArgs e) { string file; if(openFileDialog3.ShowDialog() == DialogResult.OK) { file = openFileDialog3.FileName; if(!file.EndsWith(".shm") || !file.EndsWith(".shm")) { UpdateMatching(MatchingAssistant.ERR_NO_VALID_FILE); return; } roiController.reset(); DetectionContour = null; mAssistant.reset(); FindAlwaysCheckBox.Checked = false; if(mAssistant.loadShapeModel(file)) { groupBoxCreateROI.Enabled = false; groupBoxCreateModel.Enabled = false; resetModelbutton.Enabled = true; saveModelbutton.Enabled = false; ModelContour = mAssistant.getLoadedModelContour(); if(tabControl.SelectedIndex != 0) { tabControl.SelectedIndex = 0; } else { changeWindowMode(1); CreateModelGraphics(); mView.repaint(); } } }/* if */ }
/// <summary> /// This method is invoked for any changes in the /// MatchingAssistant, concerning the model creation and /// the model finding. Also changes in the display mode /// (e.g., pyramid level) are mapped here. /// </summary> public void UpdateMatching(int val) { bool paint=false; switch(val) { case MatchingAssistant.UPDATE_XLD: ModelContour = mAssistant.getModelContour(); CreateModelGraphics(); paint = true; break; case MatchingAssistant.UPDATE_DISPLEVEL: CurrentImg = mAssistant.getDispImage(); ModelContour = mAssistant.getModelContour(); CreateModelGraphics(); paint = true; break; case MatchingAssistant.UPDATE_PYRAMID: DispPyramidTrackBar.Enabled = true; DispPyramidUpDown.Enabled = true; break; case MatchingAssistant.UPDATE_DETECTION_RESULT: DetectionContour = mAssistant.getDetectionResults(); FindModelGraphics(); paint = true; break; case MatchingAssistant.UPDATE_TESTVIEW: CurrentImg = mAssistant.getCurrTestImage(); FindModelGraphics(); break; case MatchingAssistant.ERR_WRITE_SHAPEMODEL: MessageBox.Show("Problem occured while writing into file \n" + mAssistant.exceptionText, "Matching Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case MatchingAssistant.ERR_READ_SHAPEMODEL: MessageBox.Show("Problem occured while reading from file \n" + mAssistant.exceptionText, "Matching Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case MatchingAssistant.ERR_NO_MODEL_DEFINED: MessageBox.Show("Please define a Model!", "Matching Wizard", MessageBoxButtons.OK, MessageBoxIcon.Information); paint = true; break; case MatchingAssistant.ERR_NO_IMAGE: MessageBox.Show("Please load an image", "Matching Wizard", MessageBoxButtons.OK, MessageBoxIcon.Information); break; case MatchingAssistant.ERR_NO_TESTIMAGE: MessageBox.Show("Please load a testimage", "Matching Wizard", MessageBoxButtons.OK, MessageBoxIcon.Information); paint = true; break; case MatchingAssistant.ERR_NO_VALID_FILE: MessageBox.Show("Selected file is not a HALCON ShapeModel file .shm", "Matching Wizard", MessageBoxButtons.OK, MessageBoxIcon.Information); break; case MatchingAssistant.ERR_READING_IMG: UpdateViewData(HWndCtrl.ERR_READING_IMG); break; default: break; } if(paint) mView.repaint(); }
/**********************************************************************/ /**********************************************************************/ /* Delegate Routines */ /**********************************************************************/ /**********************************************************************/ /// <summary> /// This method is invoked if changes occur in the HWndCtrl instance /// or the ROIController. In either case, the HALCON /// window needs to be updated/repainted. /// </summary> public void UpdateViewData(int val) { switch(val) { case ROIController.EVENT_CHANGED_ROI_SIGN: case ROIController.EVENT_DELETED_ACTROI: case ROIController.EVENT_DELETED_ALL_ROIS: case ROIController.EVENT_UPDATE_ROI: ModelContour = null; DetectionContour = null; bool genROI = roiController.defineModelROI(); ModelRegion = roiController.getModelRegion(); mAssistant.setModelROI(ModelRegion); CreateModelGraphics(); if(!genROI) mView.repaint(); break; case HWndCtrl.ERR_READING_IMG: MessageBox.Show("Problem occured while reading file! \n" + mView.exceptionText, "Matching assistant", MessageBoxButtons.OK, MessageBoxIcon.Information); break; default: break; } }
public void GetDetectionContour(out HXLD xldContour) { xldContour = m_MatchAssistant.getDetectionResults(); }
//显示匹配结果,画在界面上 public void PaintMatchResult(string color) { DetectionContour = mAssistant.getDetectionResults(); FindModelGraphics(color); mView.repaint(); }
/********************************************************************/ /********************************************************************/ private void displayTestImgButton_Click(object sender, System.EventArgs e) { string file; if(testImgListBox.Items.Count == 0) { mView.clearList(); changeWindowMode(2); mView.repaint(); UpdateMatching(MatchingAssistant.ERR_NO_TESTIMAGE); return; } file = (string)testImgListBox.SelectedItem; CurrentImg = mAssistant.getTestImage(file); changeWindowMode(2, CurrentImg); if(!FindAlwaysCheckBox.Checked) DetectionContour = null; FindModelGraphics(); if(ModelContour != null && FindAlwaysCheckBox.Checked) { mAssistant.applyFindModel(); } else { mView.repaint(); } }
/********************************************************************/ /********************************************************************/ private void deleteAllTestImgButton_Click(object sender, System.EventArgs e) { if(testImgListBox.Items.Count>0) { testImgListBox.Items.Clear(); mAssistant.removeTestImage(); DetectionContour = null; mView.clearList(); changeWindowMode(2); mView.repaint(); } }
/********************************************************************/ /********************************************************************/ private void delAllROIButton_Click(object sender, System.EventArgs e) { roiController.reset(); DetectionContour = null; mAssistant.reset(); DispPyramidTrackBar.Value = 1; DispPyramidTrackBar.Enabled = false; DispPyramidUpDown.Value = 1; DispPyramidUpDown.Enabled = false; }
/********************************************************************/ /********************************************************************/ private void resetModelbutton_Click(object sender, System.EventArgs e) { groupBoxCreateModel.Enabled = true; mAssistant.onExternalModelID = false; FindAlwaysCheckBox.Checked = false; resetModelbutton.Enabled = false; saveModelbutton.Enabled = true; DetectionContour = null; ModelContour = null; if(mAssistant.getDispImage()!=null) groupBoxCreateROI.Enabled = true; speedOptHandler.reset(); optInstance = speedOptHandler; UpdateStatisticsData(MatchingOpt.UPDATE_RECOG_UPDATE_VALS); UpdateStatisticsData(MatchingOpt.UPDATE_RECOG_OPTIMUM_VALS); UpdateStatisticsData(MatchingOpt.UPDATE_RECOG_STATISTICS_STATUS); inspectOptHandler.reset(); optInstance = inspectOptHandler; UpdateStatisticsData(MatchingOpt.UPDATE_INSP_STATISTICS); UpdateStatisticsData(MatchingOpt.UPDATE_INSP_RECOGRATE); //reset Model parameters mAssistant.resetCachedModelParams(); if(tabControl.SelectedIndex != 0) { tabControl.SelectedIndex = 0; } else { changeWindowMode(1); CreateModelGraphics(); mView.repaint(); } }
/********************************************************************/ /********************************************************************/ private void testImgListBox_SelectedIndexChanged(object sender, System.EventArgs e) { string file; if(testImgListBox.SelectedIndex < 0) { mView.clearList(); changeWindowMode(2); mView.repaint(); return; } DetectionContour = null; file = (string)testImgListBox.SelectedItem; mAssistant.setTestImage(file); changeWindowMode(2); if(FindAlwaysCheckBox.Checked && (mAssistant.onExternalModelID || (ModelRegion != null))) { mAssistant.applyFindModel(); } else { mView.repaint(); } }
public void GetDetectionContour(out HXLD xldContour) { Matching.GetDetectionContour(out xldContour); }
public bool GetShapeModelContour(out HXLD xldContour) { xldContour = m_MatchAssistant.getModelContour(); return(true); }
public bool GetShapeModelContour(out HXLD xldContour) { Matching.GetShapeModelContour(out xldContour); return(true); }
/// <summary> /// This method is invoked for any changes in the /// MatchingAssistant, concerning the model creation and /// the model finding. Also changes in the display mode /// (e.g., pyramid level) are mapped here. /// </summary> public void UpdateMatching(int val) { bool paint = false; switch (val) { case MatchingAssistant.UPDATE_XLD: ModelContour = mAssistant.getModelContour(); CreateModelGraphics(); paint = true; break; case MatchingAssistant.UPDATE_DISPLEVEL: CurrentImg = mAssistant.getDispImage(); ModelContour = mAssistant.getModelContour(); CreateModelGraphics(); paint = true; break; case MatchingAssistant.UPDATE_DETECTION_RESULT: //DetectionContour = mAssistant.getDetectionResults(); //FindModelGraphics(); //paint = true; break; case MatchingAssistant.UPDATE_TESTVIEW: CurrentImg = mAssistant.getCurrTestImage(); FindModelGraphics("green"); break; case MatchingAssistant.ERR_WRITE_SHAPEMODEL: MessageBox.Show("Problem occured while writing into file \n" + mAssistant.exceptionText, "Matching Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case MatchingAssistant.ERR_READ_SHAPEMODEL: MessageBox.Show("Problem occured while reading from file \n" + mAssistant.exceptionText, "Matching Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case MatchingAssistant.ERR_NO_MODEL_DEFINED: MessageBox.Show("Please define a Model!", "Matching Wizard", MessageBoxButtons.OK, MessageBoxIcon.Information); paint = true; break; case MatchingAssistant.ERR_NO_IMAGE: MessageBox.Show("Please load an image", "Matching Wizard", MessageBoxButtons.OK, MessageBoxIcon.Information); break; case MatchingAssistant.ERR_NO_TESTIMAGE: MessageBox.Show("Please load a testimage", "Matching Wizard", MessageBoxButtons.OK, MessageBoxIcon.Information); paint = true; break; case MatchingAssistant.ERR_NO_VALID_FILE: MessageBox.Show("Selected file is not a HALCON ShapeModel file .shm", "Matching Wizard", MessageBoxButtons.OK, MessageBoxIcon.Information); break; case MatchingAssistant.ERR_READING_IMG: UpdateViewData(HWndCtrl.ERR_READING_IMG); break; default: break; } if (paint) { mView.repaint(); } }