Look in the source code repository. My examples are extremely naive, but might be a good starting point:
Samples\TouchlessDemo\DrawDemo.cs (in function UpdateMarker):
_pen.Width = (int)(data.Area / 60);
This is using the MarkerEventData’s Area property (the number of pixels matching the marker in the most recent frame) to set the pen width for
So in the general case, as you’d bring the marker further from or closer to the camera (or show/hide more marker area), you’ll change the
Samples\TouchlessDemo\ImageDemo.cs (in function UpdateSingleMarker):
// Calculate baseline area (running avg) for the first _MaxSampleFrameCount frames
if (_sampleFrameCount < _MaxSampleFrameCount)
_baselineArea = (_sampleFrameCount++ == 0) ? args.EventData.Area : (_baselineArea
+ args.EventData.Area) / 2;
***[I OMITTED SOME CODE HERE FOR BREVITY]***
// Find new velocity scale by adding new acceleration value; then cap at min/max
_velocityScale += (float)((args.EventData.Area - _baselineArea) / (100F * _baselineArea));
_velocityScale = (float)(Math.Max(Math.Min(_velocityScale, _MaxVelocityScale), -_MaxVelocityScale));
This is calculating a “base area” (just
the average Area of the marker found in the first x frames), and comparing that with later Marker Area to calculate the _velocityScale (which just determines whether we should scale the image to be smaller or bigger). This gives the user the effect
of making the image bigger (zooming in) when they bring the marker closer to the camera (or reveal more marker area).
You can also use the marker bounds (MarkerEventData.Top/Bottom/Left/Right/Width/Height) to get the bounding box of the matching pixels.
Touchless isn't tied to any graphics framework; it requires DirectShow to grab camera frames and requires .Net, but you are free to combine
it's use with Windows Forms, WPF, XNA, DirectX, and even OpenGL. Search for "OpenGL .Net" in your favorite search engine.
I've only used OpenGL with unmanaged C++, but I have used XNA with C# and that's pretty sweet.
I hope that helps. Please, if you do use Touchless for something
cool, post info or e-mail me! Our users (and myself) like seeing pictures, reading about, and especially trying apps/demos made with Touchless. Best