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 (shapeModel != null && shapeModel.IsInitialized()) { HOperatorSet.WriteShapeModel(shapeModel, fileName + ".shm"); } if (SearchRegion != null && SearchRegion.IsInitialized()) { HOperatorSet.WriteRegion(SearchRegion, fileName + "se.tif"); } if (ModelRegion != null && ModelRegion.IsInitialized()) { HOperatorSet.WriteRegion(ModelRegion, fileName + "md.tif"); } IniFileOperate.INIWriteValue(fileName + "par.dat", "参数", "ModelImgRow", ModelImgRow.ToString()); IniFileOperate.INIWriteValue(fileName + "par.dat", "参数", "ModelImgCol", ModelImgCol.ToString()); IniFileOperate.INIWriteValue(fileName + "par.dat", "参数", "ModelimgAng", ModelimgAng.ToString()); IniFileOperate.INIWriteValue(fileName + "par.dat", "参数", "TimeOutEnable", TimeOutEnable.ToString()); IniFileOperate.INIWriteValue(fileName + "par.dat", "参数", "OutTime", OutTime.ToString()); shapeParam.WriteParam(fileName + "par.dat"); }
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 ReadHalconObj(string fileName) { if (File.Exists(fileName + ".ncm")) { if (shapeModel != null) { shapeModel.Dispose(); } shapeModel = new HShapeModel(fileName + ".shm"); } 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(IniFileOperate.INIGetStringValue(fileName, "参数", "ModelImgRow", ModelImgRow.ToString())); ModelImgCol = Convert.ToSingle(IniFileOperate.INIGetStringValue(fileName, "参数", "ModelImgCol", ModelImgCol.ToString())); ModelimgAng = Convert.ToSingle(IniFileOperate.INIGetStringValue(fileName, "参数", "ModelimgAng", ModelimgAng.ToString())); TimeOutEnable = Convert.ToBoolean(IniFileOperate.INIGetStringValue(fileName, "参数", "TimeOutEnable", TimeOutEnable.ToString())); OutTime = Convert.ToInt32(IniFileOperate.INIGetStringValue(fileName, "参数", "OutTime", OutTime.ToString())); shapeParam.ReadParam(fileName + "par.dat"); SetOutTime(TimeOutEnable ? 0 : OutTime); }