Exemplo n.º 1
0
        public void cvScene()
        {
            string  text = JsonConvert.SerializeObject(scene);
            cvScene obj  = JsonConvert.DeserializeObject <cvScene>(text);

            Assert.IsTrue(obj.objects.Count == scene.objects.Count);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 载入一个json场景文件
        /// </summary>
        /// <param name="path"></param>
        public void LoadFile(string path)
        {
            path = path.Replace("\"", "");

            if (!File.Exists(path))
            {
                Debug.LogError("Observe.LoadFile():文件不存在. " + path);
                return;//如果文件不存在就直接返回
            }
            Debug.Log($"Observe.LoadFile():载入文件 {path}");
            Config.Inst.AddHistory(path);

            Clear();
            string  text  = File.ReadAllText(path);
            cvScene scene = JsonConvert.DeserializeObject <cvScene>(text);

            if (scene == null || scene.objects == null)
            {
                Debug.LogWarning("Observe.LoadFile():Json反序列化失败,场景对象为null!");
                return;
            }
            for (int i = 0; i < scene.objects.Count; i++)
            {
                this.AddCvObj(scene.objects[i]);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 载入一个场景
 /// </summary>
 /// <param name="scene"></param>
 public void LoadScene(cvScene scene)
 {
     if (scene == null || scene.objects == null)
     {
         Debug.LogWarning("Observe.LoadFile():Json反序列化失败,场景对象为null!");
         return;
     }
     Clear();
     for (int i = 0; i < scene.objects.Count; i++)
     {
         this.AddCvObj(scene.objects[i]);
     }
 }
Exemplo n.º 4
0
        public void loadFile()
        {
            string path = @"D:\GC3000\IDE0OVMzVxEAJgAm\images\calib\Camera-F3DSC01.json";

            if (File.Exists(path))
            {
                string  text = File.ReadAllText(path);
                cvScene obj  = JsonConvert.DeserializeObject <cvScene>(text);

                Assert.IsTrue(obj.objects.Count > -1);
            }
            else
            {
                Debug.Log("loadFile():文件不存在,未执行测试.");
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 从网络更新场景
        /// </summary>
        public async void UpdateSceneWithNet()
        {
            try
            {
                var msg = await url.GetStringAsync();

                if (!this.isActiveAndEnabled)//使用这个在await之后进行判断
                {
                    return;
                }
                cvScene scene = JsonConvert.DeserializeObject <cvScene>(msg);
                if (curScene == null || curScene.stamp != scene.stamp)
                {
                    curScene = scene;
                    LoadScene(scene);
                }
            }
            catch (System.Exception)
            {
                //这里是通信失败
            }
        }