This project is read-only.

getting position of Z-axis

May 20, 2009 at 10:44 AM

Hi,

Is there any way to get marker Z-axis position?

Best regards

May 21, 2009 at 1:56 AM

Hello laziers,

 

I’ve been using the marker’s size and/or bounds as an indicator of the Z axis position.

This obviously isn’t correct, but it’s usually a workable way to roughly gauge the z position.

The idea isn’t to have accurate Z information, but to use the correlation of z position and size to give the user some depth cues.

I hope that works for you, and thanks for your interest in Touchless!

 

- Mike

May 21, 2009 at 7:19 AM

Hi michwass,

I see... but maby you have any source code for this? I will be very greatfull :)

Could you tell me if there is possible to combine opengl with Touchless?

regards! :)

May 21, 2009 at 7:36 PM

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 drawing.

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 pen width.

 

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 values

_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 of luck!

- Mike

May 23, 2009 at 7:25 AM

thx for the reply :) its very helpfull

 

best regards