Ejemplo n.º 1
0
        private void GetMeshDataAndWriteJson()
        {
            if (!updatedVerticesThisFrame && recording)
            {
                //getting vertex data
                frame++;
                MeshData meshData = GetMeshData(frame);
                string   json     = JsonUtility.ToJson(meshData);
                (jsonContents, curTick, write) = DataHelper.JsonContentTicker(lastFrame: lastFrame, curTick: curTick, reqTick: 3, contents: jsonContents, json);


                if (write && !lastFrame)
                {
                    JsonFileWriter.WriteDataToFile(path: filePath, text: jsonContents, title: "", lastFrame: lastFrame);
                    jsonContents = "";
                }

                else if (write && lastFrame)
                {
                    JsonFileWriter.WriteDataToFile(path: filePath, text: jsonContents, title: "", lastFrame: lastFrame);
                    jsonContents = "";
                    recording    = false;
                    filePath     = null;
                }
            }
            updatedVerticesThisFrame = false;
        }
Ejemplo n.º 2
0
        private void WriteDataLastFrame(int frame, bool lastFrame)
        {
            //proj matrix
            Matrix4x4 m_matrix         = arCamera.projectionMatrix;
            CameraProjectionMatrix tmp = new CameraProjectionMatrix();

            tmp.frame = frame;
            tmp.cameraProjectionMatrix = m_matrix;

            //config
            CameraConfig     m_config = GetCameraConfiguration();
            ScreenResolution m_res    = GetResolution();

            //prepare data
            string matrix = JsonUtility.ToJson(tmp);
            string config = JsonUtility.ToJson(m_config);
            string res    = JsonUtility.ToJson(m_res);

            //phrasing
            string par   = "}";
            string quote = "\"";
            string json  = $"{matrix}],{quote}cameraConfig{quote}:{config},{quote}resolution{quote}:{res}{par}";

            //writing
            contents += json;
            JsonFileWriter.WriteDataToFile(path: filePath, text: contents, "", lastFrame: lastFrame);
            contents = "";
        }
Ejemplo n.º 3
0
        private void WriteDataContinously(int frame, bool lastFrame)
        {
            //proj matrix
            Matrix4x4 m_matrix         = arCamera.projectionMatrix;
            CameraProjectionMatrix tmp = new CameraProjectionMatrix();

            tmp.frame = frame;
            tmp.cameraProjectionMatrix = m_matrix;

            //prepare data
            string json = JsonUtility.ToJson(tmp);

            (contents, curTick, write) = DataHelper.JsonContentTicker(lastFrame: lastFrame, curTick: curTick, reqTick: 23, contents: contents, json: json);

            //write contents
            if (write)
            {
                JsonFileWriter.WriteDataToFile(path: filePath, text: contents, "", lastFrame: lastFrame);
                contents = "";
            }

            if (lastFrame)
            {
                filePath = null;
            }
        }
Ejemplo n.º 4
0
        public void Init(string path, string title)
        {
            filePath = $"{path}{title}_{j_Prefix()}.json";
            JsonFileWriter.WriteDataToFile(path: filePath, text: "", title: "screenPosData", lastFrame: false);


            //screen space camera
            if (arCamera == null)
            {
                var cam = GameObject.FindGameObjectWithTag("MainCamera");
                arCamera = cam.GetComponent <Camera>();
            }

            if (arRaycastManager == null || arPlaneManager == null)
            {
                var sessionOrigin = GameObject.FindGameObjectWithTag("arSessionOrigin");
                arRaycastManager = sessionOrigin.GetComponent <ARRaycastManager>();
                arPlaneManager   = sessionOrigin.GetComponent <ARPlaneManager>();
                referenceCreator = sessionOrigin.GetComponent <ReferenceCreator>();
            }

            curTick      = 0;
            write        = false;
            jsonContents = "";
            //camera resolution to normalize screen pos data
            camera_width  = arCamera.pixelWidth;
            camera_height = arCamera.pixelHeight;
        }
