Пример #1
0
        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");
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }