Exemple #1
0
        public void Save(BinaryWriter bstream)
        {
            /*
             * Format:
             *    - gid
             *    - speed
             *    - trajectories
             *    - timestamps
             */

            // Write the gesture name
            bstream.Write(Gid);

            // Write the gesture speed
            bstream.Write(Speed);

            // Write the trajectory
            SampleUtils.WriteTrajectory(bstream, trajectory);

            // Write timestamps now...
            // Write header.
            bstream.Write((int)timestamps.Count);

            // Write each timestamp
            for (int ii = 0; ii < timestamps.Count; ii++)
            {
                bstream.Write(timestamps[ii]);
            }
        }
Exemple #2
0
        public static RecordingData Load(
            BinaryReader bstream,
            bool removeDuplicates,
            HashSet <int> removedDataIndices = null,
            DeviceType deviceType            = default,
            int external_PID = -1,
            bool isSession   = false)
        {
            // Read gid
            string gid = bstream.ReadString();

            // Read speed
            int speed = bstream.ReadInt32();

            HashSet <int> removedIndices = new HashSet <int>();

            // Read the trajectory
            List <Vector> trajectory = SampleUtils.ReadTrajectory(
                bstream,
                removeDuplicates,
                deviceType: deviceType,
                external_PID: external_PID,
                isSession: isSession,
                removedIndices: removedIndices);

            // Read the timestamps
            int          tcnt       = bstream.ReadInt32();
            List <float> timestamps = new List <float>();

            for (int i = 0; i < tcnt; i++)
            {
                float value = bstream.ReadSingle();

                // Discard it if the corresponding trajectory was also removed
                if (!removedIndices.Contains(i))
                {
                    timestamps.Add(value);
                }
            }

            // Adjust the frame time offsets
            timestamps = timestamps.Select(item => item - timestamps[0]).ToList();

            if (removedDataIndices != null)
            {
                foreach (var index in removedIndices)
                {
                    removedDataIndices.Add(index);
                }
            }

            return(new RecordingData(
                       trajectory,
                       timestamps,
                       speed,
                       gid));
        }
Exemple #3
0
        /**
         *
         */
        public static Sample LoadSampleFile(
            string path,
            int subject_id,
            int gesture_id,
            DeviceType deviceType = default,
            bool isSession        = false)
        {
            Sample ret = new Sample(subject_id, gesture_id, 0);

            List <float>  timeS;
            List <Vector> trajectory = SampleUtils.LoadSample(
                path,
                out timeS,
                deviceType: deviceType,
                isSession: isSession);

            ret.AddTrajectory(trajectory);
            ret.AddTimeStamps(timeS);

            return(ret);
        }