September 19, 2010

Region Observer - Module

I created a module that lets your define Region-Shapes inside the homespace and observes artifact moving in and out.
  • The Regions can be either a box, a box with a hole, a cylinder or a ring
  • An event handler fires whenever a Presence moves into a new Region
  • You can have overlapping regions and set Priorities
  • A Dynamic-Border-Value can be set, which is applied to a shape and prevents quick region changes when someone stands between two regions
  • You can also be notified whenever an artifact is no longer visible to the tracking system

This is a example, that uses the RegionDetector to observe two people in the homespace and writes their current region to the screen:

public RegionTeller(){
    InitializeComponent();

    //This shows how we you can define custom regions and observe two people moving in and out of them
    RegionsDetector peopleObserver = new RegionsDetector();

    //add two hats that will be observed as people
    peopleObserver.AddObservedPresence("WhiteHat");
    peopleObserver.AddObservedPresence("BlackHat");
               
    //define and Add custom regions
    ProximityToolkit.Vector3 displayCenter = new ProximityToolkit.Vector3(-350,0,-89);

    //Touchregion is a rectangular Box around the display
    RectangularRegion touchRegion = new RectangularRegion("touch", 400, 700, 3000);
    touchRegion.Center = displayCenter;
    touchRegion.DynamicRegionBelt = 150;
    peopleObserver.AddRegion(touchRegion,2);           

    //Sitting Region is a Rectangular Box around the couch
    RectangularRegion sittingRegion = new RectangularRegion("sitting", 600, 1500, 1350);
    sittingRegion.Center = new ProximityToolkit.Vector3(1500, 0, 0);
    sittingRegion.DynamicRegionBelt = 150;
    peopleObserver.AddRegion(sittingRegion, 2);

    //Intermediate Interaction Region is a Cylindrical Region around the display below the Touchregion and SittingRegion
    CircularRegion intermediateRegion = new CircularRegion("intermediate", 2000);
    intermediateRegion.Center = displayCenter;
    intermediateRegion.DynamicRegionBelt = 150;
    peopleObserver.AddRegion(intermediateRegion, 1);

    //Far awar Region is a circular belt around the intermediate interaction region below the Touchregion and SittingRegion
    CircularRegion farRegion = new CircularRegion("far away", new RegionValue(2000, 4000));
    farRegion.Center = displayCenter;
    farRegion.DynamicRegionBelt = 150;
    peopleObserver.AddRegion(farRegion, 1);
               
    //Be notified whenever a person changes in between Regions
    peopleObserver.OnRegionChange += new RegionChangeHandler(peopleObserver_OnRegionChange);
}
RegionLabel.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(
    delegate()
    {
        RegionLabel.Content = presence.Presence.Name + ": " + presence.Region.Name;
    }
    ));  
}

No comments:

Post a Comment