• Stars
    star
    276
  • Rank 149,319 (Top 3 %)
  • Language
    HTML
  • License
    GNU General Publi...
  • Created almost 11 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Processing library for calibrating a Kinect to a projector for aligning projections to moving bodies and surfaces

#Kinect Projector Toolkit

Processing library for calibrating a kinect and a projector together, such that projected image is automatically aligned to the physical space it is projecting onto, facilitating the projection of images onto moving bodies and surfaces.

To see some applications of the software, see this highlight video of a workshop applying the software to live dance.

The calibration methodology comes from this writeup by Jan Hrdlička at 3dsense blog. For other work on Projector/Kinect calibration, see works and code by Elliot Woods, Kyle McDonald, and Daito Manabe, as well as the OpenFrameworks addon ofxCamaraLucida.

##V2 version

A very nice-looking fork of this for Kinect V2 is available here.

##Installation

The library requires Processing 2.0+, SimpleOpenNI, ControlP5, and OpenCV.

To install the library, copy the entire contents of this repository into a folder called "KinectProjectorToolkit" inside your Processing libraries folder, as any other library.

The library comes with a number of demos in the "examples" folder, as well as a program called CALIBRATION.pde which is the application used for determining the fit between the projector and Kinect. Instructions for calibration follow below.

##Instructions for calibration

###Video tutorial for calibration

###1) Room setup

After setting the projector, fix the Kinect to face the space onto which you are projecting. Ideally, the Kinect is tracking roughly the full space of the projection; if it is too close it may not see everything the projector sees, and if it is too far, it will be less precise. Unless you have a short-throw projector, the Kinect will probably be closer to the stage than the projector.

The Kinect and projector must be totally immobilized during calibration and after, because a calibration only works for that positioning of the two devices together.

###2) Software setup

Set your computer's display to extended/dual screen and project the secondary screen. Open up CALIBRATION.pde and make sure to set the pWidth and pHeight variables at the top to exactly match the resolution of the secondary display, e.g. 1024x768.

Finally, set the calibFilename variable to the exact path to which you want to save the calibration file to.

Setting up display

###3) Getting point pairs

The interface allows you to position a 5x4 chessboard which is being projected onto your stage/room. You can move its position using the XY grid on the right side of the interface, and resize it using the "size" slider. The "searching" button toggles whether the app is actively searching for a chessboard pattern.

Setting up display

You need some sort of a flat, mobile panel (best if white) to project onto. Place the panel somewhere in front of the Kinect, and position the projected chessboard onto it. When the chessboard is visible in the Kinect RGB view on the left of the interface, toggle the "searching" button to have the program search for the chessboard. If it finds it, you should see 12 green circles pop up over the corners of the chessboard in the interface, and the "add pair" button becomes visible. If the green circles are not coming up, the chessboard can not be found in the image, which means the chessboard is too small or the lighting is not adequate. See the tutorial video for a good example. If the circles do appear, but some or all of them are red, it means the chessboard is either too close or too far from the Kinect and it can't read the depth; move it into an appropriate range. Only when 12 green circles are visible is the "add pair" button accessible.

Setting up display

Repeat this process for a series of panel positions throughout your stage space. To get the best possible fit, you should sample the space as widely as possible. Move the board to at least two or three different depths (distance from the Kinect), and position the board at high and low positions as well. The more dispersed your board points are across all three spatial dimensions, the better your fit will be. If the points are mostly coplanar, the model may not generalize well to undersampled regions.

###4) Calibration

Depending on the demands of your application, you may need only a few board positions, or several dozen. Generally, 10-15 board positions gives a good fit, with each position contributing 12 point pairs. When you have a good amount of point pairs, click the "calibrate" button. This will generate a calibration.

Once you have generated a calibration, you can toggle into "Testing mode" which allows you to test the fit. In testing mode, you can click anywhere on the Kinect image to place a red dot over a desired point in the camera image. A corresponding green point should then be projected onto that same location in your physical space. If the calibration is good, the red dot in the Kinect's image and the green one in the physical space should match. Try a few points at different locations to test the accuracy of the calibration.

If the calibration is satisfactory, click "Save." It will generate a text file containing the calibration parameters, which will be located in the path you specified in the calibFilename variable.

##Using the calibration

The core function of the library is the ability to map any 3d point in physical space to the corresponding pixel which falls on that point. The process goes as follows.

First, set up the Kinect and OpenCV. Make sure to run the Kinect's alternativeViewPointDepthToImage() so that the RGB and depth maps are aligned.

