public void ReadParam(string fileName) { NumLevels = Convert.ToInt32(SetParam.ReadParam(fileName, "NumLevels", NumLevels.ToString())); mStartingAngle = Convert.ToSingle(SetParam.ReadParam(fileName, "AngleStart", mStartingAngle.ToString())); mAngleExtent = Convert.ToSingle(SetParam.ReadParam(fileName, "AngleExtent", mAngleExtent.ToString())); AngleStep = Convert.ToSingle(SetParam.ReadParam(fileName, "AngleStep", AngleStep.ToString())); Metric = Convert.ToString(SetParam.ReadParam(fileName, "Metric", Metric.ToString())); MinScore = Convert.ToSingle(SetParam.ReadParam(fileName, "MinScore", MinScore.ToString())); NumMatches = Convert.ToInt32(SetParam.ReadParam(fileName, "NumMatches", NumMatches.ToString())); mMaxOverlap = Convert.ToSingle(SetParam.ReadParam(fileName, "MaxOverlap", mMaxOverlap.ToString())); SubPixel = Convert.ToString(SetParam.ReadParam(fileName, "SubPixel", SubPixel.ToString())); bool flag1 = Convert.ToBoolean(SetParam.ReadParam(fileName, "AutoNumLevels", IsAuto(AUTO_NUM_LEVEL).ToString())); if (flag1) { SetAuto(AUTO_NUM_LEVEL); } else { RemoveAuto(AUTO_NUM_LEVEL); } flag1 = Convert.ToBoolean(SetParam.ReadParam(fileName, "AutoNumLevels", IsAuto(AUTO_ANGLE_STEP).ToString())); if (flag1) { SetAuto(AUTO_ANGLE_STEP); } else { RemoveAuto(AUTO_ANGLE_STEP); } }
public void ReadHalconObj(string fileName) { if (File.Exists(fileName + ".ncm")) { if (nCCModel != null) { nCCModel.Dispose(); } nCCModel = new HNCCModel(fileName + ".ncm"); } if (File.Exists(fileName + "se.tif")) { if (SearchRegion != null) { SearchRegion.Dispose(); } SearchRegion = new HRegion(); SearchRegion.ReadRegion(fileName + "se.tif"); } if (File.Exists(fileName + "md.tif")) { if (ModelRegion != null) { ModelRegion.Dispose(); } ModelRegion = new HRegion(); ModelRegion.ReadRegion(fileName + "md.tif"); } if (File.Exists(fileName + ".bmp")) { if (ModelImg != null) { ModelImg.Dispose(); } ModelImg = new HImage(fileName + ".bmp"); } ModelImgRow = Convert.ToSingle(SetParam.ReadParam(fileName, "ModelImgRow", ModelImgRow.ToString())); ModelImgCol = Convert.ToSingle(SetParam.ReadParam(fileName, "ModelImgCol", ModelImgCol.ToString())); ModelimgAng = Convert.ToSingle(SetParam.ReadParam(fileName, "ModelimgAng", ModelimgAng.ToString())); TimeOutEnable = Convert.ToBoolean(SetParam.ReadParam(fileName, "TimeOutEnable", TimeOutEnable.ToString())); OutTime = Convert.ToInt32(SetParam.ReadParam(fileName, "OutTime", OutTime.ToString())); nCCParam.ReadParam(fileName + "par.dat"); SetOutTime(TimeOutEnable ? 0 : OutTime); }
public void WriteParam(string fileName) { SetParam.WriteParam(fileName, "NumLevels", NumLevels.ToString()); SetParam.WriteParam(fileName, "AngleStart", mStartingAngle.ToString()); SetParam.WriteParam(fileName, "AngleExtent", mAngleExtent.ToString()); SetParam.WriteParam(fileName, "AngleStep", AngleStep.ToString()); SetParam.WriteParam(fileName, "Metric", Metric.ToString()); SetParam.WriteParam(fileName, "MinScore", MinScore.ToString()); SetParam.WriteParam(fileName, "NumMatches", NumMatches.ToString()); SetParam.WriteParam(fileName, "MaxOverlap", mMaxOverlap.ToString()); SetParam.WriteParam(fileName, "SubPixel", SubPixel.ToString()); SetParam.WriteParam(fileName, "AutoNumLevels", IsAuto(AUTO_NUM_LEVEL).ToString()); SetParam.WriteParam(fileName, "AutoAngleStep", IsAuto(AUTO_ANGLE_STEP).ToString()); }
public void WriteHalconObj(string fileName) { string path = Path.GetDirectoryName(fileName); if (path == null || path == "\\") { return; } if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (ModelImg != null && ModelImg.IsInitialized()) { ModelImg.WriteImage("bmp", 0, fileName + ".bmp"); } if (nCCModel != null && nCCModel.IsInitialized()) { HOperatorSet.WriteNccModel(nCCModel, fileName + ".ncm"); } if (SearchRegion != null && SearchRegion.IsInitialized()) { HOperatorSet.WriteRegion(SearchRegion, fileName + "se.tif"); } if (ModelRegion != null && ModelRegion.IsInitialized()) { HOperatorSet.WriteRegion(ModelRegion, fileName + "md.tif"); } SetParam.WriteParam(fileName + "par.dat", "ModelImgRow", ModelImgRow.ToString()); SetParam.WriteParam(fileName + "par.dat", "ModelImgCol", ModelImgCol.ToString()); SetParam.WriteParam(fileName + "par.dat", "ModelimgAng", ModelimgAng.ToString()); SetParam.WriteParam(fileName + "par.dat", "TimeOutEnable", TimeOutEnable.ToString()); SetParam.WriteParam(fileName + "par.dat", "OutTime", OutTime.ToString()); nCCParam.WriteParam(fileName + "par.dat"); }