public bool MatchingModel(HObject In_Image, HTuple ModelID, out List <模板GVName> pmatest_result, out 模板GVName_halcon pmatest_result_halcon, out List <HObject> object_graphic_out, out string out_info) { HTuple hv_Rowzz, hv_Columnzz, hv_Anglezz, hv_Error; pmatest_result = new List <模板GVName>(); pmatest_result_halcon = new 模板GVName_halcon(); object_graphic_out = new List <HObject>(); out_info = ""; HHomMat2D Matrix = new HHomMat2D(); HTuple angleStart, angleExtent; double temp1 = double.Parse(txt_angleStart.Text.ToString()); HOperatorSet.TupleRad(temp1, out angleStart); double temp2 = double.Parse(txt_angleExtent.Text.ToString()); HOperatorSet.TupleRad(temp2, out angleExtent); if (In_Image == null) { MessageBox.Show("形状模板匹配: 请选择输入图像"); out_info = "形状模板匹配: 请选择输入图像"; return(false); } if (ModelID.Length == 0) { MessageBox.Show("形状模板匹配: 请选择输入模板"); out_info = "形状模板匹配: 请选择输入模板"; return(false); } try { HOperatorSet.BestMatchRot(In_Image, ModelID, (HTuple)Convert.ToDouble(txt_angleStart.Text.ToString()), (HTuple)Convert.ToDouble(txt_angleExtent.Text.ToString()), (HTuple)Convert.ToDouble(txt_greydis.Text.ToString()), this.model_subPixel.SelectedItem.ToString(), out hv_Rowzz, out hv_Columnzz, out hv_Anglezz, out hv_Error); } catch (Exception) { return(false); } double Error_number = Convert.ToDouble(this.txt_maxerror.Text.ToString()); if (hv_Error < Error_number) { // HOperatorSet.GetShapeModelContours(out ShapeModel, ModelID, 1); pmatest_result_halcon.点X = hv_Columnzz; pmatest_result_halcon.点Y = hv_Rowzz; pmatest_result_halcon.角度Angle = hv_Anglezz; // pmatest_result_halcon.分数Score = hv_Score; } for (int i = 0; i < hv_Rowzz.Length; i = i + 1) { if (hv_Error < Error_number) { HOperatorSet.VectorAngleToRigid(0, 0, 0, hv_Rowzz[i], hv_Columnzz[i], hv_Anglezz[i], out hv_MovementOfObject); // HOperatorSet.AffineTransContourXld(ShapeModel, out ho_ModelAtNewPosition, hv_MovementOfObject); // object_graphic_out.Add(ho_ModelAtNewPosition); pmatest_result.Add(new 模板GVName(i.ToString(), hv_Columnzz[i].D.ToString("F3"), hv_Rowzz[i].D.ToString("F3"), hv_Anglezz[i].D.ToString("F3"), "1")); } } return(true); }