133 |
134 |
135 |
136 |
--------------------------------------------------------------------------------
/KinectPV2/reference/package-list:
--------------------------------------------------------------------------------
1 | KinectPV2
2 |
--------------------------------------------------------------------------------
/KinectPV2/reference/resources/background.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ThomasLengeling/KinectPV2/3bda24ba8b7c62155bf308c0d86c961ca89dbfa3/KinectPV2/reference/resources/background.gif
--------------------------------------------------------------------------------
/KinectPV2/reference/resources/tab.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ThomasLengeling/KinectPV2/3bda24ba8b7c62155bf308c0d86c961ca89dbfa3/KinectPV2/reference/resources/tab.gif
--------------------------------------------------------------------------------
/KinectPV2/reference/resources/titlebar.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ThomasLengeling/KinectPV2/3bda24ba8b7c62155bf308c0d86c961ca89dbfa3/KinectPV2/reference/resources/titlebar.gif
--------------------------------------------------------------------------------
/KinectPV2/reference/resources/titlebar_end.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ThomasLengeling/KinectPV2/3bda24ba8b7c62155bf308c0d86c961ca89dbfa3/KinectPV2/reference/resources/titlebar_end.gif
--------------------------------------------------------------------------------
/KinectPV2/reference/script.js:
--------------------------------------------------------------------------------
1 | function show(type)
2 | {
3 | count = 0;
4 | for (var key in methods) {
5 | var row = document.getElementById(key);
6 | if ((methods[key] & type) != 0) {
7 | row.style.display = '';
8 | row.className = (count++ % 2) ? rowColor : altColor;
9 | }
10 | else
11 | row.style.display = 'none';
12 | }
13 | updateTabs(type);
14 | }
15 |
16 | function updateTabs(type)
17 | {
18 | for (var value in tabs) {
19 | var sNode = document.getElementById(tabs[value][0]);
20 | var spanNode = sNode.firstChild;
21 | if (value == type) {
22 | sNode.className = activeTableTab;
23 | spanNode.innerHTML = tabs[value][1];
24 | }
25 | else {
26 | sNode.className = tableTab;
27 | spanNode.innerHTML = "" + tabs[value][1] + "";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/KinectPV2/src/KinectPV2/Constants.java:
--------------------------------------------------------------------------------
1 | package KinectPV2;
2 |
3 | /*
4 | Copyright (C) 2014 Thomas Sanchez Lengeling.
5 | KinectPV2, Kinect for Windows v2 library for processing
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | */
25 |
26 | /**
27 | * Common variables for all the classes.
28 | * @author Thomas Sanchez Lengeling
29 | *
30 | */
31 | public interface Constants {
32 |
33 | public final static int BODY_COUNT = 6;
34 |
35 | public final static int WIDTHColor = 1920;
36 | public final static int HEIGHTColor = 1080;
37 |
38 | public final static int WIDTHDepth = 512;
39 | public final static int HEIGHTDepth = 424;
40 |
41 | public final static int Int32 = 0;
42 | public final static int Float = 1;
43 | }
44 |
--------------------------------------------------------------------------------
/KinectPV2/src/KinectPV2/FaceFeatures.java:
--------------------------------------------------------------------------------
1 | package KinectPV2;
2 |
3 | /*
4 | Copyright (C) 2014 Thomas Sanchez Lengeling.
5 | KinectPV2, Kinect for Windows v2 library for processing
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | */
25 |
26 | /**
27 | * Face Features class, with type Feature and State.
28 | * @author Thomas Sanchez Lengeling
29 | *
30 | */
31 | public class FaceFeatures {
32 |
33 | int feature;
34 | int state;
35 |
36 | /**
37 | * Create Feature
38 | * @param feature
39 | * @param state
40 | */
41 | FaceFeatures(int feature, int state){
42 | this.feature = feature;
43 | this.state = state;
44 | }
45 |
46 | /**
47 | * Set Feature
48 | * @param feature
49 | */
50 | public void setFeatureType(int feature){
51 | this.feature = feature;
52 | }
53 |
54 | /**
55 | * Set State
56 | * @param state
57 | */
58 | public void setState(int state){
59 | this.state = state;
60 | }
61 |
62 |
63 | /**
64 | * Get State
65 | * @return
66 | */
67 | public int getState(){
68 | return state;
69 | }
70 |
71 | /**
72 | * Get Feature Type
73 | * @return
74 | */
75 | public int getFeatureType(){
76 | return feature;
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/KinectPV2/src/KinectPV2/FaceProperties.java:
--------------------------------------------------------------------------------
1 | package KinectPV2;
2 |
3 | /*
4 | Copyright (C) 2014 Thomas Sanchez Lengeling.
5 | KinectPV2, Kinect for Windows v2 library for processing
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | */
25 |
26 | /**
27 | * Commun Face Properties
28 | * @author Thomas Sanchez Lengeling
29 | *
30 | */
31 | public interface FaceProperties extends Constants {
32 | public final static int FaceProperty_Happy = 0;
33 | public final static int FaceProperty_Engaged = 1;
34 | public final static int FaceProperty_LeftEyeClosed = 2;
35 | public final static int FaceProperty_RightEyeClosed = 3;
36 | public final static int FaceProperty_LookingAway = 4;
37 | public final static int FaceProperty_MouthMoved = 5;
38 | public final static int FaceProperty_MouthOpen = 6;
39 | public final static int FaceProperty_WearingGlasses = 7;
40 | public final static int Activity_Count = ( FaceProperty_WearingGlasses + 1 );
41 |
42 | public final static int FACESIZE = BODY_COUNT * (36);
43 |
44 | public final static int DetectionResult_Unknown = -1;
45 | public final static int DetectionResult_Yes = 1;
46 | public final static int DetectionResult_No = 0;
47 | public final static int DetectionResult_Maybe =2;
48 |
49 | public final static int Face_LeftEye = 0;
50 | public final static int Face_RightEye = 1;
51 | public final static int Face_Nose = 2;
52 | public final static int Face_LeftMouth = 3;
53 | public final static int Face_RightMouth = 4;
54 |
55 | public final static int HDFaceVertexCount = 1347;
56 |
57 | //6 MORE POINT FOR TRACKING AND NOT TRAKING
58 | public final static int HDFaceVertexPoints = HDFaceVertexCount * BODY_COUNT * 2 + BODY_COUNT;
59 |
60 | }
--------------------------------------------------------------------------------
/KinectPV2/src/KinectPV2/HDFaceData.java:
--------------------------------------------------------------------------------
1 | package KinectPV2;
2 |
3 | import processing.core.PVector;
4 |
5 | /*
6 | Copyright (C) 2014 Thomas Sanchez Lengeling.
7 | KinectPV2, Kinect for Windows v2 library for processing
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | */
27 |
28 | /**
29 | * Face Features class, with type Feature and State.
30 | * @author Thomas Sanchez Lengeling
31 | *
32 | */
33 | public class HDFaceData implements FaceProperties{
34 |
35 | PVector [] HDFaceVertex;
36 | boolean faceTracked;
37 |
38 | HDFaceData(){
39 | HDFaceVertex = new PVector[ HDFaceVertexCount];
40 | for(int i = 0; i < HDFaceVertexCount; i++)
41 | HDFaceVertex[i] = new PVector(0, 0);
42 | }
43 |
44 | protected void createHDFaceVertexData(float [] rawData, int iFace){
45 | int index = HDFaceVertexCount * 2;
46 |
47 | if(rawData[BODY_COUNT * HDFaceVertexCount * 2 + iFace] == 1)
48 | faceTracked = true;
49 | else
50 | faceTracked = false;
51 | for(int i = 0; i < HDFaceVertexCount; i++) {
52 | HDFaceVertex[i].x = rawData[index * iFace + i * 2 + 0];
53 | HDFaceVertex[i].y = rawData[index * iFace + i * 2 + 1];
54 | }
55 | }
56 |
57 | public PVector [] getHDFaceVertex(){
58 | return HDFaceVertex;
59 | }
60 |
61 | public boolean isTracked() {
62 | return faceTracked;
63 | }
64 |
65 | public float getX(int index) {
66 | return HDFaceVertex[index].x;
67 | }
68 |
69 | public float getY(int index) {
70 | return HDFaceVertex[index].y;
71 | }
72 |
73 | public PVector getPVector(int index) {
74 | return HDFaceVertex[index];
75 | }
76 |
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/KinectPV2/src/KinectPV2/Image.java:
--------------------------------------------------------------------------------
1 | package KinectPV2;
2 |
3 | /*
4 | Copyright (C) 2014 Thomas Sanchez Lengeling.
5 | KinectPV2, Kinect for Windows v2 library for processing
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | */
25 |
26 | import processing.core.PApplet;
27 | import processing.core.PImage;
28 |
29 | /**
30 | * Image class helper
31 | * @author Thomas Sanchez Lengeling
32 | *
33 | */
34 | public class Image{
35 | private float fps;
36 | private int imgPixelSize;
37 | private PApplet parent;
38 |
39 | protected PImage img;
40 | private boolean processRawData;
41 |
42 | protected byte [] rawByteData;
43 |
44 | protected float [] rawFloatData;
45 | protected int [] rawIntData;
46 |
47 | public Image(PApplet p, int width, int height, int MODE){
48 | parent = p;
49 | img = parent.createImage(width, height, MODE);
50 | imgPixelSize = width * height;
51 | rawByteData = new byte[imgPixelSize];
52 |
53 | rawIntData = new int[imgPixelSize];
54 | rawFloatData = new float[imgPixelSize];
55 | processRawData= false;
56 | }
57 |
58 | /**
59 | * Get Image Size in int
60 | * @return int
61 | */
62 | public int getImgSize(){
63 | return imgPixelSize;
64 | }
65 |
66 | /**
67 | * update Pixels, img.updatePixels()
68 | */
69 | public void updatePixels(){
70 | img.updatePixels();
71 | }
72 |
73 | /**
74 | * load Pixels, img.loadPixels()
75 | */
76 | public void loadPixels(){
77 | img.loadPixels();
78 | }
79 |
80 | /**
81 | * get Pixels Image, img.pixels
82 | * @return int []
83 | */
84 | public int [] pixels(){
85 | return img.pixels;
86 | }
87 |
88 | /**
89 | * get Image
90 | * @return PImage
91 | */
92 | public PImage getImage() {
93 | return img;
94 | }
95 |
96 | /**
97 | * get Fps of the current Image
98 | * @return float
99 | */
100 | public float getFPS() {
101 | return fps;
102 | }
103 |
104 | /**
105 | * Process Raw Data
106 | * @return boolean
107 | */
108 | public boolean isProcessRawData(){
109 | return processRawData;
110 | }
111 |
112 | /**
113 | * Activate Process Rae Data
114 | * @param rawData
115 | */
116 | public void activateRawData(boolean rawData){
117 | processRawData = rawData;
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/KinectPV2/src/KinectPV2/KJoint.java:
--------------------------------------------------------------------------------
1 | package KinectPV2;
2 | import processing.core.PVector;
3 |
4 | /*
5 | Copyright (C) 2014 Thomas Sanchez Lengeling.
6 | KinectPV2, Kinect for Windows v2 library for processing
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy
9 | of this software and associated documentation files (the "Software"), to deal
10 | in the Software without restriction, including without limitation the rights
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the Software is
13 | furnished to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in
16 | all copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | THE SOFTWARE.
25 | */
26 |
27 | /**
28 | * Simple Joint Class with (x, y, z) position, Orientation, state and type
29 | * @author thomas
30 | *
31 | */
32 | public class KJoint {
33 |
34 | protected PVector pos;
35 |
36 | protected int state;
37 |
38 | protected int type;
39 |
40 | protected KQuaternion orientation;
41 |
42 |
43 |
44 | KJoint(float x, float y, float z, KQuaternion ori, int state){
45 | pos = new PVector(x, y, z);
46 | orientation = ori;
47 | this.state = state;
48 | }
49 |
50 | KJoint(){}
51 |
52 | /**
53 | * Get orientation of a single Joint
54 | * @return Quartenion
55 | */
56 | public KQuaternion getOrientation() {
57 | return orientation;
58 | }
59 |
60 | /**
61 | * get PVector Position
62 | * @return
63 | */
64 | public PVector getPosition(){
65 | return pos;
66 | }
67 | /**
68 | * get X position
69 | * @return float x
70 | */
71 | public float getX(){
72 | return pos.x;
73 | }
74 |
75 | /**
76 | * get Y position
77 | * @return float y
78 | */
79 | public float getY(){
80 | return pos.y;
81 | }
82 |
83 | /**
84 | * get Z position
85 | * @return float z
86 | */
87 | public float getZ(){
88 | return pos.z;
89 | }
90 |
91 | /**
92 | * get State of a single Joint
93 | * @return state
94 | */
95 | public int getState(){
96 | return state;
97 | }
98 |
99 | /**
100 | * get Joint Type
101 | * @return int
102 | */
103 | public int getType(){
104 | return type;
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/KinectPV2/src/KinectPV2/KQuaternion.java:
--------------------------------------------------------------------------------
1 | package KinectPV2;
2 |
3 | import processing.core.PVector;
4 |
5 | /*
6 | Copyright (C) 2014 Thomas Sanchez Lengeling.
7 | KinectPV2, Kinect for Windows v2 library for processing
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | */
27 |
28 | /**
29 | * Simple KQuartenion class
30 | * @author Thomas Sanchez Lengeling
31 | *
32 | */
33 | public class KQuaternion {
34 |
35 | float x;
36 | float y;
37 | float z;
38 |
39 | float w;
40 |
41 | KQuaternion(float w, float x, float y, float z){
42 | this.x = x;
43 | this.y = y;
44 | this.z = z;
45 | this.w = w;
46 | }
47 |
48 | KQuaternion(){
49 | this.x = 0;
50 | this.y = 0;
51 | this.z = 0;
52 | this.w = 0;
53 | }
54 |
55 |
56 | public PVector rotate(float x1, float y1, float z1)
57 | {
58 | KQuaternion q = new KQuaternion(0.0f, x1, y1, z1);
59 | KQuaternion r = mult(new KQuaternion(w, x, y, z), q);
60 | KQuaternion conj = Conj();
61 | KQuaternion retult = mult(r, conj);
62 | return new PVector( retult.x, retult.y, retult.z);
63 | }
64 |
65 | public KQuaternion Conj()
66 | {
67 | return new KQuaternion(w, -x, -y, -z);
68 | }
69 |
70 | public KQuaternion mult(KQuaternion q1, KQuaternion q2)
71 | {
72 | return new KQuaternion(q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z
73 | , q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y
74 | , q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z
75 | , q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x);
76 | }
77 |
78 | public float getX(){
79 | return x;
80 | }
81 |
82 | public float getY(){
83 | return y;
84 | }
85 |
86 | public float getZ(){
87 | return z;
88 | }
89 |
90 | public float getW(){
91 | return w;
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/KinectPV2/src/KinectPV2/KRectangle.java:
--------------------------------------------------------------------------------
1 | package KinectPV2;
2 |
3 | /*
4 | Copyright (C) 2014 Thomas Sanchez Lengeling.
5 | KinectPV2, Kinect for Windows v2 library for processing
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | */
25 |
26 | /**
27 | * Simple KRectangle class
28 | * @author Thomas Sanchez Lengeling
29 | *
30 | */
31 | public class KRectangle {
32 |
33 | float x;
34 | float y;
35 |
36 | float width;
37 | float height;
38 |
39 |
40 | KRectangle(float x, float y, float width, float height){
41 | this.x = x;
42 | this.y = y;
43 | this.width = width;
44 | this.height = height;
45 | }
46 |
47 | public void setX(float x){
48 | this.x =x;
49 | }
50 |
51 | public void setY(float y){
52 | this.y =y;
53 | }
54 |
55 | public void setWidth(float w){
56 | this.width =w;
57 | }
58 |
59 | public void setHeight(float height){
60 | this.height = height;
61 | }
62 |
63 | public float getX(){
64 | return x;
65 | }
66 |
67 | public float getY(){
68 | return y;
69 | }
70 |
71 | public float getWidth(){
72 | return width;
73 | }
74 |
75 | public float getHeight(){
76 | return height;
77 | }
78 |
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/KinectPV2/src/KinectPV2/KinectPV2.java:
--------------------------------------------------------------------------------
1 | package KinectPV2;
2 |
3 | import processing.core.PApplet;
4 |
5 | /*
6 | Copyright (C) 2014 Thomas Sanchez Lengeling.
7 | KinectPV2, Kinect for Windows v2 library for processing
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | */
27 |
28 | /**
29 | *
30 | * @author Thomas Sanchez Lengeling
31 | *
32 | */
33 | public class KinectPV2 extends Device{
34 |
35 | public static PApplet parent;
36 |
37 | public KinectPV2(PApplet _p) {
38 | super(_p);
39 | parent = _p;
40 |
41 | parent.registerMethod("dispose", this);
42 | }
43 |
44 | public void init(){
45 | initDevice();
46 | runningKinect = true;
47 | }
48 |
49 | public void dispose() {
50 | System.out.println("EXIT");
51 | runningKinect = false;
52 | stopDevice();
53 | cleanDevice();
54 | }
55 |
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/KinectPV2/src/KinectPV2/Skeleton.java:
--------------------------------------------------------------------------------
1 | package KinectPV2;
2 |
3 | /*
4 | Copyright (C) 2014 Thomas Sanchez Lengeling.
5 | KinectPV2, Kinect for Windows v2 library for processing
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | */
25 |
26 | /**
27 | * Skeleton Class
28 | * @author Thomas Sanchez Lengeling
29 | *
30 | */
31 | public class Skeleton implements SkeletonProperties{
32 |
33 |
34 | protected KJoint [] kJoints;
35 |
36 | protected int leftHandState;
37 | protected int rightHandState;
38 |
39 | private boolean tracked;
40 |
41 | Skeleton(){
42 | kJoints = new KJoint[JointType_Count + 1];
43 | for(int i = 0; i < JointType_Count + 1; i++){
44 | kJoints[i] = new KJoint(0,0,0, new KQuaternion(), 0);
45 | }
46 | }
47 |
48 | /*
49 | * if the current skeleton is being tracked
50 | */
51 | public boolean isTracked(){
52 | return tracked;
53 | }
54 |
55 | /**
56 | * get the array of joints of the skeleton
57 | * @return KJoint []
58 | */
59 | public KJoint [] getJoints(){
60 | return kJoints;
61 | }
62 |
63 | /**
64 | * get Left Hand State of the skeleton
65 | * @return int leftHandState
66 | */
67 | public int getLeftHandState(){
68 | return leftHandState;
69 | }
70 |
71 | /**
72 | * get Right Hand State of the skeleton
73 | * @return int rightHandState
74 | */
75 | public int getRightHandState(){
76 | return rightHandState;
77 | }
78 |
79 | protected void createSkeletonData(float [] rawData, int i){
80 | int index2 = i * (JointType_Count+1) * 9;
81 | int indexJoint = index2 + (JointType_Count+1) * 9 - 1;
82 | if(rawData[indexJoint] == 1.0){
83 | tracked = true;
84 | }else{
85 | tracked = false;
86 | }
87 |
88 | if(tracked){
89 | for(int j = 0; j < JointType_Count; ++j){
90 | int index1 = j * 9;
91 | kJoints[j].pos.x = rawData[index2 + index1 + 0];
92 | kJoints[j].pos.y = rawData[index2 + index1 + 1];
93 | kJoints[j].pos.z = rawData[index2 + index1 + 2];
94 |
95 | kJoints[j].orientation.w = rawData[index2 + index1 + 3];
96 | kJoints[j].orientation.x = rawData[index2 + index1 + 4];
97 | kJoints[j].orientation.y = rawData[index2 + index1 + 5];
98 | kJoints[j].orientation.z = rawData[index2 + index1 + 6];
99 |
100 | int state = (int)rawData[index2 + index1 + 7];
101 | int type = (int)rawData[index2 + index1 + 8];
102 |
103 | kJoints[j].state = state;
104 | kJoints[j].type = type;
105 | if(type == JointType_HandLeft)
106 | leftHandState = state;
107 | if(type == JointType_HandRight)
108 | rightHandState = state;
109 | }
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/KinectPV2/src/KinectPV2/SkeletonProperties.java:
--------------------------------------------------------------------------------
1 | package KinectPV2;
2 |
3 | /*
4 | Copyright (C) 2014 Thomas Sanchez Lengeling.
5 | KinectPV2, Kinect for Windows v2 library for processing
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | */
25 |
26 | /**
27 | * Skeleton Properties
28 | * @author Thomas Sanchez Lengeling
29 | *
30 | */
31 | public interface SkeletonProperties extends Constants{
32 | public final static int JointType_SpineBase = 0;
33 | public final static int JointType_SpineMid = 1;
34 | public final static int JointType_Neck = 2;
35 | public final static int JointType_Head = 3;
36 | public final static int JointType_ShoulderLeft = 4;
37 | public final static int JointType_ElbowLeft = 5;
38 | public final static int JointType_WristLeft = 6;
39 | public final static int JointType_HandLeft = 7;
40 | public final static int JointType_ShoulderRight = 8;
41 | public final static int JointType_ElbowRight = 9;
42 | public final static int JointType_WristRight = 10;
43 | public final static int JointType_HandRight = 11;
44 | public final static int JointType_HipLeft = 12;
45 | public final static int JointType_KneeLeft = 13;
46 | public final static int JointType_AnkleLeft = 14;
47 | public final static int JointType_FootLeft = 15;
48 | public final static int JointType_HipRight = 16;
49 | public final static int JointType_KneeRight = 17;
50 | public final static int JointType_AnkleRight = 18;
51 | public final static int JointType_FootRight = 19;
52 | public final static int JointType_SpineShoulder = 20;
53 | public final static int JointType_HandTipLeft = 21;
54 | public final static int JointType_ThumbLeft = 22;
55 | public final static int JointType_HandTipRight = 23;
56 | public final static int JointType_ThumbRight = 24;
57 | public final static int JointType_Count = ( JointType_ThumbRight + 1 );
58 |
59 | public final static int JOINTSIZE = BODY_COUNT * (JointType_Count + 1) * 9;
60 |
61 | public final static int TrackingState_NotTracked = 0;
62 | public final static int TrackingState_Inferred = 1;
63 | public final static int TrackingState_Tracked = 2;
64 |
65 |
66 | public final static int HandState_Unknown = 0;
67 | public final static int HandState_NotTracked = 1;
68 | public final static int HandState_Open = 2;
69 | public final static int HandState_Closed = 3;
70 | public final static int HandState_Lasso = 4;
71 | }
72 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Thomas Sanchez Lengeling
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------