kinect = new SimpleOpenNI(this); 
kinect.enableDepth();
kinect.alternativeViewPointDepthToImage();
opencv = new OpenCV(this, kinect.depthWidth(), kinect.depthHeight());

Next, load your calibration file (replace CALIBRATION_PATH with the path to the calibration file saved from the process described above).

kpt = new KinectProjectorToolkit(this, kinect.depthWidth(), kinect.depthHeight());
kpt.loadCalibration(CALIBRATION_PATH);

In a frame, update the Kinect and then send its real world depth map to the KinectProjectorToolkit object.

kinect.update();  
kpc.setDepthMapRealWorld(kinect.depthMapRealWorld()); 

Then, given a point from the real world depth map, you can obtain its pixel coordinate by running the convertKinectToProjector() method. The point can be, for example, the real world point of a tracked skeleton's hand. Make sure you are sampling from depthMapRealWorld() not depthMap(). So given real world PVector realWorldPoint, the projected coordinate is accessible via:

PVector projectedPoint = kpt.convertKinectToProjector(realWorldPoint);

The toolkit has some higher level functions which automate some of this, depending on the specific task. For example, if you are tracking a skeleton and have an ArrayList of PVectors which correspond to a tracked object's contour points, you can convert all of them using the function getProjectedContour(ArrayList<PVector> contourPoints).

An optional second parameter "dilates" the projected contour, i.e. stretches or compresses it. For example, getProjectedContour(ArrayList<PVector> contourPoints, 2.0) will return a projected contour which has been stretched out to double its original dimensions; this can be useful, for example, in tracing a user's contour on the screen behind them. The default dilation is 1.0 (original size, no stretching).

The test applications in the library demonstrate some of these tasks.

##Test applications

The library contains a number of examples, prefixed "Test" which demonstrate various uses of the toolkit for creative projection. Demos include projecting an image onto a human body, projecting images onto specific tracked parts of a body, graphics projected onto background surfaces interacting with tracked bodies, etc.

You must first make sure to go through the calibration process and generate the calibration file. Before running any of the demos, you must change the location of the loaded calibration file to the calibration you generated in the first step, and modify the line in the example accordingly.

kpt.loadCalibration(YOUR_PATH_HERE);

Descriptions for test applications follow below:

###TestSkeleton, TestKrang, TestFireball These demos are the simplest applications of the calibration. The Kinect tracks users and returns real world coordinates for their joints and limbs, and we project objects onto them. Skeleton projects the entire skeleton onto each person, Krang projects an image of Krang onto users' torsos.

###TestBodyGraphics, TestBodyImage, TestBodyMovie, TestBodyShader Show the process of projecting graphics onto a tracked human body, via the Kinect's userImage. They are identical, except for the content of the graphics, showing how to project a PGraphics object, a PImage, a Movie, and a shader, respectively.

###TestRibbons Similar to the body projection examples, but instead projects ribbon-like lines around the contour of a body, tracing them onto the background behind the user.

###TestBackgroundFX This example shows how a tracked user can manipulate background graphics projected behind them onto a screen or floor.

###TestFallingPolygons Similar to TestBackgroundFX as it involves a user manipulating a background screen. A game in which polygons fall from the sky and a user can physically interact with them on a wall.

###RENDER This is a high-level application combining the previous examples with a user interface for applying the effects. It is currently still under development.

More Repositories

1

Processing-Shader-Examples

A collection of GLSL shaders and how to use them in Processing sketches
GLSL
246
star
2

p5js-osc

OSC for p5.js with examples
JavaScript
205
star
3

ofxTSNE

t-SNE dimensionality reduction technique for openFrameworks
C++
197
star
4

CubistMirror

an openframeworks app which repeatedly applies real-time style transfer on a webcam
C++
148
star
5

ofxKinectProjectorToolkit

openFrameworks addon for calibrating a Kinect to a projector for real-time projection mapping onto moving surfaces
C++
126
star
6

ofxLearn

General-purpose machine learning library for openFrameworks, supporting classification, regression, and clustering tasks
C++
98
star
7

ofxAbletonLive

addon for openFrameworks for controlling Ableton Live
C++
77
star
8

ofxLeapMotion2

A wrapper for the Leap Motion SDK compatible with Leap 2.0 Beta with skeletal tracking
C++
60
star
9

ofxKinectProjectorToolkitV2

openFrameworks addon for calibrating a KinectV2 to a projector for real-time projection mapping onto tracked spaces
C++
59
star
10

