public HandTracker(Context context) { this.context = context; //gestureGenerator = context.FindExistingNode(NodeType.Gesture) as GestureGenerator; handsGenerator = context.FindExistingNode(NodeType.Hands) as HandsGenerator; //gestureGenerator.GestureRecognized += new EventHandler<GestureRecognizedEventArgs>(gestureGenerator_GestureRecognized); handsGenerator.HandCreate += new EventHandler<HandCreateEventArgs>(handsGenerator_HandCreate); handsGenerator.HandDestroy += new EventHandler<HandDestroyEventArgs>(handsGenerator_HandDestroy); handsGenerator.HandUpdate += new EventHandler<HandUpdateEventArgs>(handsGenerator_HandUpdate); handsGenerator.StartGenerating(); //gestureGenerator.AddGesture("Wave"); Trace.WriteLine("HandSensor initialized"); }
void Start() { InitializeCharacter (); context = new Context (XML_SETUP_FILE); sessionManager = new SessionManager(context, "Wave", "RaiseHand"); depthGenerator = context.FindExistingNode(NodeType.Depth) as DepthGenerator; handsGenerator = context.FindExistingNode(NodeType.Hands) as HandsGenerator; //image = context.FindExistingNode(NodeType.Image) as ImageGenerator; //gesture = context.FindExistingNode(NodeType.Gesture) as GestureGenerator; if (depthGenerator == null) throw new Exception("Viewer must have a depth node!"); //if (gesture == null) throw new Exception("Viewer must have a gesture node!"); //if (image == null) throw new Exception("Viewer must have a image node!"); userGenerator = new UserGenerator (context); skeletonCapability = userGenerator.SkeletonCapability; poseDetectionCapability = userGenerator.PoseDetectionCapability; calibPose = skeletonCapability.CalibrationPose; //gestureGenerator = new GestureGenerator(context); foreach (String s in poseDetectionCapability.GetAllAvailablePoses()) Debug.LogWarning("available pose found: " +s); //foreach (String s in gestureGenerator.EnumerateAllGestures()) // Debug.LogWarning("available gesture found: " + s); //gestureGenerator.GestureRecognized += HandleGestureGestureRecognized; //gesture.AddGesture("Click"); //gestureGenerator.AddGesture("RaiseHand"); //seems buggy //gestureGenerator.AddGesture("Wave"); swipeDetector = new SwipeDetector(); //steadyDetector = new SteadyDetector();//(3, 1f); //swipeDetector.SwipeLeft += HandleSwipeDetectorSwipeLeft; //Session Managment sessionManager.SessionStart += HandleSessionManagerSessionStart; sessionManager.SessionEnd += HandleSessionManagerSessionEnd; //User Generator userGenerator.NewUser += HandleUserGeneratorNewUser; userGenerator.LostUser += HandleUserGeneratorLostUser; poseDetectionCapability.PoseDetected += HandlePoseDetectionCapabilityPoseDetected; skeletonCapability.CalibrationEnd += HandleSkeletonCapabilityCalibrationEnd; skeletonCapability.SetSkeletonProfile (SkeletonProfile.All); skeletonCapability.SetSmoothing(.5f); // give us some smooothing //Start generating userGenerator.StartGenerating(); //handsGenerator.MirrorCapability.SetMirror(true); // TODO: should this be true? handsGenerator.StartGenerating(); //gestureGenerator.StartGenerating(); //slider selector //selectableSlider2D = new SelectableSlider2D(Screen.width, Screen.height); //selectableSlider2D.ValueChange += HandleSelectableSlider2DValueChange; //selectableSlider2D.ItemHover += HandleSelectableSlider2DItemHover; //selectableSlider2D.ItemSelect += HandleSelectableSlider2DItemSelect; pointDenoiser = new PointDenoiser(); pointDenoiser.AddListener(swipeDetector); //pointDenoiser.AddListener(steadyDetector); //pointDenoiser.AddListener(selectableSlider2D); //flowRouter = new FlowRouter(); //flowRouter.ActiveListener = pointDenoiser; sessionManager.AddListener(pointDenoiser); MapOutputMode mapMode = depthGenerator.MapOutputMode; // Init depth & label map related stuff usersMapSize = mapMode.XRes * mapMode.YRes; //usersLabelTexture = new Texture2D(mapMode.XRes, mapMode.YRes); //nonPOT slow usersLabelTexture = new Texture2D(1024,512); //speed up by using power of two and then setpixel() with blockwidth (640) and blockheight (480) usersMapColors = new Color[usersMapSize]; usersMapRect = new Rect(Screen.width - usersLabelTexture.width / 2, Screen.height - usersLabelTexture.height / 2, usersLabelTexture.width / 2, usersLabelTexture.height / 2); usersLabelMap = new short[usersMapSize]; usersDepthMap = new short[usersMapSize]; usersHistogramMap = new float[5000]; this.shouldRun = true; if (NiteInitializingEvent != null) //notify others that we're done initializing NiteInitializingEvent(this, EventArgs.Empty); }