示例#1
0
    private void OnRecordButton()
    {
        if (!m_isRecording)
        {
            if (!m_gestManager.m_skReader.IsSkeletonAvailable())
            {
                m_showStr = "Please record after Kinect detects your skeleton";
            }
            else
            {
                m_showStrHeader = "Recording...";
                m_showStr       = m_showStrHeader;
                m_skRecorder.Reset();
                m_isRecording = true;
            }
        }
        else
        {
            if (!Directory.Exists(ConstDef.skelRootPath))
            {
                Directory.CreateDirectory(ConstDef.skelRootPath);
            }
            string filename = m_inputStr;
            if (!filename.EndsWith(ConstDef.skelFileSuffix))
            {
                filename += ConstDef.skelFileSuffix;
            }
            if (File.Exists(ConstDef.skelRootPath + filename))
            {
                filename = "skeleton data " + DateTime.Now.ToString("yy-MM-dd-HH-mm-ss") + ConstDef.skelFileSuffix;
            }

            try
            {
                using (StreamWriter writer = new StreamWriter(ConstDef.skelRootPath + filename))
                {
                    m_skRecorder.SaveFile(writer);
                }
                m_showStr = "Skeleton data have been saved to " + filename;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                m_showStr = filename + ": error occurred when saving";
            }

            m_isRecording = false;
        }

        ConstDef.defaultFileName = m_inputStr;
    }
示例#2
0
    public void OnSaveButton()
    {
        if (!Directory.Exists(ConstDef.skelRootPath))
        {
            Directory.CreateDirectory(ConstDef.skelRootPath);
        }
        string filename = m_inputStr;

        if (!filename.EndsWith(ConstDef.KFFileSuffix))
        {
            filename += ConstDef.KFFileSuffix;
        }
        if (m_inputStr == null || m_inputStr == ""
            /* || File.Exists(ConstDef.skelRootPath + filename)*/)             // commented because we allow overwriting
        {
            filename = "key frame data " + DateTime.Now.ToString("yy-MM-dd-HH-mm-ss") + ConstDef.KFFileSuffix;
        }

        try
        {
            int savedFrameCount;
            using (StreamWriter writer = new StreamWriter(ConstDef.skelRootPath + filename))
            {
                savedFrameCount = m_skRecorder.SaveFile(writer);
            }
            m_showStr = savedFrameCount + " frames (including " + m_skRecorder.TaggedFrameCount +
                        " key frames) has been saved to " + filename;
        }
        catch (Exception e)
        {
            Debug.LogException(e);
            m_showStr = filename + ": error occurred when saving";
        }

        ConstDef.defaultFileName = m_inputStr;
    }