Kinect2Gesture

code for Blink performance project -- classification of KinectV2 dancer gestures/poses -> write Arduino code
C++
56
star
11

image-tSNE

example of t-SNE to fc7 activations of a convnet (keras + sklearn)
Python
52
star
12

text-learning

language + text generation + summarization using Keras and Sumy
Python
45
star
13

p5js-sketches

a collection of sketches for p5.js
JavaScript
44
star
14

AudioTSNE

audio sample t-SNE in Processing
Processing
41
star
15

ofxRunway

runway client for openframeworks (w.i.p.)
C++
36
star
16

wiki-tSNE

IPython notebook for clustering and visualizing documents using tf-idf analysis and t-SNE, example of Wikipedia articles
HTML
35
star
17

ofxScreenGrab

Screen capturing utility for OpenFrameworks, for recording your desktop to an ofTexture
C
34
star
18

audio-tSNE

analyze audio sample database with librosa, visualize with openframeworks
C++
34
star
19

ofxSecondWindow

[Deprecated] OpenFrameworks addon for creating and drawing to multiple separate windows
C++
33
star
20

ofxPwrrPoint

powerpoint replacement for openframeworks
C++
30
star
21

ofxSelfOrganizingMap

openFrameworks addon implementing a self-organizing map
C++
29
star
22

densecap-video

merging captions and generating videos from densecap frame sequences
Python
25
star
23

SeashellGenerator

Generative seashell mesh creation in Processing
Java
24
star
24

Auto-Photo-Mosaic

A Matlab framework for composing photo mosaics
C++
24
star
25

OF-tools

Tools and templates for OpenFrameworks
C++
24
star
26

LeapMotionOSC

application streaming LeapMotion data and derived statistics
C++
22
star
27

Mosaic

automatic generation of photo mosaics in openframeworks
C++
21
star
28

KinectOSC

Application which streams one Kinect user's skeleton coordinates over OSC
C++
20
star
29

p5js-sandbox

Online sandbox for p5.js with code editing, saving, and browsing
JavaScript
20
star
30

ofxaddons-bingo

simple mashups of openframeworks addons
C++
19
star
31

FlockingBoids

A fancy-ish implementation in Processing of Craig Reynold's Boids program, with camera control and 3d modeling of the boids
Processing
19
star
32

LeapMotion-SuperCollider-Instruments

A series of SuperCollider sound instruments controllable via LeapMotion hand tracker
SuperCollider
17
star
33

screengrab-caption

an openframeworks app that live-captions your desktop screen with a neural net
C
17
star
34

Bennington_GenerativeArt

course notes and code for Generative Art course DA2108 at Bennington College, fall semester 2015
JavaScript
15
star
35

ofxSequencer

sequencer addon for openframeworks which supports discrete or continuous cell values
C
14
star
36

wifi_geolocation

Get your latitude/longitude via wifi access points
Python
14
star
37

secret_face

Privately averaging everyone's faces together without sharing actual pictures
JavaScript
14
star
38

RobotShakespeare

A twitter bot which generates pseudo-Shakesperean prose every 30 minutes
Python
14
star
39

ofxTouchOsc

openframeworks addon for generating TouchOsc layouts
C
14
star
40

ofxProjectionMapping

simple projection mapping addon for openframeworks, sitting on top of ofxVideoMapping
C++
13
star
41

ofxControl

openframeworks addon for generating GUI, managing OSC, presets, and sequencers (W.I.P.)
C++
13
star
42

OF-tools-and-templates

a collection of high-level tools and templates for OpenFrameworks
C++
12
star
43

osc-modules

A collection of openFrameworks standalone apps for sending and receiving OSC between apps
C++
12
star
44

deepdream

w.i.p.
Jupyter Notebook
11
star
45

ReverseImageSearchRealTime

W.I.P. app for real-time reverse image search using a convnet, PCA, and KD-Tree (openframeworks)
C++
11
star
46

ofxKDTree

KDTree implementation for fast nearest-neighbor search on variable-sized points, based on nanoflann
C++
11
star
47

ofxSuperCollider

openframeworks addon for controlling SuperCollider via OSC
C
10
star
48

ofxConvexHull

openframeworks addon for calculating the 2d convex hull of an array of points
Makefile
9
star
49

course-ml4a

Jupyter Notebook
9
star
50

sfpc-code

code examples made in sfpc, fall 2015,
JavaScript
8
star
51

