Processing and Kinect – Replaying Recorded Kinect Data for Development

This uses the format from Peizhao.

First, get the code by cloning the repository at http://github.com/rhema/art . (look up git or github if you need to)

The folder we are interested with here is processing/sandbox/communication.

This folder contains the files:

./data/DirectIndirectRawData.txt   Kinect data from a raw (ascii values) format that we don’t use anymore.
./data/kinect_indirect_slower.bin  Kinect data from binary format.  If you want to know about the format, look at our discussion on github.
./udp/processing_consumer/consume_udp/consume_udp.pde   Example listener and visualizer in processing.
./udp/python_udp_simulator/load_data.py   Opens files in /data.
./udp/python_udp_simulator/simulate.py   The file you want to run to generate UDP data.

To run, run /udp/python_udp_simulator/simulate.py.  This starts the UDP traffic.  Then, open consume_udp.pde in processing (I used 2.5>).  You should see this:

The processing file has some comments.  The way that you might use it in a project is to copy this as a file in your sketch.  You could use the variables that get updated below directly:

PVector root_position = new PVector(0,0,0);
Vector<PVector> all_positions = new Vector<PVector>(21);//raw kinect data
Vector<PVector> all_positions_p = new Vector<PVector>(21);//converted to 2d

all_positions_p contains screen coordinates.   You need to make sure you don’t write to all_positions or all_positions_p or you may run into synchronization issues.

Or, you could call a different function from the within function dancerPositionAlteredEvent.

Please comment if you have questions and I will revise this post.

Measuring Direct vs Indirect Paths, an Initial Prototype

In thinking about the sketch 1 assignment, which is to create a performance that looks at direct vs indirect space, I’ve been thinking about how measure in/directness.  The following example images come from a live demo in HTML5/Javascript I made yesterday.  Drag your mouse around to see the last 30 or so points your mouse moved.  The intuition behind the metric is to measure the predicability of the path.  For each point, I try to predict the next 5 steps by assuming the actual path will continue in the same linear predicted path.  The following screenshots show a various paths and a scale from 0 to 100 of in/directness.

direct

 

 

 

 

indirectish 

 

indirect

 

Here, the green path shows the actual mouse path.  Each red line is the predicted path at a point.  The more often the red path matches the green path, the more direct the path is.

One can imagine using a Kinect or Wiimote to generate this path.  Once that is accomplished, interactive visualizations and sonifications can be mapped to this metric.

 

 

An Accident in R – Plot

While going over some data for an unrelated research project, I accidentally discovered a very useful feature of R.

 

First, I load a CSV File:

> heat<-read.csv(“MiamiHeat.csv”)

For this example, I’m using a data set from the Miami Heat NBA team here.  The Wikipedia article on Basketball Statistics describes the columns in this sheet.

Normally, I might plot something I find interesting, let’s plot rebounds vs steals:

> plot(heat$Rebounds,heat$Steals)

 

That’s kind of interesting, but we have many columns in this csv file that might provide some insight about the NBA.   The plot looks pretty muddled, but we might as well check for a correlation:

> cor.test(heat$Rebounds,heat$Steals)

    Pearson’s product-moment correlation

data:  heat$Rebounds and heat$Steals
t = -0.0943, df = 80, p-value = 0.925
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.2270342  0.2069341
sample estimates:
cor
-0.01054669

We see can’t show a correlation for this.  Is there anything interesting here?  Well, we can actually plot each column against every other column with one command!

> plot(heat)

While, from this blog post, this image may not seem useful, it is quite useful on a decent sized screen.   Here’s a closer look from  a subsection:

It looks like FGA (field goals attempted) and Points are positively correlated.

> plot(heat$FGA,heat$Points)

We also see that a positive correlation with some effect:

    Pearson’s product-moment correlation

data:  heat$FGA and heat$Points
t = 3.394, df = 80, p-value = 0.001074
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.1492569 0.5309065
sample estimates:
cor
0.3547730

You can see how using R’s plot on ALL of your data can be useful for exploring possible relationships among your data.