From fa43303ae73e1db3a33436cc1fc5e2fa7dcb68c5 Mon Sep 17 00:00:00 2001 From: Philipp Kramer Date: Wed, 11 Sep 2019 16:31:53 +0200 Subject: [PATCH] working kinect to box implementation --- kinectv1_wuerfel.pde | 408 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 408 insertions(+) create mode 100644 kinectv1_wuerfel.pde diff --git a/kinectv1_wuerfel.pde b/kinectv1_wuerfel.pde new file mode 100644 index 0000000..4c33edf --- /dev/null +++ b/kinectv1_wuerfel.pde @@ -0,0 +1,408 @@ +import org.openkinect.freenect.*; +import org.openkinect.processing.*; +import processing.serial.*; + +//zadig 2.0.1 libusbK https://zadig.akeo.ie/downloads/ + +Serial sPort; + +Kinect kinect; + +// Depth image +PImage depthImg; +PImage depthImgRaw; +PImage videoImg; + +public enum Mode +{ + DEPTHCOLOR, NEARESTIMAGECOLOR +} + +Mode mode=Mode.DEPTHCOLOR; + +boolean leftview_depth=true; +boolean enable_mirrorImage=true; +boolean enable_IRImage=false; +boolean enable_colordepth=false; + +// Which pixels do we care about? +int minDepth = 200; +int maxDepth = 1000; + +// What is the kinect's angle +float angle; + +static int boxnum=19; +color box[] = new color[boxnum]; +int boxid[] = new int[boxnum]; +PVector boxpos[] = new PVector[boxnum]; //center position of box +PVector boxsize[] = new PVector[boxnum]; //size of box (width,height) +boolean boxenabled[] = new boolean[boxnum]; +float[] depthLookUp = new float[2048]; + +static int FRAMERATE=10; +int fadetime=1000/FRAMERATE /10; //fadetime in centiseconds + +int editbox=0; //num of box +boolean editboxpos=false; //editmode + +int infomessagecounter=0; //counts every frame +String infomessage=""; + + +void setup() { + size(1280, 480); + frameRate(FRAMERATE); + + colorMode(HSB, 255); + + kinect = new Kinect(this); + kinect.initDepth(); + kinect.initVideo(); + + kinect.enableMirror(enable_mirrorImage); + kinect.enableIR(enable_IRImage); + kinect.enableColorDepth(enable_colordepth); + angle = kinect.getTilt(); + + + // Blank image + depthImgRaw = new PImage(kinect.width, kinect.height); + depthImg = new PImage(kinect.width, kinect.height); + + for (int i=0;i