models

collection of submodules linking to model forks
8
star
52

KinectProjectorCalibration

R&D for KinectProjectorToolkit
Processing
7
star
53

ml4a-slides

presentation slides
C++
7
star
54

neural-art-tools

Python
6
star
55

ofxSpreadsheet

spreadsheet editor for openFrameworks
C
6
star
56

face_tracker

Runway Face Tracker (test example)
Python
6
star
57

Manta

applications for the Manta controller
C++
6
star
58

ofxDraggable

simple convenience class for draggable points (openframeworks)
C++
6
star
59

Visuals

openframeworks + raspberry pi
C++
5
star
60

ofxControlOSC

openFrameworks addon for generating layouts for the iOS/Android OSC-sending app Control
C++
5
star
61

Runway-FaceTracker

A face tracking model for Runway (example for SDK tutorial pt 2)
Python
5
star
62

genekogan.github.io

personal website + alt-AI
JavaScript
5
star
63

ml4a-ITP-s16

Code created for or in machine learning for artists class at ITP-NYU, spring 2016
Processing
4
star
64

fast_neural_style

Python
4
star
65

AndersonRanch-workshop

Processing sketches for workshop at Anderson Ranch
Processing
4
star
66

mapbox_dl

getting tiles from mapbox
Python
4
star
67

SuperCollider

tools for interfacing SuperCollider with OpenFrameworks
C++
4
star
68

ofxCanvas

simple drawing canvas with buttons/gui
C++
4
star
69

ofxGMM

openFrameworks addon for modeling a data distribution as a Gaussian mixture model
C
4
star
70

GPT3-FoxDot

GPT3 livecoding in FoxDot
Python
4
star
71

ofxPCA

openframeworks addon for principal component analysis, based on Eigen
C++
4
star
72

ofxOnscreenKeyboard

clickable touchscreen keyboard addon for openframeworks
C++
4
star
73

generative-geometry

generative geometry sketches in Processing using Hemesh library
Processing
3
star
74

MachineYearning

Projection mapping on ABB industrial robot arm, calibration via streaming joint angles, for use in Machine Yearning performance 4.23.2014
Processing
3
star
75

Parsons-Quad-C-workshops

code examples from Quad-C lectures at Parsons MFA-DT, 4/11 - 4/12
C
3
star
76

ml4a-workshop

ml4a-workshop materials
JavaScript
3
star
77

ofxClickable

Simple virtual (easily extendable) clickable button element for interfaces
C++
3
star
78

kurukshetra

code for creative coding class at kurukshetra festival, guindy college, chennai 2016
JavaScript
3
star
79

ofxSandboxTracker

CV application to track a sandbox and turn it into a label map image
C++
3
star
80

OF-Ableton-Osc

using LiveOSC for openFrameworks + Ableton Live communication, parameterization
C
3
star
81

ofxPointInPolyline

[obsolete] lightweight openframeworks addon for checking if a point lies inside a polygon
C++
3
star
82

ofxScrollableImage

addon to create a scrollable canvas with a large image in it, using a shader
C++
3
star
83

node-template

minimal node.js template with express and sockets.io with basic server-client two-way communication
JavaScript
2
star
84

LoggerOld

Personal electronic journal logging system in Python using SQLite and Alfred
Python
2
star
85

Birl

Training application for Birl, using ofxLearn and ofxUI.
C++
2
star
86

AudioUnitOSC

control AudioUnits (mac) via OSC
C
2
star
87

ofxHistogram

addon for getting the color histogram of an image in openframeworks
Makefile
2
star
88

of-templates

templates for openFrameworks wrapping common and uncommon routines for audio & video
C++
2
star
89

pix2pix-clients

C++
2
star
90

Tessellator

draw tessellations in Processing
Processing
2
star
91

PCA_demos

Two processing programs to visualize what dimensionality reduction means (for educational purposes)
Processing
2
star
92

ofxEMD

Earth mover's distance for openFrameworks
C++
1
star
93

syfter

Python
1
star
94

facecount

Python
1
star
95

ExquisiteShader

experiment in multi-player generativity. work in progress
GLSL
1
star
96

NabiMusic

doodles to music for nabi center install
Groovy
1
star
97

genekogan.com

homepage
HTML
1
star
98

ethblockart-p5-stars

JavaScript
1
star
99

deepdream_caffe

working with google's deepdream / inceptionism
Python
1
star
100

ofxManta

openFrameworks addon for interfacing with the Manta controller
C
1
star