Skip to content
This repository
Browse code

Added licence, fixed of007 set root issue, fixed ofxHardwareDriver de…

…fines
  • Loading branch information...
commit eef6e4e7663835ad859fd5cb7fc257eac52b478c 1 parent 851c8c3
Matthew Gingold authored
BIN  .DS_Store
Binary file not shown
40 src/ofxDepthGenerator.cpp 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxDepthGenerator.cpp
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #include "ofxDepthGenerator.h"
2 31 #include "ofxOpenNIMacros.h"
3 32
@@ -55,14 +84,7 @@ bool ofxDepthGenerator::setup(ofxOpenNIContext* pContext) {
55 84 // found the depth generator so set map_mode from it
56 85 depth_generator.GetMapOutputMode(map_mode);
57 86 } else {
58   - NodeInfoList depthsList;
59   - result = pContext->getXnContext().EnumerateProductionTrees(XN_NODE_TYPE_DEPTH, NULL, depthsList);
60   -
61   - // take first
62   - NodeInfo chosen = *depthsList.Begin();
63   -
64   - result = pContext->getXnContext().CreateProductionTree(chosen, depth_generator);
65   - //result = depth_generator.Create(pContext->getXnContext());
  87 + result = depth_generator.Create(pContext->getXnContext());
66 88 CHECK_RC(result, "Creating depth generator");
67 89
68 90 if (result != XN_STATUS_OK) return false;
@@ -118,7 +140,7 @@ void ofxDepthGenerator::setDepthColoring(enumDepthColoring c) {
118 140 }
119 141
120 142
121   -// returns mask pixels in a range (use updateMaskPixels and getDepthPixels(int forDepthThresholdNumber) for multiple masks as it's more efficient)
  143 +// returns mask pixels in a range TODO: make do multiple ranges
122 144 unsigned char* ofxDepthGenerator::getDepthPixels(int nearThreshold, int farThreshold) {
123 145
124 146 if (max_number_depths == 1) {
31 src/ofxDepthGenerator.h 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxDepthGenerator.h
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #ifndef _H_OFXDEPTHGENERATOR
2 31 #define _H_OFXDEPTHGENERATOR
3 32
@@ -22,8 +51,6 @@ typedef struct {
22 51 // this must be at least 1!
23 52 #define MAX_NUMBER_DEPTHS 4
24 53
25   -using namespace xn;
26   -
27 54 class ofxDepthGenerator {
28 55
29 56 public:
29 src/ofxGestureGenerator.cpp 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxGestureGenerator.cpp
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #include "ofxGestureGenerator.h"
2 31 #include "ofxOpenNIMacros.h"
3 32
29 src/ofxGestureGenerator.h 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxGestureGenerator.h
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #ifndef _H_OFXGESTUREGENERATOR
2 31 #define _H_OFXGESTUREGENERATOR
3 32
29 src/ofxHandGenerator.cpp 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxHandGenerator.cpp
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #include "ofxHandGenerator.h"
2 31 #include "ofxOpenNIMacros.h"
3 32 #include "ofxTrackedHand.h"
29 src/ofxHandGenerator.h 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxHandGenerator.h
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #ifndef _H_OFXHANDGENERATOR
2 31 #define _H_OFXHANDGENERATOR
3 32
40 src/ofxHardwareDriver.cpp 100644 → 100755
... ... @@ -1,5 +1,37 @@
  1 +/*
  2 + * ofxHardwareDriver.cpp
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
  30 +
1 31 #include "ofxHardwareDriver.h"
2 32
  33 +#if defined (TARGET_OSX)
  34 +
3 35 ofxHardwareDriver::ofxHardwareDriver() {
4 36 printf("Init lib_usb control of Kinect Motor, LEDs and accelerometers");
5 37 }
@@ -10,7 +42,7 @@ ofxHardwareDriver::~ofxHardwareDriver() {
10 42
11 43 void ofxHardwareDriver::setup(int index)
12 44 {
13   - libusb_context *ctx;
  45 + //libusb_context *ctx;
14 46 libusb_init(&ctx);
15 47 libusb_device **devs; //pointer to pointer of device, used to retrieve a list of devices
16 48 ssize_t cnt = libusb_get_device_list (ctx, &devs); //get the list of devices
@@ -135,5 +167,7 @@ void ofxHardwareDriver::shutDown() {
135 167 // strange behaviour if the kinect is tilted in between
136 168 // application starts eg., the angle continues to be set
137 169 // even when app not running...which is odd...
138   - libusb_exit(0);
139   -}
  170 + libusb_exit(ctx);
  171 +}
  172 +
  173 +#endif
38 src/ofxHardwareDriver.h 100644 → 100755
... ... @@ -1,8 +1,41 @@
  1 +/*
  2 + * ofxHardwareDriver.h
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
  30 +
1 31 #ifndef _H_OFXHARDWAREDRIVER
2 32 #define _H_OFXHARDWAREDRIVER
3 33
4   -// based on ROS kinect_aux.cpp driver and freenect tilt.c for controlling motor and accelerometers
5 34 #include "ofMain.h"
  35 +
  36 +#if defined (TARGET_OSX)
  37 +// based on ROS kinect_aux.cpp driver and freenect tilt.c for controlling motor and accelerometers
  38 +
6 39 #include <libusb.h>
7 40
8 41 // VID and PID for Kinect and motor/acc/leds
@@ -67,6 +100,8 @@ class ofxHardwareDriver {
67 100 int tilt_angle;
68 101
69 102 void shutDown();
  103 +
  104 + libusb_context *ctx;
70 105
71 106 private:
72 107
@@ -76,4 +111,5 @@ class ofxHardwareDriver {
76 111
77 112 };
78 113
  114 +#endif
79 115 #endif
40 src/ofxIRGenerator.cpp 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxIRGenerator.cpp
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #include "ofxIRGenerator.h"
2 31 #include "ofxOpenNIMacros.h"
3 32
@@ -12,15 +41,12 @@ void ofxIRGenerator::generateTexture() {
12 41
13 42 xn::IRMetaData ird;
14 43 ir_generator.GetMetaData(ird);
15   - const XnUInt8* pImage = (XnUInt8*)ird.Data();
  44 + const XnIRPixel* pImage = ird.Data();
16 45
17   - int j = 0;
18   -
19   - for (int i = 0; i < ird.XRes() * ird.YRes()*2; i+=2, j++) { // Don't ask me why ;-)
20   - ir_pixels[j] = pImage[i];
  46 + for (int i = 0; i < ird.XRes() * ird.YRes(); i++) {
  47 + ir_pixels[i] = pImage[i]/4;
21 48 }
22   -
23   - //memcpy(ir_pixels, pImage, sizeof(unsigned char) * ird.XRes() * ird.YRes());
  49 +
24 50 ir_texture.loadData(ir_pixels, ird.XRes(), ird.YRes(), GL_LUMINANCE);
25 51
26 52 }
29 src/ofxIRGenerator.h 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxIRGenerator.h
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #ifndef _H_OFXIRGENERATOR
2 31 #define _H_OFXIRGENERATOR
3 32
29 src/ofxImageGenerator.cpp 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxImageGenerator.cpp
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #include "ofxImageGenerator.h"
2 31 #include "ofxOpenNIMacros.h"
3 32
29 src/ofxImageGenerator.h 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxImageGenerator.h
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #ifndef _H_OFXIMAGEENERATOR
2 31 #define _H_OFXIMAGEENERATOR
3 32
29 src/ofxOpenNI.h 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxOpenNI.h
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #ifndef _H_OFXOPENNI
2 31 #define _H_OFXOPENNI
3 32
101 src/ofxOpenNIContext.cpp 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxOpenNIContext.cpp
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #include "ofxOpenNIContext.h"
2 31 #include "ofxDepthGenerator.h"
3 32 #include "ofxOpenNIMacros.h"
@@ -5,80 +34,17 @@
5 34 // Startup
6 35 //----------------------------------------
7 36 ofxOpenNIContext::ofxOpenNIContext() {
  37 + string path = ofToDataPath(""); // hack needed to set root path in 007 otherwise openNI isn't working!?!
8 38 is_using_recording = false;
9   - enableLogging();
10 39 }
11 40
12 41 // Just initialize; use this when you"re creating nodes yourself.
13 42 //----------------------------------------
14 43 bool ofxOpenNIContext::initContext(){
15 44 xn::EnumerationErrors errors;
16   - XnStatus nRetVal = context.Init();
17   - cout << xnGetStatusString(nRetVal) << endl;
18   - if(nRetVal != XN_STATUS_OK) logErrors(errors);
19   - CHECK_RC(nRetVal, "ofxOpenNIContext.setup()");
20   -
21   - // find devices
22   - NodeInfoList list;
23   - nRetVal = context.EnumerateProductionTrees(XN_NODE_TYPE_DEVICE, NULL, list, &errors);
24   - cout << xnGetStatusString(nRetVal) << endl;
25   - if(nRetVal != XN_STATUS_OK) logErrors(errors);
26   - XN_IS_STATUS_OK(nRetVal);
27   -
28   - printf("The following devices were found:\n");
29   - int i = 1;
30   - for (NodeInfoList::Iterator it = list.Begin(); it != list.End(); ++it, ++i)
31   - {
32   - NodeInfo deviceNodeInfo = *it;
33   -
34   - Device deviceNode;
35   - deviceNodeInfo.GetInstance(deviceNode);
36   - XnBool bExists = deviceNode.IsValid();
37   - if (!bExists)
38   - {
39   - context.CreateProductionTree(deviceNodeInfo, deviceNode);
40   - // this might fail.
41   - }
42   -
43   - if (deviceNode.IsValid() && deviceNode.IsCapabilitySupported(XN_CAPABILITY_DEVICE_IDENTIFICATION))
44   - {
45   - const XnUInt32 nStringBufferSize = 200;
46   - XnChar strDeviceName[nStringBufferSize];
47   - XnChar strSerialNumber[nStringBufferSize];
48   -
49   - XnUInt32 nLength = nStringBufferSize;
50   - deviceNode.GetIdentificationCap().GetDeviceName(strDeviceName, nLength);
51   - nLength = nStringBufferSize;
52   - deviceNode.GetIdentificationCap().GetSerialNumber(strSerialNumber, nLength);
53   - printf("[%d] %s (%s)\n", i, strDeviceName, strSerialNumber);
54   - }
55   - else
56   - {
57   - printf("[%d] %s\n", i, deviceNodeInfo.GetCreationInfo());
58   - }
59   -
60   - // release the device if we created it
61   - if (!bExists && deviceNode.IsValid())
62   - {
63   - deviceNode.Release();
64   - }
65   - }
66   - printf("\n");
67   - printf("Choose device to open (1): ");
68   -
69   - int chosen = 1;
70   - scanf("%d", &chosen);
71   -
72   - // create it
73   - NodeInfoList::Iterator it = list.Begin();
74   - for (i = 1; i < chosen; ++i)
75   - {
76   - it++;
77   - }
78   -
79   - NodeInfo deviceNode = *it;
80   - nRetVal = context.CreateProductionTree(deviceNode, g_Device);
81   - XN_IS_STATUS_OK(nRetVal);
  45 + XnStatus result = context.Init();
  46 + if(result != XN_STATUS_OK) logErrors(errors);
  47 + BOOL_RC(result, "ofxOpenNIContext.setup()");
82 48 }
83 49
84 50 // Initialize using an .ONI recording.
@@ -116,6 +82,7 @@ bool ofxOpenNIContext::setup() {
116 82
117 83 if (initContext()) {
118 84 addLicense("PrimeSense", "0KOIk2JeIBYClPWVnMoRKn5cdY4=");
  85 + enableLogging();
119 86 return true;
120 87 } else return false;
121 88
33 src/ofxOpenNIContext.h 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxOpenNIContext.h
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #ifndef _H_OFXOPENNICONTEXT
2 31 #define _H_OFXOPENNICONTEXT
3 32
@@ -7,8 +36,6 @@
7 36 #include <XnLog.h>
8 37 #include "ofMain.h"
9 38
10   -using namespace xn;
11   -
12 39 class ofxOpenNIContext {
13 40
14 41 public:
@@ -51,8 +78,6 @@ class ofxOpenNIContext {
51 78
52 79 bool is_using_recording;
53 80 xn::Context context;
54   -
55   - Device g_Device;
56 81
57 82 };
58 83
29 src/ofxOpenNIMacros.h 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxOpenNIMacros.h
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #define CHECK_RC(rc, what) \
2 31 if (rc != XN_STATUS_OK) \
3 32 { \
29 src/ofxOpenNIRecorder.cpp 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxOpenNIRecorder.cpp
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #include "ofxOpenNIRecorder.h"
2 31
3 32 // Frame sync is currently not possible with Kinect cameras!!
29 src/ofxOpenNIRecorder.h 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxOpenNIRecorder.h
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #ifndef _H_OFXOPENNIRECORDER
2 31 #define _H_OFXOPENNIRECORDER
3 32
29 src/ofxTrackedHand.cpp 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxTrackedHand.cpp
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #include "ofxTrackedHand.h"
2 31
3 32 //--------------------------------------------------------------
29 src/ofxTrackedHand.h 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxTrackedHand.h
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #ifndef _H_OFXTRACKEDHAND
2 31 #define _H_OFXTRACKEDHAND
3 32
43 src/ofxTrackedUser.cpp 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxTrackedUser.cpp
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #include "ofxTrackedUser.h"
2 31
3 32 ofxTrackedUser::ofxTrackedUser(ofxOpenNIContext* pContext)
@@ -88,10 +117,14 @@ void ofxTrackedUser::updateLimb(ofxLimb& rLimb) {
88 117
89 118 }
90 119
91   -void ofxTrackedUser::debugDraw() {
92   -
93   - neck.debugDraw();
  120 +void ofxTrackedUser::debugDraw(const float wScale, const float hScale) {
94 121
  122 + glPushMatrix();
  123 +
  124 + glScalef(wScale, hScale, 1);
  125 +
  126 + neck.debugDraw();
  127 +
95 128 // left arm + shoulder
96 129 left_shoulder.debugDraw();
97 130 left_upper_arm.debugDraw();
@@ -117,6 +150,8 @@ void ofxTrackedUser::debugDraw() {
117 150 right_lower_leg.debugDraw();
118 151
119 152 hip.debugDraw();
  153 +
  154 + ofDrawBitmapString(ofToString((int)id), neck.position[0].X + 10, neck.position[0].Y);
120 155
121   - ofDrawBitmapString(ofToString((int)id), neck.position[0].X + 10, neck.position[0].Y);
  156 + glPopMatrix();
122 157 }
35 src/ofxTrackedUser.h 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxTrackedUser.h
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #ifndef _H_OFXTRACKEDUSER
2 31 #define _H_OFXTRACKEDUSER
3 32
@@ -44,7 +73,7 @@ class ofxOpenNIContext;
44 73 class ofxTrackedUser {
45 74 public:
46 75
47   - void debugDraw();
  76 + void debugDraw(const float wScale=1.0f, const float hScale=1.0f);
48 77
49 78 ofxLimb neck;
50 79
@@ -75,7 +104,9 @@ class ofxTrackedUser {
75 104 ofxLimb hip;
76 105 XnUserID id;
77 106
78   -
  107 + bool skeletonTracking, skeletonCalibrating, skeletonCalibrated;
  108 + XnPoint3D center;
  109 +
79 110 private:
80 111
81 112 ofxTrackedUser(ofxOpenNIContext* pContext);
45 src/ofxUserGenerator.cpp 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxUserGenerator.cpp
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #include "ofxUserGenerator.h"
2 31 #include "ofxOpenNIMacros.h"
3 32 #include "ofxTrackedUser.h"
@@ -134,7 +163,8 @@ bool ofxUserGenerator::setup( ofxOpenNIContext* pContext) {
134 163 useMaskPixels = false;
135 164
136 165 // setup mask pixels array TODO: clean this up on closing or dtor
137   - for (int user = 0; user < MAX_NUMBER_USERS; user++) {
  166 + //including 0 as all users
  167 + for (int user = 0; user <= MAX_NUMBER_USERS; user++) {
138 168 maskPixels[user] = new unsigned char[width * height];
139 169 }
140 170
@@ -142,7 +172,8 @@ bool ofxUserGenerator::setup( ofxOpenNIContext* pContext) {
142 172 useCloudPoints = false;
143 173
144 174 // setup cloud points array TODO: clean this up on closing or dtor
145   - for (int user = 0; user < MAX_NUMBER_USERS; user++) {
  175 + //including 0 as all users
  176 + for (int user = 0; user <= MAX_NUMBER_USERS; user++) {
146 177 cloudPoints[user] = new ofPoint[width * height];
147 178 cloudColors[user] = new ofColor[width * height];
148 179 }
@@ -282,7 +313,11 @@ void ofxUserGenerator::update() {
282 313 for(int i = 0; i < found_users; ++i) {
283 314 if(user_generator.GetSkeletonCap().IsTracking(users[i])) {
284 315 tracked_users[i]->id = users[i];
285   - tracked_users[i]->updateBonePositions();
  316 + user_generator.GetCoM(users[i], tracked_users[i]->center);
  317 + tracked_users[i]->skeletonTracking = user_generator.GetSkeletonCap().IsTracking(users[i]);
  318 + tracked_users[i]->skeletonCalibrating = user_generator.GetSkeletonCap().IsCalibrating(users[i]);
  319 + tracked_users[i]->skeletonCalibrated = user_generator.GetSkeletonCap().IsCalibrated(users[i]);
  320 + if(tracked_users[i]->skeletonTracking) tracked_users[i]->updateBonePositions();
286 321 }
287 322 }
288 323
@@ -409,13 +444,13 @@ void ofxUserGenerator::updateCloudPoints() {
409 444
410 445 ofPoint ofxUserGenerator::getWorldCoordinateAt(int x, int y, int userID) {
411 446
412   - return cloudPoints[userID][y * height + x];
  447 + return cloudPoints[userID][y * width + x];
413 448
414 449 }
415 450
416 451 ofColor ofxUserGenerator::getWorldColorAt(int x, int y, int userID) {
417 452
418   - return cloudColors[userID][y * height + x];
  453 + return cloudColors[userID][y * width + x];
419 454
420 455 }
421 456
35 src/ofxUserGenerator.h 100644 → 100755
... ... @@ -1,3 +1,32 @@
  1 +/*
  2 + * ofxUserGenerator.h
  3 + *
  4 + * Copyright 2011 (c) Matthew Gingold http://gingold.com.au
  5 + * Originally forked from a project by roxlu http://www.roxlu.com/
  6 + *
  7 + * Permission is hereby granted, free of charge, to any person
  8 + * obtaining a copy of this software and associated documentation
  9 + * files (the "Software"), to deal in the Software without
  10 + * restriction, including without limitation the rights to use,
  11 + * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 + * copies of the Software, and to permit persons to whom the
  13 + * Software is furnished to do so, subject to the following
  14 + * conditions:
  15 + *
  16 + * The above copyright notice and this permission notice shall be
  17 + * included in all copies or substantial portions of the Software.
  18 + *
  19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 + * OTHER DEALINGS IN THE SOFTWARE.
  27 + *
  28 + */
  29 +
1 30 #ifndef _H_OFXUSERGENERATOR
2 31 #define _H_OFXUSERGENERATOR
3 32
@@ -65,9 +94,9 @@ class ofxUserGenerator {
65 94
66 95 // vars for cloud point and masking
67 96 XnUInt16 width, height;
68   - unsigned char * maskPixels[MAX_NUMBER_USERS];
69   - ofPoint * cloudPoints[MAX_NUMBER_USERS];
70   - ofColor * cloudColors[MAX_NUMBER_USERS];
  97 + unsigned char * maskPixels[MAX_NUMBER_USERS+1];//including 0 as all users
  98 + ofPoint * cloudPoints[MAX_NUMBER_USERS+1];//including 0 as all users
  99 + ofColor * cloudColors[MAX_NUMBER_USERS+1];//including 0 as all users
71 100 bool useMaskPixels, useCloudPoints;
72 101
73 102 float smoothing_factor;

0 comments on commit eef6e4e

Please sign in to comment.
Something went wrong with that request. Please try again.