Ejemplo n.º 5
0
 public void Init(string path, string title)
 {
     write    = false;
     curTick  = 0;
     filePath = $"{path}{title}_{j_Prefix()}.json";
     JsonFileWriter.WriteDataToFile(path: filePath, text: "", title: "facePoseList", lastFrame: false);
     Debug.Log("init face pos");
 }
 //only works with a single face mesh
 public void Init(string path, string title)
 {
     write = false;
     //init json file on disk
     filePath = $"{path}{title}_{j_Prefix()}.json";
     JsonFileWriter.WriteDataToFile(path: filePath, text: "", title: "meshGeometry", lastFrame: false);
     recording = true;
     Debug.Log("init face mesh indicies handler");
 }
Ejemplo n.º 7
0
 public void Init(string path, string title)
 {
     pointDensity = PlayerPrefsHandler.Instance.GetFloat("pointDensity", 0.05f);
     filePath     = $"{path}{title}_{j_Prefix()}.json";
     lastFrame    = false;
     JsonFileWriter.WriteDataToFile(path: filePath, text: "", title: "points", lastFrame: false);
     arPointCloud = GameObject.FindGameObjectWithTag("pointCloud").GetComponent <ARPointCloud>();
     ReceivePointCloud();
     recording = true;
 }
Ejemplo n.º 8
0
        //only works with a single face mesh
        public void Init(string path, string title)
        {
            //assign variables
            lastFrame    = false;
            recording    = true;
            jsonContents = "";

            //init json file on disk
            filePath = $"{path}{title}_{j_Prefix()}.json";
            JsonFileWriter.WriteDataToFile(path: filePath, text: "", title: "meshDataList", lastFrame: false);
            Debug.Log("Initialized face mesh");
        }
        private void GetMeshIndices()
        {
            MeshGeometry meshGeometry = GetMeshGeometry();

            if (write)
            {
                string json = JsonUtility.ToJson(meshGeometry);

                JsonFileWriter.WriteDataToFile(path: filePath, text: json + "]}", title: "", lastFrame: true);
                recording = false;
                write     = false;
                filePath  = null;
            }
        }
Ejemplo n.º 10
0
        private void WriteData(string json, bool lastFrame)
        {
            (jsonContents, curTick, write) = DataHelper.JsonContentTicker(lastFrame: lastFrame, curTick: curTick, reqTick: 49, contents: jsonContents, json: json);

            if (write)
            {
                JsonFileWriter.WriteDataToFile(path: filePath, text: jsonContents, title: "", lastFrame: lastFrame);
                jsonContents = "";

                if (lastFrame)
                {
                    filePath = null;
                }
            }
        }
        //while recoring updating facial features and store them as blendshapedata as soon the subsystem update occurs
        void UpdateFaceFeatures()
        {
            if (recording)
            {
#if UNITY_IOS && !UNITY_EDITOR
                List <BlendShape> tmpBlendShapes = new List <BlendShape>();
                frame++;

                using (var m_blendShapes = m_ARKitFaceSubsystem.GetBlendShapeCoefficients(m_Face.trackableId, Allocator.Temp))
                {
                    foreach (var featureCoefficient in m_blendShapes)
                    {
                        BlendShape blendShape = new BlendShape()
                        {
                            shapeKey = featureCoefficient.blendShapeLocation.ToString(),
                            value    = featureCoefficient.coefficient
                        };

                        tmpBlendShapes.Add(blendShape);
                    }
                }

                //getting blend shape data
                BlendShapeData blendShapeData = new BlendShapeData()
                {
                    blendShapes = tmpBlendShapes,
                    frame       = frame
                };

                blendShapeDataList.Add(blendShapeData);

                string json = JsonUtility.ToJson(blendShapeData);

                if (lastFrame)
                {
                    string par = "]}";
                    json     += par;
                    recording = false;
                }
                JsonFileWriter.WriteDataToFile(path: filePath, text: json, title: "", lastFrame: lastFrame);
                if (lastFrame)
                {
                    filePath = null;
                }
#endif
            }
        }
Ejemplo n.º 12
0
        public void Init(string path, string title)
        {
            filePath = $"{path}{title}_{j_Prefix()}.json";
            JsonFileWriter.WriteDataToFile(path: filePath, text: "", title: "cameraProjection", lastFrame: false);

            //reference to the ar camera
            if (arCameraManager == null || arCamera == null)
            {
                var obj = GameObject.FindGameObjectWithTag("arSessionOrigin");
                arCameraManager = obj.GetComponentInChildren <ARCameraManager>();
                arCamera        = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
            }

            curTick  = 0;
            contents = "";
            write    = false;
        }
Ejemplo n.º 13
0
        private void AccessingPoseData(int frame, bool lastFrame)
        {
            //getting vertex data
            var    poseData = DataHelper.GetPoseData(mainCamera, frame);
            string json     = JsonUtility.ToJson(poseData);

            (jsonContents, curTick, write) = DataHelper.JsonContentTicker(lastFrame: lastFrame, curTick: curTick, reqTick: 61, contents: jsonContents, json: json);

            if (write)
            {
                JsonFileWriter.WriteDataToFile(path: filePath, text: jsonContents, title: "", lastFrame: lastFrame);
                jsonContents = "";
                if (lastFrame)
                {
                    filePath = null;
                }
            }
        }
        public void Init(string path, string title)
        {
            filePath = $"{path}{title}_{j_Prefix()}.json";
            JsonFileWriter.WriteDataToFile(path: filePath, text: "", title: "blendShapeData", lastFrame: false);

#if UNITY_IOS && !UNITY_EDITOR
            if (m_ARKitFaceSubsystem == null)
            {
                var faceManager = FindObjectOfType <ARFaceManager>();
                if (faceManager != null)
                {
                    m_ARKitFaceSubsystem = (ARKitFaceSubsystem)faceManager.subsystem;
                }
            }
#endif
            m_Face.updated += OnUpdated;
            recording       = true;
            lastFrame       = false;
        }
Ejemplo n.º 15
0
        private void WriteDataToFile()
        {
            if (write && !lastFrame)
            {
                JsonFileWriter.WriteDataToFile(
                    path: filePath, text: contents, title: "", lastFrame: lastFrame);
                contents = "";
            }

            if (write && lastFrame)
            {
                JsonFileWriter.WriteDataToFile(
                    path: filePath, text: contents, title: "", lastFrame: lastFrame);
                contents = "";

                recording = false;
                filePath  = null;
            }
        }
Ejemplo n.º 16
0
        public void StopTracking()
        {
            for (int i = 0; i < referenceCreator.anchors.Count; i++)
            {
                var    vector = referenceCreator.anchors[i].transform.position;
                string json   = JsonUtility.ToJson(vector);

                if (i < referenceCreator.anchors.Count - 1)
                {
                    jsonContents += $"{json},";
                }
                else
                {
                    jsonContents += json;
                }
            }

            //TODO: Check if data gets closed
            jsonContents += "]}";
            JsonFileWriter.WriteDataToFile(path: filePath, text: jsonContents, title: "", lastFrame: true);
            jsonContents = "";
            filePath     = null;
        }
Ejemplo n.º 17
0
 public void Init(string path, string title)
 {
     filePath = $"{path}{title}_{j_Prefix()}.json";
     JsonFileWriter.WriteDataToFile(path: filePath, text: "", title: "cameraPoseList", lastFrame: false);
     mainCamera = GameObject.FindGameObjectWithTag("MainCamera");
 }
Ejemplo n.º 18
0
 public void Init(string path, string title)
 {
     filePath = $"{path}{title}_{j_Prefix()}.json";
     JsonFileWriter.WriteDataToFile(path: filePath, text: "", title: "anchorData", lastFrame: false);
     referenceCreator = GameObject.FindGameObjectWithTag("arSessionOrigin").GetComponent <ReferenceCreator>();
 }