# Speed Determination and Picking Colour from a Ramp

Hi All,

I’m new to TouchDesigner and I have taken on a little project in order to learn the application. I will be using a Kinect for Windows v2 with TD on the weekend but for now I am using a Kinect for Windows v1. I am trying to track a dancer, or even just someone stumbling around in front of the Kinect, such as myself. I want to use the player’s moves to affect both imagery and audio content.

I am currently working on tracking the hands of the player to draw a line and I want to use the speed of movement of the hand to control the colour of the line being drawn.

How can I determine the speed of movement of a tracked point in 3D space?

How can I use the speed calculated to select a colour from a horizontal ramp for the object that is being used to draw the line?

The desired result would be that when the hand is moving slowly a dark colour is selected at the beginning of the ramp and when it’s moving quickly a bright colour is selected from the end of the ramp with everything else falling in between those extremes.

Any help would be greatly appreciated.

Glen

hi!
welcome!
Well, the speed is pretty simple, you can use the slope CHOP for example to get the derivative of a signal. I think (5 oçlock in the moring here) you can just add up the absolute values of the three derivatives of the coordinates. At least that should produce something useful.

You can use a lookup TOP to get a pixel line or row from a ramp using another TOP. This TOP, that would be your ‘index’ there could be a constant TOP. The constant TOP’s brightness, would control which row/column is looked up. And the constant TOP’s color/brightness could be controlled via chop exporting.
Sry, no time right now to produce an example now, and I’m sure there are tons of other ways to do this, but I hope that’ll get you started.
cheers!

Thanks for the welcome, and the guidance, both of these suggestions worked very well!

Additional questions now as a result:

The movement of the circle which is creating the line is very jittery and it jumps way off of track at times. Is there any way that I can filter out the noise/jitteriness? Is it the Kinect v1 that might be causing this?

When I am drawing the line using the circle, if I move quickly there are gaps in the lap such that it is no longer a line but a series of dots. Is there any way that I can fix this?

Thanks again.

Just a small tip: Adding the absolute values is only approximate.
I think more accurate is taking the length of the equivalent vector from the 3 channels.

You can do this simply by feeding the Speed CHOP into a Match CHOP and selecting:
Combine Channels: Length

To smooth things out, try applying a Filter CHOP or Lag CHOP somewhere in the chain.

Not sure what your network is, but you may want to use a Trail CHOP to get a running history of the output values, instead of just the one current value.
You can then add a circle to each sample in the Trail, instead of just the one you’re doing now.

Alternatively the Limit SOP can be used to turn CHOP channels into connected line geometry.

Hope that helps,
Rob.

Thanks again folks.

Any idea how I can accomplish something like the smudge tool from Photoshop using XY data from the Kinect? I am able to use the Kinect to track hand positions, but using the displace operator doesn’t seem to provide the results I want, or at least I haven’t figure out how to get them yet.

Sorry for the barrage of questions folks, I’ll try to keep them to a minimum.

Is there any way that when I change the Index parameter of a Switch TOP, I can cause others OPs to change/update/reset as a result?

What I would like to do is, when the Switch TOP index value changes, I want the the opacity channel of a Level TOP to momentarily drop to 0 and then return to it’s previous value. Is this possible?

Also, I tried to use the Limit SOP to create connected lines as above but I could only see results when I used the single spheres and circles, not the lines. Any idea why that might be the case?

Ok, I have made a little bit of progress with creating a script to change the opacity of another OP. However, I can’t get it to change back. Please correct me if I’m wrong but I assume it may be a timing issue? I have tried using the time.sleep() command but that throws an error that global name ‘time’ is not defined.