private void label1_Click(object sender, EventArgs e) { bfr = myKinect.BodyFrameSource.OpenReader(); bfr.FrameArrived += bfr_FrameArrived; vgbd = new VisualGestureBuilderDatabase("C:/Users/INGENIERO POL/Documents/Poryectos visual/WindowsFormsApp1/WindowsFormsApp1/DB/D_cabeza.gba"); vgbfs = new VisualGestureBuilderFrameSource(KinectSensor.GetDefault(), 0); foreach (Gesture g in vgbd.AvailableGestures) { if (g.Name.Equals("D_cabeza")) { Gesture = g; vgbfs.AddGesture(Gesture); } if (g.Name.Equals("D_garganta")) { Gesture2 = g; vgbfs.AddGesture(Gesture2); } } vgbr = vgbfs.OpenReader(); vgbfs.GetIsEnabled(Gesture); vgbfs.GetIsEnabled(Gesture2); vgbr.FrameArrived += vgbr_FrameArrived; myKinect.Open(); }
public GestureDetector(KinectSensor kinectSensor) { if (kinectSensor == null) { return; } main = (MainWindow)App.Current.MainWindow; // create the vgb source. The associated body tracking ID will be set when a valid body frame arrives from the sensor. this.vgbFrameSource = new VisualGestureBuilderFrameSource(kinectSensor, 0); // open the reader for the vgb frames this.vgbFrameReader = this.vgbFrameSource.OpenReader(); if (this.vgbFrameReader != null) { this.vgbFrameReader.IsPaused = true; this.vgbFrameReader.FrameArrived += this.Reader_GestureFrameArrived; } using (VisualGestureBuilderDatabase database = new VisualGestureBuilderDatabase(VGB_DATABASE_FILE)) { foreach (Gesture gesture in database.AvailableGestures) { this.vgbFrameSource.AddGesture(gesture); clapGesture = gesture; } } using (VisualGestureBuilderDatabase database = new VisualGestureBuilderDatabase(ZoomOutdtb)) { foreach (Gesture gesture in database.AvailableGestures) { vgbFrameSource.AddGesture(gesture); ZoomOut = gesture; } } using (VisualGestureBuilderDatabase database = new VisualGestureBuilderDatabase(Swipedtb)) { foreach (Gesture gesture in database.AvailableGestures) { vgbFrameSource.AddGesture(gesture); if (gesture.Name == "Swipe_Right") { RightToLeft = gesture; } if (gesture.Name == "Swipe_Left") { LeftToRight = gesture; } } } }
// Use this for initialization void Start() { if (AttachedObject != null) { _ps = AttachedObject.GetComponent <ParticleSystem>(); _ps.emissionRate = 4; _ps.startColor = Color.blue; } _kinect = KinectSensor.GetDefault(); _gestureDatabase = VisualGestureBuilderDatabase.Create(Application.streamingAssetsPath + "/salute.gbd"); _gestureFrameSource = VisualGestureBuilderFrameSource.Create(_kinect, 0); foreach (var gesture in _gestureDatabase.AvailableGestures) { _gestureFrameSource.AddGesture(gesture); if (gesture.Name == "salute") { _salute = gesture; } if (gesture.Name == "saluteProgress") { _saluteProgress = gesture; } } _gestureFrameReader = _gestureFrameSource.OpenReader(); _gestureFrameReader.IsPaused = true; }
// Use this for initialization void Start() { _kinect = KinectSensor.GetDefault(); _gestureFrameSource = VisualGestureBuilderFrameSource.Create(_kinect, 0); VisualGestureBuilderDatabase _gestureDatabase = null; foreach (var dbName in databaseArray) { var databasePath = Path.Combine(Application.streamingAssetsPath, dbName); _gestureDatabase = VisualGestureBuilderDatabase.Create(databasePath); foreach (var gesture in _gestureDatabase.AvailableGestures) { _gestureFrameSource.AddGesture(gesture); trackedGestures.AddLast(gesture); // if (gesture.Name == "Lean_Left") // { // Lean_Left = gesture; // } } } _gestureFrameReader = _gestureFrameSource.OpenReader(); _gestureFrameReader.IsPaused = true; }
// Use this for initialization void Start() { _Sensor = KinectSensor.GetDefault(); if (_Sensor != null) { if (!_Sensor.IsOpen) { _Sensor.Open(); } // Set up Gesture Source _Source = VisualGestureBuilderFrameSource.Create(_Sensor, 0); // open the reader for the vgb frames _Reader = _Source.OpenReader(); if (_Reader != null) { _Reader.IsPaused = true; _Reader.FrameArrived += GestureFrameArrived; } // load the 'Seated' gesture from the gesture database string path = System.IO.Path.Combine(Application.streamingAssetsPath, databasePath); Debug.Log("database path is " + path); _Database = VisualGestureBuilderDatabase.Create(path); // Load all gestures IList <Gesture> gesturesList = _Database.AvailableGestures; for (int g = 0; g < gesturesList.Count; g++) { Gesture gesture = gesturesList[g]; Debug.Log("database name is " + gesture.Name); _Source.AddGesture(gesture); } } instance = this; }
/// <summary> /// Initializes a new instance of the GestureDetector class along with the gesture frame source and reader /// </summary> /// <param name="kinectSensor">Active sensor to initialize the VisualGestureBuilderFrameSource object with</param> public KinectGestureDetector(KinectSensor kinectSensor) { if (_gestureCommands == null) { throw new ArgumentException(nameof(_gestureCommands)); } if (kinectSensor == null) { throw new ArgumentNullException(nameof(kinectSensor)); } // create the vgb source. The associated body tracking ID will be set when a valid body frame arrives from the sensor. _vgbFrameSource = new VisualGestureBuilderFrameSource(kinectSensor, 0); _vgbFrameSource.TrackingIdLost += Source_TrackingIdLost; // open the reader for the vgb frames _vgbFrameReader = _vgbFrameSource.OpenReader(); if (_vgbFrameReader != null) { _vgbFrameReader.IsPaused = false; _vgbFrameReader.FrameArrived += Reader_GestureFrameArrived; } using var database = new VisualGestureBuilderDatabase(PathHelper.FileGestureDatabasePath); // we could load all available gestures in the database with a call to vgbFrameSource.AddGestures(database.AvailableGestures), // but for this program, we only want to track one discrete gesture from the database, so we'll load it by name foreach (var gesture in database.AvailableGestures) { _vgbFrameSource.AddGesture(gesture); } }
// Start is called before the first frame update void Start() { if (customGestureManager != null) //if an instance of custom gesture manager already exists { Destroy(this); //destroy this script } customGestureManager = this; //set the singleton kinect = KinectSensor.GetDefault(); //get the kinect gestureDatabase = VisualGestureBuilderDatabase.Create(Application.streamingAssetsPath + "/" + databaseName + ".gbd"); //get the database gestureFrameSource = VisualGestureBuilderFrameSource.Create(kinect, 0); //create the frame source Pose[] poses = GameObject.FindObjectsOfType <Pose>(); foreach (var gesture in gestureDatabase.AvailableGestures) { for (int i = 0; i < poses.Length; i++) { if (gesture.Name.Equals(poses[i].GetGestureName())) { CustomGesture tempGesture;//create the new struct tempGesture.gesture = gesture; tempGesture.mesh = poses[i].GetMesh(); gestures.Add(tempGesture);//add it to the list } } // Debug.Log(gesture.Name); gestureFrameSource.AddGesture(gesture);//add all the available gestures in the database to the frame source } gestureFrameReader = gestureFrameSource.OpenReader(); gestureFrameReader.IsPaused = true; }
void UpdateGestureResult(Body[] _BodyData) { if (_BodyData != null) { int bodyindex = 0; //the bodyindex for those event controllers foreach (Body body in _BodyData) { // init a new ID with source and reader if (body.IsTracked && HashIdtb.Count < Maxpeople && !HashIdtb.ContainsKey(body.TrackingId) && body.TrackingId != 0) { VisualGestureBuilderFrameSource _Source = VisualGestureBuilderFrameSource.Create(_Sensor, 0); // create a VGB from sensor // add the Gestures in database for (int g = 0; g < gesturesList.Count; g++) { Gesture gesture = gesturesList[g]; _Source.AddGesture(gesture); } // add the Gestures in database _Source.TrackingId = body.TrackingId; // assign a ID VisualGestureBuilderFrameReader _Reader = _Source.OpenReader(); if (_Reader != null) { _Reader.IsPaused = false; _Reader.FrameArrived += GestureFrameArrived; } Dictionary <VisualGestureBuilderFrameSource, VisualGestureBuilderFrameReader> _Group = new Dictionary <VisualGestureBuilderFrameSource, VisualGestureBuilderFrameReader>(); _Group.Add(_Source, _Reader); HashIdtb.Add(_Source.TrackingId, _Group); if (!PlayerArgs.ContainsKey(body.TrackingId)) { PlayerArgs.Add(_Source.TrackingId, bodyindex); } Debug.Log("Add a " + body.TrackingId); } // init a new ID with source and reader // only update our body index to our playerargs(bcos once the reader init, we don't need to update the data mannually) if (body.IsTracked && PlayerArgs.ContainsKey(body.TrackingId) && body.TrackingId != 0) { PlayerArgs[body.TrackingId] = bodyindex; } bodyindex += 1; //move the index to next } } }
// detector one gesture one time public void AddDetector(string name) { // Debug.Log ("gesturelist is "+gesturesList[0].Name); for (int g = 0; g < gesturesList.Count; g++) { Gesture gesture = gesturesList [g]; string gname = gesture.Name; // Debug.Log ("gname is "+ gname); if (gesture.Name == name) { Debug.Log("database name is " + gesture.Name); _Source.AddGesture(gesture); } } }
// Initializes a new instance of the GestureDetector class along with the gesture frame source and reader public GestureDetector(KinectSensor kinectSensor, GestureResultView gestureResultView) { //init LifeCycleEvents.. lce = new LifeCycleEvents("GESTURES", "FUSION", "gestures-1", "acoustic", "command"); // LifeCycleEvents(string source, string target, string id, string medium, string mode) mmic = new MmiCommunication("localhost", 9876, "User1", "ASR"); //PORT TO FUSION - uncomment this line to work with fusion later //mmic = new MmiCommunication("localhost", 8000, "User1", "GESTURES"); // MmiCommunication(string IMhost, int portIM, string UserOD, string thisModalityName) mmic.Send(lce.NewContextRequest()); count = 0; if (kinectSensor == null) { throw new ArgumentNullException("Kinect Sensor is null"); } if (gestureResultView == null) { throw new ArgumentNullException("Gesture Result View is null"); } GestureResultView = gestureResultView; // Create the vgb source. The associated body tracking ID will be set when a valid body frame arrives from the sensor. vgbFrameSource = new VisualGestureBuilderFrameSource(kinectSensor, 0); vgbFrameSource.TrackingIdLost += Source_TrackingIdLost; // Open the reader for the vgb frames vgbFrameReader = vgbFrameSource.OpenReader(); if (vgbFrameReader != null) { vgbFrameReader.IsPaused = true; vgbFrameReader.FrameArrived += Reader_GestureFrameArrived; } // Load gestures from database using (VisualGestureBuilderDatabase database = new VisualGestureBuilderDatabase(gestureDatabase)) { foreach (Gesture gesture in database.AvailableGestures) { if (gesture.Name.Equals(stop) || gesture.Name.Equals(back) || gesture.Name.Equals(skip) || gesture.Name.Equals(vdown) || gesture.Name.Equals(vup)) { vgbFrameSource.AddGesture(gesture); } } } }
// Use this for initialization void Start() { _kinect = KinectSensor.GetDefault(); _gestureDatabase = VisualGestureBuilderDatabase.Create(Application.streamingAssetsPath + "/wavehand_Right.gba"); _gestureFrameSource = VisualGestureBuilderFrameSource.Create(_kinect, 0); foreach (var gesture in _gestureDatabase.AvailableGestures) { _gestureFrameSource.AddGesture(gesture); print("gesture available name : " + gesture.Name); if (gesture.Name == "wavehand_right") { wavehand_right = gesture; } } _gestureFrameReader = _gestureFrameSource.OpenReader(); _gestureFrameReader.IsPaused = true; }
// Use this for initialization void Start() { _kinect = KinectSensor.GetDefault(); // Recogemos el kinect por defecto _gestureDatabase = VisualGestureBuilderDatabase.Create(Application.streamingAssetsPath + "/ImaGestures.gbd"); // Recoge la base de datos _gestureFrameSource = VisualGestureBuilderFrameSource.Create(_kinect, 0); // Array de gestos ???? if (_gestureDatabase != null) { Debug.Log("Base de datos cargada con �xito"); } else { Debug.LogError("Error al cargar la base de datos"); } /* * Anyade los gestos * TODO: DEFINIR LOS NOMBRES DE ESTOS GESTOS DE MIERDA */ foreach (var gesture in _gestureDatabase.AvailableGestures) { _gestureFrameSource.AddGesture(gesture); switch (gesture.Name) { case "Menu_Right": _gesture1 = gesture; break; case "Alas": _gesture2 = gesture; break; default: Debug.Log(gesture.Name); break; } } _gestureFrameReader = _gestureFrameSource.OpenReader(); _gestureFrameReader.IsPaused = true; }
public GestureScan(KinectSensor kinectSensor, ulong trackingId, VisualGestureBuilderDatabase visualGestureBuilderDatabase) { TrackingId = trackingId; _vgbFrameSource = new VisualGestureBuilderFrameSource(kinectSensor, 0); _vgbFrameSource.TrackingIdLost += OnTrackingIdLost; _vgbFrameReader = _vgbFrameSource.OpenReader(); _vgbFrameReader.IsPaused = true; _vgbFrameReader.FrameArrived += OnFrameArrived; foreach (var gesture in visualGestureBuilderDatabase.AvailableGestures) { _vgbFrameSource.AddGesture(gesture); } _vgbFrameSource.TrackingId = trackingId; _vgbFrameReader.IsPaused = false; }
private void InitializeGestureRecognition() { GestureFrameSource = new VisualGestureBuilderFrameSource(KinectConnection.KSensor, 0); GestureFrameSource.TrackingIdLost += OnTrackingIdLost; if (GestureFrameSource != null) { GestureFrameReader = GestureFrameSource.OpenReader(); GestureFrameReader.FrameArrived += OnGestureFrameArrived; } using (VisualGestureBuilderDatabase database = new VisualGestureBuilderDatabase(this.Database)) { foreach (Gesture g in database.AvailableGestures) { GestureFrameSource.AddGesture(g); GesturesDictionary.Add(g.Name, g); } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { this.kinect = KinectSensor.GetDefault(); this.kinect.IsAvailableChanged += this.Sensor_IsAvailableChanged; this.StatusText = this.kinect.IsAvailable ? "A Kinect está ativa." : "A Kinect está desativada!"; this.GestureText = "Nenhum gesto detetado."; this.DataContext = this; _gm = new GestureMod(); bodyFrameReader = kinect.BodyFrameSource.OpenReader(); bodyFrameReader.FrameArrived += bodyFrameArrived; bodyFrameReader.IsPaused = false; vgbDb = new VisualGestureBuilderDatabase(@"Gestures\IM_Gestures.gbd"); vgbFrameSource = new VisualGestureBuilderFrameSource(KinectSensor.GetDefault(), 0); foreach (var g in vgbDb.AvailableGestures) { vgbFrameSource.AddGesture(g); } vgbFrameReader = vgbFrameSource.OpenReader(); vgbFrameReader.FrameArrived += vgbFrameArrived; kinect.Open(); }
/// <summary> /// Initializes a new instance of the GestureDetector class along with the gesture frame source and reader /// </summary> /// <param name="kinectSensor">Active sensor to initialize the VisualGestureBuilderFrameSource object with</param> /// <param name="gestureResultView">GestureResultView object to store gesture results of a single body to</param> public GestureDetector(KinectSensor kinectSensor, GestureResult gestureResultView) { if (kinectSensor == null) { throw new ArgumentNullException("kinectSensor"); } if (gestureResultView == null) { throw new ArgumentNullException("gestureResultView"); } this.GestureResultView = gestureResultView; // create the vgb source. The associated body tracking ID will be set when a valid body frame arrives from the sensor. this.vgbFrameSource = new VisualGestureBuilderFrameSource(kinectSensor, 0); this.vgbFrameSource.TrackingIdLost += this.Source_TrackingIdLost; // open the reader for the vgb frames this.vgbFrameReader = this.vgbFrameSource.OpenReader(); if (this.vgbFrameReader != null) { this.vgbFrameReader.IsPaused = true; this.vgbFrameReader.FrameArrived += this.Reader_GestureFrameArrived; } // load the 'Seated' gesture from the gesture database using (VisualGestureBuilderDatabase database = new VisualGestureBuilderDatabase(this.gestureDatabase)) { // we could load all available gestures in the database with a call to vgbFrameSource.AddGestures(database.AvailableGestures), // but for this program, we only want to track one discrete gesture from the database, so we'll load it by name foreach (Gesture gesture in database.AvailableGestures) { if (gesture.Name.Equals(this.GestureName)) { vgbFrameSource.AddGesture(gesture); } } } }
// Use this for initialization void Start() { fasterhappened = false; slowerhappened = false; _Sensor = KinectSensor.GetDefault(); if (_Sensor != null) { if (!_Sensor.IsOpen) { _Sensor.Open(); } // Set up Gesture Source _Source = VisualGestureBuilderFrameSource.Create(_Sensor, 0); // open the reader for the vgb frames _Reader = _Source.OpenReader(); if (_Reader != null) { _Reader.IsPaused = true; _Reader.FrameArrived += GestureFrameArrived; } // load the 'Seated' gesture from the gesture database string path = System.IO.Path.Combine(Application.streamingAssetsPath, databasePath); // TODO path irgendwann nicht mehr hardcoden _Database = VisualGestureBuilderDatabase.Create("Assets/Streaming Assets/gestures.gbd"); // Load all gestures IList <Gesture> gesturesList = _Database.AvailableGestures; for (int g = 0; g < gesturesList.Count; g++) { Gesture gesture = gesturesList[g]; _Source.AddGesture(gesture); } } }
internal override void OnStart() { // Create the vgb source. The associated body tracking ID will be set when a valid body frame arrives from the sensor. _frameSource = new VisualGestureBuilderFrameSource(Manager.Sensor, 0); // Open the reader for the vgb frames _frameReader = _frameSource.OpenReader(); if (_frameReader != null) { _frameReader.FrameArrived += FrameArrived; } // Load all gestures using (var database = new VisualGestureBuilderDatabase(DatabasePath)) { foreach (var gesture in database.AvailableGestures) { Console.WriteLine("Adding gesture {0} {1}", gesture.Name, gesture.GestureType); _frameSource.AddGesture(gesture); } } }
//Methof to initialise your kinect void InitKinect() { _getsureBasePath = Path.Combine(Application.streamingAssetsPath, "GestureDB/JumpDB.gbd"); _dbGestures = VisualGestureBuilderDatabase.Create(_getsureBasePath); _bodies = new Windows.Kinect.Body[6]; _kinect = Windows.Kinect.KinectSensor.GetDefault(); _kinect.Open(); _gestureFrameSource = VisualGestureBuilderFrameSource.Create(_kinect, 0); //for each gesture in trained database of custom gestures - add them to kinect frame source foreach (Gesture gest in _dbGestures.AvailableGestures) { _gestureFrameSource.AddGesture(gest); if (gest.Name == "Jump") { _jump = gest; } else if (gest.Name == "Lean_Left") { _moveLeft = gest; } else if (gest.Name == "Lean_Right") { _moveRight = gest; } else if (gest.Name == "Swing") { _swing = gest; } } _bodyFrameSource = _kinect.BodyFrameSource; _bodyFrameReader = _bodyFrameSource.OpenReader(); _bodyFrameReader.FrameArrived += _bodyFrameReader_FrameArrived; _gestureFrameReader = _gestureFrameSource.OpenReader(); _gestureFrameReader.IsPaused = true; _gestureFrameReader.FrameArrived += _gestureFrameReader_FrameArrived; }
void Start() { _Sensor = KinectSensor.GetDefault(); if (_Sensor != null) { if (!_Sensor.IsOpen) { _Sensor.Open(); } // Set up Gesture Source _Source = VisualGestureBuilderFrameSource.Create(_Sensor, 0); // open the reader for the vgb frames _Reader = _Source.OpenReader(); if (_Reader != null) { _Reader.IsPaused = true; _Reader.FrameArrived += GestureFrameArrived; } // load the gesture from the gesture database string path = System.IO.Path.Combine(Application.streamingAssetsPath, databasePath); _Database1 = VisualGestureBuilderDatabase.Create(path + "/Intro.gbd"); _Database2 = VisualGestureBuilderDatabase.Create(path + "/Onigiri.gbd"); _Database3 = VisualGestureBuilderDatabase.Create(path + "/Move_on.gbd"); _Database4 = VisualGestureBuilderDatabase.Create(path + "/Naja.gbd"); _Database5 = VisualGestureBuilderDatabase.Create(path + "/Bangloey.gbd"); _Database6 = VisualGestureBuilderDatabase.Create(path + "/Nidnid.gbd"); _Database7 = VisualGestureBuilderDatabase.Create(path + "/ChoeyMoey.gbd"); _Database8 = VisualGestureBuilderDatabase.Create(path + "/TakeUpArm.gbd"); _Database9 = VisualGestureBuilderDatabase.Create(path + "/DrawBigHeart.gbd"); _Database10 = VisualGestureBuilderDatabase.Create(path + "/Yeah.gbd"); _Database11 = VisualGestureBuilderDatabase.Create(path + "/TourPai.gbd"); _Database12 = VisualGestureBuilderDatabase.Create(path + "/Tummada.gbd"); _Database13 = VisualGestureBuilderDatabase.Create(path + "/Move_down.gbd"); _Database14 = VisualGestureBuilderDatabase.Create(path + "/Down_leg.gbd"); _Database15 = VisualGestureBuilderDatabase.Create(path + "/LoveorNot.gbd"); _Database16 = VisualGestureBuilderDatabase.Create(path + "/ComeOn.gbd"); _Database17 = VisualGestureBuilderDatabase.Create(path + "/LetsCookie.gbd"); _Database18 = VisualGestureBuilderDatabase.Create(path + "/Koisuru.gbd"); _Database19 = VisualGestureBuilderDatabase.Create(path + "/FurtuneCookies.gbd"); _Database20 = VisualGestureBuilderDatabase.Create(path + "/LetsWish.gbd"); _Database21 = VisualGestureBuilderDatabase.Create(path + "/HenWing.gbd"); _Database22 = VisualGestureBuilderDatabase.Create(path + "/Heyhey.gbd"); _Database23 = VisualGestureBuilderDatabase.Create(path + "/Clap.gbd"); _Database24 = VisualGestureBuilderDatabase.Create(path + "/Up_down.gbd"); _Database25 = VisualGestureBuilderDatabase.Create(path + "/Hairoo.gbd"); _Database26 = VisualGestureBuilderDatabase.Create(path + "/Rotate.gbd"); _Database27 = VisualGestureBuilderDatabase.Create(path + "/End.gbd"); _Database28 = VisualGestureBuilderDatabase.Create(path + "/Point.gbd"); _Database29 = VisualGestureBuilderDatabase.Create(path + "/Side.gbd"); // Load all gestures IList <Gesture> gesturesList1 = _Database1.AvailableGestures; IList <Gesture> gesturesList2 = _Database2.AvailableGestures; IList <Gesture> gesturesList3 = _Database3.AvailableGestures; IList <Gesture> gesturesList4 = _Database4.AvailableGestures; IList <Gesture> gesturesList5 = _Database5.AvailableGestures; IList <Gesture> gesturesList6 = _Database6.AvailableGestures; IList <Gesture> gesturesList7 = _Database7.AvailableGestures; IList <Gesture> gesturesList8 = _Database8.AvailableGestures; IList <Gesture> gesturesList9 = _Database9.AvailableGestures; IList <Gesture> gesturesList10 = _Database10.AvailableGestures; IList <Gesture> gesturesList11 = _Database11.AvailableGestures; IList <Gesture> gesturesList12 = _Database12.AvailableGestures; IList <Gesture> gesturesList13 = _Database13.AvailableGestures; IList <Gesture> gesturesList14 = _Database14.AvailableGestures; IList <Gesture> gesturesList15 = _Database15.AvailableGestures; IList <Gesture> gesturesList16 = _Database16.AvailableGestures; IList <Gesture> gesturesList17 = _Database17.AvailableGestures; IList <Gesture> gesturesList18 = _Database18.AvailableGestures; IList <Gesture> gesturesList19 = _Database19.AvailableGestures; IList <Gesture> gesturesList20 = _Database20.AvailableGestures; IList <Gesture> gesturesList21 = _Database21.AvailableGestures; IList <Gesture> gesturesList22 = _Database22.AvailableGestures; IList <Gesture> gesturesList23 = _Database23.AvailableGestures; IList <Gesture> gesturesList24 = _Database24.AvailableGestures; IList <Gesture> gesturesList25 = _Database25.AvailableGestures; IList <Gesture> gesturesList26 = _Database26.AvailableGestures; IList <Gesture> gesturesList27 = _Database27.AvailableGestures; IList <Gesture> gesturesList28 = _Database28.AvailableGestures; IList <Gesture> gesturesList29 = _Database29.AvailableGestures; for (int x = 0; x < gesturesList1.Count; x++) { Gesture g1 = gesturesList1[x]; if (g1.Name.Equals("Intro_Right")) { _Source.AddGesture(g1); } if (g1.Name.Equals("Intro_Left")) { _Source.AddGesture(g1); } } for (int x = 0; x < gesturesList2.Count; x++) { Gesture g2 = gesturesList2[x]; if (g2.Name.Equals("Onigiri_Right")) { _Source.AddGesture(g2); } if (g2.Name.Equals("Onigiri_Left")) { _Source.AddGesture(g2); } } for (int x = 0; x < gesturesList3.Count; x++) { Gesture g3 = gesturesList3[x]; if (g3.Name.Equals("Move_on_Right")) { _Source.AddGesture(g3); } if (g3.Name.Equals("Move_on_Left")) { _Source.AddGesture(g3); } } for (int x = 0; x < gesturesList4.Count; x++) { Gesture g4 = gesturesList4[x]; if (g4.Name.Equals("Naja")) { _Source.AddGesture(g4); } } for (int x = 0; x < gesturesList5.Count; x++) { Gesture g5 = gesturesList5[x]; if (g5.Name.Equals("Bangloey")) { _Source.AddGesture(g5); } } for (int x = 0; x < gesturesList6.Count; x++) { Gesture g6 = gesturesList6[x]; if (g6.Name.Equals("Nidnid")) { _Source.AddGesture(g6); } } for (int x = 0; x < gesturesList7.Count; x++) { Gesture g7 = gesturesList7[x]; if (g7.Name.Equals("ChoeyMoey")) { _Source.AddGesture(g7); } } for (int x = 0; x < gesturesList8.Count; x++) { Gesture g8 = gesturesList8[x]; if (g8.Name.Equals("TakeUpArm_Right")) { _Source.AddGesture(g8); } if (g8.Name.Equals("TakeUpArm_Left")) { _Source.AddGesture(g8); } } for (int x = 0; x < gesturesList9.Count; x++) { Gesture g9 = gesturesList9[x]; if (g9.Name.Equals("DrawBigHeart")) { _Source.AddGesture(g9); } } for (int x = 0; x < gesturesList10.Count; x++) { Gesture g10 = gesturesList10[x]; if (g10.Name.Equals("Yeah")) { _Source.AddGesture(g10); } } for (int x = 0; x < gesturesList11.Count; x++) { Gesture g11 = gesturesList11[x]; if (g11.Name.Equals("TourPai")) { _Source.AddGesture(g11); } } for (int x = 0; x < gesturesList12.Count; x++) { Gesture g12 = gesturesList12[x]; if (g12.Name.Equals("Tummada")) { _Source.AddGesture(g12); } } for (int x = 0; x < gesturesList13.Count; x++) { Gesture g13 = gesturesList13[x]; if (g13.Name.Equals("Move_down_Left")) { _Source.AddGesture(g13); } if (g13.Name.Equals("Move_down_Right")) { _Source.AddGesture(g13); } } for (int x = 0; x < gesturesList14.Count; x++) { Gesture g14 = gesturesList14[x]; if (g14.Name.Equals("Down_leg_Left")) { _Source.AddGesture(g14); } if (g14.Name.Equals("Down_leg_Right")) { _Source.AddGesture(g14); } } for (int x = 0; x < gesturesList15.Count; x++) { Gesture g15 = gesturesList15[x]; if (g15.Name.Equals("LoveorNot_Left")) { _Source.AddGesture(g15); } } for (int x = 0; x < gesturesList16.Count; x++) { Gesture g16 = gesturesList16[x]; if (g16.Name.Equals("ComeOn")) { _Source.AddGesture(g16); } } for (int x = 0; x < gesturesList17.Count; x++) { Gesture g17 = gesturesList17[x]; if (g17.Name.Equals("LetsCookie")) { _Source.AddGesture(g17); } } for (int x = 0; x < gesturesList18.Count; x++) { Gesture g18 = gesturesList18[x]; if (g18.Name.Equals("Koisuru_Left")) { _Source.AddGesture(g18); } if (g18.Name.Equals("Koisuru_Right")) { _Source.AddGesture(g18); } } for (int x = 0; x < gesturesList19.Count; x++) { Gesture g19 = gesturesList19[x]; if (g19.Name.Equals("FurtuneCookies")) { _Source.AddGesture(g19); } } for (int x = 0; x < gesturesList20.Count; x++) { Gesture g20 = gesturesList20[x]; if (g20.Name.Equals("LetsWish_Left")) { _Source.AddGesture(g20); } if (g20.Name.Equals("LetsWish_Right")) { _Source.AddGesture(g20); } } for (int x = 0; x < gesturesList21.Count; x++) { Gesture g21 = gesturesList21[x]; if (g21.Name.Equals("HenWing")) { _Source.AddGesture(g21); } } for (int x = 0; x < gesturesList22.Count; x++) { Gesture g22 = gesturesList22[x]; if (g22.Name.Equals("Heyhey")) { _Source.AddGesture(g22); } } for (int x = 0; x < gesturesList23.Count; x++) { Gesture g23 = gesturesList23[x]; if (g23.Name.Equals("Clap")) { _Source.AddGesture(g23); } } for (int x = 0; x < gesturesList24.Count; x++) { Gesture g24 = gesturesList24[x]; if (g24.Name.Equals("Up_down")) { _Source.AddGesture(g24); } } for (int x = 0; x < gesturesList25.Count; x++) { Gesture g25 = gesturesList25[x]; if (g25.Name.Equals("Hairoo")) { _Source.AddGesture(g25); } } for (int x = 0; x < gesturesList26.Count; x++) { Gesture g26 = gesturesList26[x]; if (g26.Name.Equals("Rotate")) { _Source.AddGesture(g26); } } for (int x = 0; x < gesturesList27.Count; x++) { Gesture g27 = gesturesList27[x]; if (g27.Name.Equals("End")) { _Source.AddGesture(g27); } } for (int x = 0; x < gesturesList28.Count; x++) { Gesture g28 = gesturesList28[x]; if (g28.Name.Equals("Point_Left")) { _Source.AddGesture(g28); } if (g28.Name.Equals("Point_Right")) { _Source.AddGesture(g28); } } for (int x = 0; x < gesturesList29.Count; x++) { Gesture g29 = gesturesList29[x]; if (g29.Name.Equals("Side")) { _Source.AddGesture(g29); } } } }
private bool InitVisualGestures() { KinectManager kinectManager = KinectManager.Instance; KinectInterop.SensorData sensorData = kinectManager != null?kinectManager.GetSensorData() : null; Kinect2Interface kinectInterface = sensorData.sensorInterface as Kinect2Interface; KinectSensor kinectSensor = kinectInterface != null ? kinectInterface.kinectSensor : null; if (kinectSensor == null) { return(false); } if (gestureDatabase == string.Empty) { Debug.LogError("Please specify gesture database file!"); return(false); } // copy the gesture database file from Resources, if available if (!File.Exists(gestureDatabase)) { TextAsset textRes = Resources.Load(gestureDatabase, typeof(TextAsset)) as TextAsset; if (textRes != null && textRes.bytes.Length != 0) { File.WriteAllBytes(gestureDatabase, textRes.bytes); } } // create the vgb source vgbFrameSource = VisualGestureBuilderFrameSource.Create(kinectSensor, 0); // open the reader vgbFrameReader = vgbFrameSource != null?vgbFrameSource.OpenReader() : null; if (vgbFrameReader != null) { vgbFrameReader.IsPaused = true; } using (VisualGestureBuilderDatabase database = VisualGestureBuilderDatabase.Create(gestureDatabase)) { if (database == null) { Debug.LogError("Gesture database not found: " + gestureDatabase); return(false); } // check if we need to load all gestures bool bAllGestures = (gestureNames.Count == 0); foreach (Gesture gesture in database.AvailableGestures) { bool bAddGesture = bAllGestures || gestureNames.Contains(gesture.Name); if (bAddGesture) { string sGestureName = gesture.Name; vgbFrameSource.AddGesture(gesture); if (!gestureNames.Contains(sGestureName)) { gestureNames.Add(sGestureName); } if (!gestureData.ContainsKey(sGestureName)) { VisualGestureData data = new VisualGestureData(); data.gestureName = sGestureName; data.timestamp = Time.realtimeSinceStartup; data.isDiscrete = (gesture.GestureType == GestureType.Discrete); data.isContinuous = (gesture.GestureType == GestureType.Continuous); gestureData.Add(sGestureName, data); } } } } return(true); }
// Use this for initialization public virtual void Start() { GameManegmentHelper.isUI = false; this.AllGestures = new List <string>(); this.CurrentGestureName = string.Empty; this.DetectedConfidence = 0.0f; currentTime = System.DateTime.Now.ToString(); _BodySource = FindObjectOfType <BodySourceManager>(); if (GameManegmentHelper.sensor == null) { Debug.Log("Initbhj"); _Sensor = KinectSensor.GetDefault(); GameManegmentHelper.sensor = _Sensor; } else { _Sensor = GameManegmentHelper.sensor; } //Debug.Log("Initbhj"); if (_Sensor != null) { // Debug.Log("Initbhj"); if (!_Sensor.IsOpen) { _Sensor.Open(); } _Source = VisualGestureBuilderFrameSource.Create(_Sensor, 0); _Reader = _Source.OpenReader(); // Set up Gesture Source //if (GameManegmentHelper._gestureSource==null) //{ // _Source = VisualGestureBuilderFrameSource.Create(_Sensor, 0); // GameManegmentHelper._gestureSource = _Source; // // Debug.Log(_Source); //} //else //{ // _Source = GameManegmentHelper._gestureSource; // //Debug.Log(_Source); //} //// open the reader for the vgb frames //if (GameManegmentHelper._gestureReader==null) //{ // _Reader = _Source.OpenReader(); // GameManegmentHelper._gestureReader = _Reader; //} //else //{ // _Reader = GameManegmentHelper._gestureReader; //} if (_Reader != null) { _Reader.IsPaused = true; _Reader.FrameArrived += GestureFrameArrived; } // load the gesture from the gesture database string path = System.IO.Path.Combine(Application.streamingAssetsPath, databasePath); _Database = VisualGestureBuilderDatabase.Create(path); // Load all gestures IList <Gesture> gesturesList = _Database.AvailableGestures; for (int g = 0; g < gesturesList.Count; g++) { Gesture gesture = gesturesList[g]; Debug.Log(gesture.Name); _Source.AddGesture(gesture); AllGestures.Add(gesture.Name); } } InitComponents(); }
// Use this for initialization void Start() { _Sensor = KinectSensor.GetDefault(); if (_Sensor != null) { if (!_Sensor.IsOpen) { _Sensor.Open(); } // Set up Gesture Source _Source = VisualGestureBuilderFrameSource.Create(_Sensor, 0); // open the reader for the vgb frames _Reader = _Source.OpenReader(); if (_Reader != null) { _Reader.IsPaused = true; _Reader.FrameArrived += GestureFrameArrived; } // load the ‘Squat’ gesture from the gesture database string path = System.IO.Path.Combine(Application.streamingAssetsPath, databasePath); _Database = VisualGestureBuilderDatabase.Create(path); // Load all gestures IList <Gesture> gesturesList = _Database.AvailableGestures; for (int x = 0; x < gesturesList.Count; x++) { Gesture g = gesturesList[x]; if (g.Name.Equals(landingLeftGesture)) { _Source.AddGesture(g); } if (g.Name.Equals(landingRightGesture)) { _Source.AddGesture(g); } if (g.Name.Equals(landing)) { _Source.AddGesture(g); } if (g.Name.Equals(moveUpwards)) { _Source.AddGesture(g); } if (g.Name.Equals(hover)) { _Source.AddGesture(g); } if (g.Name.Equals(moveDownWards)) { _Source.AddGesture(g); } } //for (int g = 0; g < gesturesList.Count; g++) // { // Gesture gesture = gesturesList[g]; // _Source.AddGesture(gesture); //} } }
void Awake() { Controller = gameObject.GetComponent <CharacterController> (); if (Controller == null) { Debug.LogWarning("OVRPlayerController: No CharacterController attached."); } // We use OVRCameraRig to set rotations to cameras, // and to be influenced by rotation OVRCameraRig[] CameraControllers; CameraControllers = gameObject.GetComponentsInChildren <OVRCameraRig> (); if (CameraControllers.Length == 0) { Debug.LogWarning("OVRPlayerController: No OVRCameraRig attached."); } else if (CameraControllers.Length > 1) { Debug.LogWarning("OVRPlayerController: More then 1 OVRCameraRig attached."); } else { CameraController = CameraControllers [0]; } YRotation = transform.rotation.eulerAngles.y; Physics.IgnoreLayerCollision(0, 8); //ignores collisions between the player and all objects menu = gameObject.GetComponent <Menu> (); source = GetComponent <UnityEngine.AudioSource> (); addAtoms = gameObject.GetComponent <AddAtoms> (); addAtoms.Init(); // load the file addAtoms.parsePDB(); //populate the scene Quaternion ort = (HmdRotatesY) ? CameraController.centerEyeAnchor.rotation : transform.rotation; addAtoms.setPosition(ort * Vector3.forward * 30 + this.transform.position); //centers the atoms infront of the user //initiate the kinect _Sensor = KinectSensor.GetDefault(); if (_Sensor != null) { _Mapper = _Sensor.CoordinateMapper; _Reader = _Sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Body | FrameSourceTypes.Depth); rightHand = transform.FindChild("RightHand").gameObject; leftHand = transform.FindChild("LeftHand").gameObject; rightHandMover = rightHand.GetComponent <GestureMover> (); leftHandMover = leftHand.GetComponent <GestureMover> (); var frameDesc = _Sensor.DepthFrameSource.FrameDescription; depthFrameWidth = frameDesc.Width; if (!_Sensor.IsOpen) { _Sensor.Open(); } _gestureDatabase = VisualGestureBuilderDatabase.Create(Application.streamingAssetsPath + "/Menu2.gbd"); _gestureFrameSource = VisualGestureBuilderFrameSource.Create(_Sensor, 0); foreach (var gesture in _gestureDatabase.AvailableGestures) { _gestureFrameSource.AddGesture(gesture); if (gesture.Name == "Menu2") { _menu = gesture; } } _gestureFrameReader = _gestureFrameSource.OpenReader(); _gestureFrameReader.IsPaused = true; } }