예제 #1
0
    public void processCalibrationMatrix(string calibration)
    {
        string[] tokens = calibration.Split(MessageSeparators.L1);
        foreach (string s in tokens)
        {
            if (s == "")
            {
                break;
            }
            string[] chunks = s.Split(';');
            string   id     = chunks[0];

            Matrix4x4 mat = new Matrix4x4(new Vector4(float.Parse(chunks[1]), float.Parse(chunks[5]), float.Parse(chunks[9]), float.Parse(chunks[13])),
                                          new Vector4(float.Parse(chunks[2]), float.Parse(chunks[6]), float.Parse(chunks[10]), float.Parse(chunks[14])),
                                          new Vector4(float.Parse(chunks[3]), float.Parse(chunks[7]), float.Parse(chunks[11]), float.Parse(chunks[15])),
                                          new Vector4(float.Parse(chunks[4]), float.Parse(chunks[8]), float.Parse(chunks[12]), float.Parse(chunks[16])));

            GameObject cloudobj = new GameObject(id);
            cloudobj.transform.localPosition = new Vector3(mat[0, 3], mat[1, 3], mat[2, 3]);
            cloudobj.transform.localRotation = mat.rotation;
            cloudobj.transform.localScale    = new Vector3(-1, 1, 1);
            cloudobj.AddComponent <PointCloudDepth>();

            PointCloudDepth cloud = cloudobj.GetComponent <PointCloudDepth>();
            cloud.Init();
            _clouds.Add(id, cloud);
            _cloudGameObjects.Add(id, cloudobj);
        }
    }
예제 #2
0
    public void processCalibration(string calibration)
    {
        string[] tokens = calibration.Split(MessageSeparators.L1);
        foreach (string s in tokens)
        {
            if (s == "")
            {
                break;
            }
            string[] chunks = s.Split(';');
            string   id     = chunks[0];
            float    px     = float.Parse(chunks[1]);
            float    py     = float.Parse(chunks[2]);
            float    pz     = float.Parse(chunks[3]);
            float    rx     = float.Parse(chunks[4]);
            float    ry     = float.Parse(chunks[5]);
            float    rz     = float.Parse(chunks[6]);
            float    rw     = float.Parse(chunks[7]);

            GameObject cloudobj = new GameObject(id);
            cloudobj.transform.localPosition = new Vector3(px, py, pz);
            cloudobj.transform.localRotation = new Quaternion(rx, ry, rz, rw);
            cloudobj.transform.localScale    = new Vector3(-1, 1, 1);
            cloudobj.AddComponent <PointCloudDepth>();
            PointCloudDepth cloud = cloudobj.GetComponent <PointCloudDepth>();
            cloud.Init();
            _clouds.Add(id, cloud);
            _cloudGameObjects.Add(id, cloudobj);


            cloudobj.transform.parent = _parent;
        }
    }
예제 #3
0
    private void loadConfig()
    {
        Dictionary <string, string> config = ConfigProperties.load(configFile);

        _videosDir        = config["videosDir"];
        _colorStreamName  = config["colorStreamName"];
        _depthStreamName  = config["depthStreamName"];
        _normalStreamName = config["normalStreamName"];
        _vidWidth         = int.Parse(config["vidWidth"]);
        _vidHeight        = int.Parse(config["vidHeight"]);
        _layerNum         = int.Parse(config["numLayers"]);


        for (int i = 0; i < _layerNum; i++)
        {
            string s = "";
            s = s + i;
            string    calib  = config[s];
            string[]  chunks = calib.Split(';');
            Matrix4x4 mat    = new Matrix4x4(new Vector4(float.Parse(chunks[0]), float.Parse(chunks[4]), float.Parse(chunks[8]), float.Parse(chunks[12])),
                                             new Vector4(float.Parse(chunks[1]), float.Parse(chunks[5]), float.Parse(chunks[9]), float.Parse(chunks[13])),
                                             new Vector4(float.Parse(chunks[2]), float.Parse(chunks[6]), float.Parse(chunks[10]), float.Parse(chunks[14])),
                                             new Vector4(float.Parse(chunks[3]), float.Parse(chunks[7]), float.Parse(chunks[11]), float.Parse(chunks[15])));

            GameObject cloudobj = new GameObject(s);
            cloudobj.transform.SetParent(_papi.transform);
            cloudobj.transform.localPosition = new Vector3(mat[0, 3], mat[1, 3], mat[2, 3]);
            cloudobj.transform.localRotation = mat.rotation;
            cloudobj.transform.localScale    = new Vector3(-1, 1, 1);
            cloudobj.AddComponent <PointCloudDepth>();

            PointCloudDepth cloud = cloudobj.GetComponent <PointCloudDepth>();

            //play from url
            string colorvideo = _videosDir + "\\" + s + _colorStreamName;
            //char[] sep = { '\\' };
            //string[] folderName = _videosDir.Split(sep);
            //string colorvideo = "CloudData\\" + folderName[folderName.Length - 1] + "\\" + s + _colorStreamName;
            string depthvideo = _videosDir + "\\" + s + _depthStreamName;
            //string normalvideo = _videosDir + "\\" + s + _normalStreamName;

            cloud.initStructs((uint)i, colorvideo, depthvideo, cloudobj, this);

            _clouds.Add(s, cloud);
        }
    }