상속: ISerializable
예제 #1
0
        public static ActionLibrary load(String path)
        {
            /*ActionLibrary al = new ActionLibrary();

            Stream stream = File.Open(path, FileMode.Open);
            BinaryFormatter bformatter = new BinaryFormatter();

            al = (ActionLibrary)bformatter.Deserialize(stream);
            stream.Close();

            return al;*/

            Dictionary<string, string> actions = new Dictionary<string, string>();
            actions["raise the roof"] = "raisetheroof";
            actions["walk forward"] = "walkforward";
            actions["walk left"] = "walkleft";
            actions["walk back"] = "walkbackward";
            actions["walk right"] = "walkright";
            actions["wave right"] = "waveright";
            actions["wave left"] = "waveleft";
            string filename = "Z:/dev/kinect-nao/recordings/";
            ActionLibrary lib = new ActionLibrary();

            foreach (string actionName in actions.Keys)
            {
                List<HumanSkeleton> seq = new List<HumanSkeleton>();
                using (StreamReader s = new StreamReader(filename + actions[actionName] + "/"
                    + actionName + "1.rec"))
                {
                    while (!s.EndOfStream)
                    {
                        seq.Add(new HumanSkeleton(s.ReadLine()));
                    }
                }

                ActionSequence<NaoSkeleton> naoSeq = new ActionSequence<NaoSkeleton>();
                foreach (HumanSkeleton h in seq)
                {
                    AngleConverter ac = new AngleConverter(h);
                    naoSeq.append(ac.getNaoSkeleton());
                }

                if (actionName.StartsWith("walk"))
                {
                    NaoSkeleton start = naoSeq.get(0);
                    NaoSkeleton end = naoSeq.get(naoSeq.size() - 1);
                    NaoSkeleton diff = new NaoSkeleton(new NaoPosition(end.Position.X - start.Position.X, end.Position.Y - start.Position.Y, end.Position.Z - start.Position.Z));
                    naoSeq = new ActionSequence<NaoSkeleton>();
                    naoSeq.append(diff);
                }
                lib.appendToCache(naoSeq);
                lib.setCachedName(actionName);
                lib.saveCache();
            }

            return lib;
        }
예제 #2
0
        static void Main(string[] args)
        {
            Dictionary<string, string> actions = new Dictionary<string, string>();
            actions["raise the roof"] = "raisetheroof";
            actions["walk forward"] = "walkforward";
            actions["walk left"] = "walkleft";
            actions["wave right"] = "waveright";
            actions["wave left"] = "waveleft";
            string filename = "Z:/dev/kinect-nao/recordings/";
            ActionLibrary lib = new ActionLibrary();

            foreach (string actionName in actions.Keys)
            {
                List<HumanSkeleton> seq = new List<HumanSkeleton>();
                using (StreamReader s = new StreamReader(filename + actions[actionName] + "/"
                    + actionName + "1.rec"))
                {
                    while (!s.EndOfStream)
                    {
                        seq.Add(new HumanSkeleton(s.ReadLine()));
                    }
                }

                //List<float[]> naoSeq = new List<float[]>();
                ActionSequence<NaoSkeleton> naoSeq = new ActionSequence<NaoSkeleton>();
                foreach (HumanSkeleton h in seq)
                {
                    AngleConverter ac = new AngleConverter(h);
                    naoSeq.append(ac.getNaoSkeleton());
                    //naoSeq.Add(ac.getAngles());
                }

                lib.appendToCache(naoSeq);
                lib.setCachedName(actionName);
                lib.saveCache();
                //bool isJointAction = true; // false if is a walking action
                //ExecuteOnNao(naoSeq, isJointAction);
            }
            lib.save(MainController.ACTION_LIB_PATH);
        }
예제 #3
0
 private void init()
 {
     this.lib = ActionLibrary.load(ACTION_LIB_PATH);
     har = new HumanActionRecognizer(MODEL_LIB_PATH);
     har.Recognition += new HumanActionRecognizer.RecognitionEventHandler(har_Recognition);
     har.RecordingStart += new HumanActionRecognizer.RecordingEventHandler(har_RecordingStart);
     har.RecordingReady += new HumanActionRecognizer.RecordingEventHandler(har_RecordingReady);
     har.RecordingStop += new HumanActionRecognizer.RecordingEventHandler(har_RecordingStop);
 }