예제 #1
0
        /// <summary>
        /// 保存参数到本地图片
        /// </summary>
        public void SaveParamToLocalFile()
        {
            if (VisionFrame == null)
            {
                VisionFrame = VisionFrameFactory.CreateInstance(EVisionFrameType);
            }

            //保存输入参数
            if (VisionFrame.IsEnableInput == true)
            {
                if (string.IsNullOrEmpty(InputParamFile))
                {
                    InputParamFile = "default.json";
                }

                //若文件不存在,则创建默认配置到此文件;若文件存在,则从配置文件中加载配置;
                string filePath = $"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}/VisionPlatform/Scene/{EVisionFrameType}/{Name}/InputParam/{InputParamFile}";
                JsonSerialization.SerializeObjectToFile(VisionFrame.Inputs, filePath);
            }

            //保存输出参数
            if (VisionFrame.IsEnableOutput == true)
            {
                if (string.IsNullOrEmpty(OutputParamFile))
                {
                    OutputParamFile = "default.json";
                }

                //若文件不存在,则创建默认配置到此文件;若文件存在,则从配置文件中加载配置;
                string filePath = $"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}/VisionPlatform/Scene/{EVisionFrameType}/{Name}/OutputParam/{OutputParamFile}";
                JsonSerialization.SerializeObjectToFile(VisionFrame.Outputs, filePath);
            }
        }
예제 #2
0
        public void Init()
        {
            try
            {
                //还原视觉框架
                if (EVisionFrameType == EVisionFrameType.Unknown)
                {
                    throw new ArgumentException("VisionFrameName invalid");
                }

                if (VisionFrame == null)
                {
                    VisionFrame = VisionFrameFactory.CreateInstance(EVisionFrameType);
                }

                //还原视觉算子
                if (string.IsNullOrEmpty(VisionOperaFile))
                {
                    throw new ArgumentException("VisionOperaFile cannot be null");
                }

                string visionOperaFilePath = $"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}/VisionPlatform/Scene/{EVisionFrameType}/{Name}/VisionOperation/{VisionOperaFile}";
                VisionFrame.Init(visionOperaFilePath);

                //还原输入参数
                RecoverInputFile();

                //还原输出参数
                RecoverOutputFile();

                //还原相机
                if (VisionFrame.IsEnableCamera)
                {
                    if (!string.IsNullOrEmpty(CameraSerial))
                    {
                        //若相机无效,则不报异常
                        try
                        {
                            SetCamera(CameraSerial);
                        }
                        catch (InvalidOperationException)
                        {
                            //若打开相机失败,不抛异常
                        }

                        ////配置相机参数
                        //if (CameraFactory.DefaultCameraSdkType != ECameraSdkType.VirtualCamera)
                        //{
                        //    SetCameraConfigFile(CameraConfigFile);
                        //}

                        ////配置标定信息
                        //SetCameraCalibrationFile(CalibrationFile);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #3
0
 /// <summary>
 /// 创建Scene新实例
 /// </summary>
 /// <param name="sceneName">场景名</param>
 /// <param name="eVisionFrame">视觉框架枚举</param>
 public Scene(string sceneName, EVisionFrameType eVisionFrame) : this(sceneName)
 {
     EVisionFrameType = eVisionFrame;
     VisionFrame      = VisionFrameFactory.CreateInstance(eVisionFrame);
 }