Chapter 2

Closest Pixel with Running Average

The sketch shown in Example A-1 uses two arrays declared as global variables to track the x- and y-components of the three most recent positions of the closest point seen by the Kinect. It then averages these three points to determine the current closest point. Performing this average smooths out the position of the point being tracked, making the tracking less responsive to outliers.

Example A-1. closest_pixel_running_average.pde

import SimpleOpenNI.*; SimpleOpenNI kinect; // these will become a running average // so they have to be floats float closestX; float closestY; // create arrays to store recent // closest x- and y-values for averaging int[] recentXValues = new int[3]; int[] recentYValues = new ...

Get Making Things See now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.