Created
December 10, 2014 00:10
-
-
Save ThomasLengeling/fadad0fa2a7422833885 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.nio.FloatBuffer; | |
import KinectPV2.*; | |
import javax.media.opengl.GL2; | |
private KinectPV2 kinect; | |
float a = 0; | |
int zval = 50; | |
float scaleVal = 260; | |
float rotY = 0; | |
float rotZ = 0; | |
float rotX = PI; | |
float depthVal = 0; | |
PImage imgCol; | |
public void setup() { | |
size(1920, 1080, P3D); | |
kinect = new KinectPV2(this); | |
// kinect.enableDepthImg(true); | |
// kinect.enableColorImg(true); | |
kinect.enablePointCloudColor(true); | |
kinect.init(); | |
imgCol = createImage(1920, 1080, RGB); | |
} | |
public void draw() { | |
background(0); | |
FloatBuffer colorBuffer = kinect.getColorChannelBuffer(); | |
imgCol.loadPixels(); | |
for (int x = 0; x < kinect.WIDTHColor; x++) { | |
for (int y= 0; y < kinect.HEIGHTColor; y++) { | |
int index= x+y*kinect.WIDTHColor; | |
PVector col = getVal(x, y, colorBuffer); | |
color c = color( col.x*255, col.y*255, col.z*255); | |
imgCol.pixels[index] = c; | |
} | |
} | |
imgCol.updatePixels(); | |
image(imgCol, 0, 0); | |
image(kinect.getColorImage(), 0, 0, 320, 240); | |
text("fps: "+frameRate, 50, 50); | |
} | |
PVector getVal(int x, int y, FloatBuffer in) { | |
int index = (x+y*kinect.WIDTHColor)*3;//(int)map(mouseX,0,width,1,24); | |
return getVal(index, in); | |
} | |
PVector getVal(int index, FloatBuffer in) { | |
return new PVector(in.get(index + 0), in.get(index+1), in.get(index+2)); | |
} | |
color getCol(int index, FloatBuffer in) { | |
return (int)(in.get(index)*255); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment