├── Kinector
├── en.lproj
│ ├── InfoPlist.strings
│ └── Credits.rtf
├── Kinector-Prefix.pch
├── timing.h
├── main.m
├── Timer.h
├── AppDelegate.h
├── Kinect.h
├── SimpleGLView.h
├── KinectorProtocols.h
├── Renderer.h
├── MainWindowController.h
├── AppDelegate.m
├── Kinector-Info.plist
├── timing.c
├── Timer.m
├── MainWindowController.m
├── Renderer.m
├── SimpleGLView.m
├── Kinect.m
└── MainWindow.xib
├── Kinector.xcodeproj
├── xcuserdata
│ └── foo.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── Kinector.xcscheme
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── foo.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── project.pbxproj
└── Readme.md
/Kinector/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/Kinector.xcodeproj/xcuserdata/foo.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/Kinector/Kinector-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'Kinector' target in the 'Kinector' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #endif
8 |
--------------------------------------------------------------------------------
/Kinector.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Kinector.xcodeproj/project.xcworkspace/xcuserdata/foo.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marsmining/Kinector/master/Kinector.xcodeproj/project.xcworkspace/xcuserdata/foo.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/Kinector/timing.h:
--------------------------------------------------------------------------------
1 | //
2 | // timing.h
3 | // Kinector
4 | //
5 | // Created by foo on 8/26/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | struct ktimeinfo* timinit();
12 |
13 | double timtick(struct ktimeinfo *ctx);
--------------------------------------------------------------------------------
/Kinector/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // Kinector
4 | //
5 | // Created by foo on 8/28/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, char *argv[])
12 | {
13 | return NSApplicationMain(argc, (const char **)argv);
14 | }
15 |
--------------------------------------------------------------------------------
/Kinector/Timer.h:
--------------------------------------------------------------------------------
1 | //
2 | // Timer.h
3 | // Kinector
4 | //
5 | // Created by foo on 8/30/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | #define MAXSAMPLES 100
13 |
14 | @interface Timer : NSObject
15 |
16 | - (double) timtick;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/Kinector/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // Kinector
4 | //
5 | // Created by foo on 8/28/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "MainWindowController.h"
11 |
12 | @interface AppDelegate : NSObject
13 |
14 | @property (nonatomic, strong) MainWindowController *controller;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/Kinector/Kinect.h:
--------------------------------------------------------------------------------
1 | //
2 | // Kinect.h
3 | // Kinector
4 | //
5 | // Created by foo on 8/14/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Timer.h"
11 |
12 | @interface Kinect : NSObject {
13 | Timer *timer;
14 | }
15 |
16 | - (void) start;
17 |
18 | - (void) stop;
19 |
20 | - (BOOL) isRunning;
21 |
22 | - (uint8_t *) getDepthBuffer;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/Kinector/SimpleGLView.h:
--------------------------------------------------------------------------------
1 | //
2 | // SimpleGLView.h
3 | // Kinector
4 | //
5 | // Created by foo on 8/26/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "KinectorProtocols.h"
12 |
13 | @interface SimpleGLView : NSOpenGLView
14 |
15 | @property (nonatomic, strong) id renderer;
16 |
17 | - (void) start;
18 |
19 | - (void) stop;
20 |
21 | - (BOOL) isRunning;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/Kinector/en.lproj/Credits.rtf:
--------------------------------------------------------------------------------
1 | {\rtf1\ansi\ansicpg1252\cocoartf1187
2 | {\fonttbl\f0\fswiss\fcharset0 Helvetica;}
3 | {\colortbl;\red255\green255\blue255;}
4 | \vieww9600\viewh8400\viewkind0
5 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
6 |
7 | \f0\b\fs24 \cf0 Kinector\
8 | \
9 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural
10 |
11 | \b0 \cf0 simple osx 10.8 app to display kinect depth buffer via opengl using libfreenect library}
--------------------------------------------------------------------------------
/Kinector/KinectorProtocols.h:
--------------------------------------------------------------------------------
1 | //
2 | // KinectorProtocols.h
3 | // Kinector
4 | //
5 | // Created by foo on 8/29/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @protocol RenderDelegate
12 |
13 | - (void) prepare;
14 |
15 | - (void) render;
16 |
17 | - (void) resizeWithWidth:(GLuint)width AndHeight:(GLuint)height;
18 |
19 | @end
20 |
21 | @protocol KinectBufferDelegate
22 |
23 | - (uint8_t *) getDepthBuffer;
24 |
25 | @end
--------------------------------------------------------------------------------
/Kinector.xcodeproj/xcuserdata/foo.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | Kinector.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | FCDC2FB515ED0B8F00F8A14A
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Kinector/Renderer.h:
--------------------------------------------------------------------------------
1 | //
2 | // Renderer.h
3 | // Kinector
4 | //
5 | // Created by foo on 8/26/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "KinectorProtocols.h"
12 | #import "Timer.h"
13 |
14 | #define INITIAL_WIDTH 640
15 | #define INITIAL_HEIGHT 480
16 |
17 | @interface Renderer : NSObject
18 |
19 | - (id) initWithDelegate:(id)adel;
20 |
21 | - (void) prepare;
22 |
23 | - (void) render;
24 |
25 | - (void) resizeWithWidth:(GLuint)width AndHeight:(GLuint)height;
26 |
27 | @property (nonatomic, weak) id delegate;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/Kinector/MainWindowController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainWindowController.h
3 | // Altnect
4 | //
5 | // Created by foo on 8/28/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "SimpleGLView.h"
11 | #import "Kinect.h"
12 | #import "Renderer.h"
13 |
14 | @interface MainWindowController : NSWindowController
15 |
16 | @property (weak) IBOutlet SimpleGLView *glView;
17 | @property (nonatomic, strong) Kinect *kinect;
18 | @property (nonatomic, strong) Renderer *renderer;
19 |
20 | - (void) stop;
21 |
22 | - (IBAction) toggleDisplay:(NSButton *)sender;
23 |
24 | - (IBAction) toggleKinect:(NSButton *)sender;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/Kinector/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // Kinector
4 | //
5 | // Created by foo on 8/14/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @implementation AppDelegate
12 |
13 | // view controller
14 | @synthesize controller = _controller;
15 |
16 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
17 | NSLog(@"AppDelegate - applicationDidFinishLaunching");
18 |
19 | // create our window controller
20 | self.controller = [[MainWindowController alloc] init];
21 |
22 | // set color
23 | [self.controller.window setBackgroundColor:[NSColor orangeColor]];
24 |
25 | // display window
26 | [self.controller.window makeKeyAndOrderFront:self];
27 |
28 | }
29 |
30 | - (void) applicationWillTerminate:(NSNotification *)notification {
31 | NSLog(@"AppDelegate - applicationWillTerminate");
32 |
33 | [self.controller stop];
34 | }
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/Kinector/Kinector-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | de.ockhamsolutions.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSMinimumSystemVersion
26 | ${MACOSX_DEPLOYMENT_TARGET}
27 | NSHumanReadableCopyright
28 | Copyright © 2012 Ockham Solutions GmbH. All rights reserved.
29 | NSMainNibFile
30 | MainMenu
31 | NSPrincipalClass
32 | NSApplication
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Kinector/timing.c:
--------------------------------------------------------------------------------
1 | //
2 | // timing.c
3 | // Kinector
4 | //
5 | // Created by foo on 8/26/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #include "timing.h"
10 | #include
11 |
12 | #define MAXSAMPLES 100
13 |
14 | // timing stuff
15 |
16 | struct ktimeinfo {
17 | int tickindex;
18 | uint64_t ticksum;
19 | uint64_t ticklist[MAXSAMPLES];
20 | uint64_t lastclock;
21 | };
22 |
23 | mach_timebase_info_data_t info;
24 |
25 | double calcAverageTick(uint64_t newtick, struct ktimeinfo *ctx) {
26 |
27 | ctx->ticksum -= ctx->ticklist[ctx->tickindex];
28 | ctx->ticksum += newtick;
29 | ctx->ticklist[ctx->tickindex] = newtick;
30 |
31 | if(++ctx->tickindex == MAXSAMPLES)
32 | ctx->tickindex = 0;
33 |
34 | return ((double) ctx->ticksum / MAXSAMPLES);
35 | }
36 |
37 | double timtick(struct ktimeinfo *ctx) {
38 | uint64_t curr = mach_absolute_time();
39 | uint64_t diff = curr - ctx->lastclock;
40 | ctx->lastclock = curr;
41 | double avg = calcAverageTick(diff, ctx);
42 | const double elapsed = avg * (double)info.numer / (double)info.denom;
43 | return 1.0f / (elapsed / 1000000000);
44 | }
45 |
46 | struct ktimeinfo* timinit() {
47 |
48 | struct ktimeinfo *ctx = malloc(sizeof(struct ktimeinfo));
49 |
50 | ctx->tickindex = 0;
51 | ctx->ticksum = 0;
52 | ctx->lastclock = 0;
53 |
54 | // init tick list
55 | for (int i=0; i < MAXSAMPLES; i++) ctx->ticklist[i] = 0;
56 |
57 | // get time info
58 | mach_timebase_info(&info);
59 |
60 | return ctx;
61 | }
--------------------------------------------------------------------------------
/Kinector/Timer.m:
--------------------------------------------------------------------------------
1 | //
2 | // Timer.m
3 | // Kinector
4 | //
5 | // Created by foo on 8/30/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import "Timer.h"
10 |
11 | @interface Timer() {
12 | @private
13 |
14 | int tickindex;
15 | uint64_t ticksum;
16 | uint64_t ticklist[MAXSAMPLES];
17 | uint64_t lastclock;
18 | mach_timebase_info_data_t info;
19 | }
20 |
21 | @end
22 |
23 | @implementation Timer
24 |
25 | /**
26 | * Perform the average calculation and array management.
27 | */
28 | - (double) calcAverageTick:(uint64_t) newtick {
29 |
30 | ticksum-=ticklist[tickindex]; /* subtract value falling off */
31 | ticksum+=newtick; /* add new value */
32 | ticklist[tickindex]=newtick; /* save new value so it can be subtracted later */
33 | if(++tickindex==MAXSAMPLES) /* inc buffer index */
34 | tickindex=0;
35 |
36 | /* return average */
37 | return((double)ticksum/MAXSAMPLES);
38 | }
39 |
40 | /**
41 | * Register tick and return current rolling average.
42 | */
43 | - (double) timtick {
44 | uint64_t curr = mach_absolute_time();
45 | uint64_t diff = curr - lastclock;
46 | lastclock = curr;
47 |
48 | double avg = [self calcAverageTick:diff];
49 | const double elapsed = avg * (double)info.numer / (double)info.denom;
50 | return 1.0f / (elapsed / 1000000000);
51 | }
52 |
53 | /**
54 | * Initialize.
55 | */
56 | - (id) init {
57 |
58 | self = [super init];
59 |
60 | // init instance vars
61 | tickindex=0;
62 | ticksum=0;
63 | lastclock=0;
64 |
65 | // init tick list
66 | for (int i=0; i < MAXSAMPLES; i++) ticklist[i] = 0;
67 |
68 | // get time info
69 | mach_timebase_info(&info);
70 |
71 | return self;
72 | }
73 |
74 | @end
75 |
--------------------------------------------------------------------------------
/Kinector/MainWindowController.m:
--------------------------------------------------------------------------------
1 | //
2 | // MainWindowController.m
3 | // Altnect
4 | //
5 | // Created by foo on 8/28/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import "MainWindowController.h"
10 |
11 | /**
12 | * Coordinates all objects lifecycle and activities.
13 | */
14 | @implementation MainWindowController
15 |
16 | @synthesize glView = _glView;
17 | @synthesize kinect = _kinect;
18 | @synthesize renderer = _renderer;
19 |
20 | // getters w/lazy init
21 |
22 | - (Kinect *) kinect {
23 | if (!_kinect)
24 | _kinect = [[Kinect alloc] init];
25 | return _kinect;
26 | }
27 |
28 | - (Renderer *) renderer {
29 | if (!_renderer)
30 | _renderer = [[Renderer alloc] initWithDelegate:self];
31 | return _renderer;
32 | }
33 |
34 | // buffer delegate
35 |
36 | - (uint8_t *) getDepthBuffer {
37 | NSLog(@"MainWindowController - getDepthBuffer");
38 |
39 | return [self.kinect getDepthBuffer];
40 | }
41 |
42 | - (id) init
43 | {
44 | self = [super initWithWindowNibName:@"MainWindow"];
45 |
46 | if (self) {
47 | // code
48 | }
49 | return self;
50 | }
51 |
52 | - (void) windowDidLoad
53 | {
54 | [super windowDidLoad];
55 |
56 | // code
57 | self.glView.renderer = self.renderer;
58 | }
59 |
60 | - (void) stop
61 | {
62 | NSLog(@"MainWindowController - stop");
63 |
64 | [self.kinect stop];
65 | [self.glView stop];
66 | }
67 |
68 | - (IBAction) toggleDisplay:(NSButton *)sender {
69 | NSLog(@"MainWindowController - toggleDisplay");
70 |
71 | if (self.glView.isRunning) {
72 | [self.glView stop];
73 | sender.title = @"Start OpenGL";
74 | } else {
75 | [self.glView start];
76 | sender.title = @"Stop OpenGL";
77 | }
78 | }
79 |
80 | - (IBAction)toggleKinect:(NSButton *)sender {
81 | NSLog(@"MainWindowController - toggleKinect");
82 |
83 | if (self.kinect.isRunning) {
84 | [self.kinect stop];
85 | sender.title = @"Start Kinect";
86 | } else {
87 | [self.kinect start];
88 | sender.title = @"Stop Kinect";
89 | }
90 | }
91 |
92 | @end
93 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | # Kinector
2 |
3 | Work in progress. Mac app which uses Kinect.
4 |
5 | ## Notes
6 |
7 | ### Depth to RGB
8 |
9 | The [libfreenect](https://github.com/OpenKinect/libfreenect) library
10 | includes a very helpful example, but I had to work extra hard to make
11 | sense of the code which translates the depth buffer value to some rgb
12 | value for display. Visualizing depth values could be done a million
13 | ways. Initially, I just scaled the value to 8-bit for grayscale. But I
14 | was intrigued by the logic in
15 | [this example code](https://github.com/OpenKinect/libfreenect/blob/4d2fede2202c48469aa2300234906d171b7dd7d0/examples/glview.c#L358-L398).
16 |
17 | First off, if you initialize the depth camera like so:
18 |
19 | ```c
20 | freenect_set_depth_mode(f_dev, freenect_find_depth_mode(
21 | FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT));
22 | ```
23 |
24 | And if we use the routine from the `glview.c` linked above, we get an
25 | image with a color range like this:
26 |
27 | 
28 |
29 | _the red dot is just some opengl drawing, ignore that_
30 |
31 | Ok so, in this mode, the depth camera is giving us 11-bit (2048)
32 | values. The first step done for each sample, is a lookup in
33 | the `t_gamma` array, of length 2048. The array is initialized like so:
34 |
35 | ```c
36 | // init gamma array
37 | for (int i=0; i < 2048; i++) {
38 | float v = i / 2048.0;
39 |
40 | v = powf(v, 3) * 6;
41 | t_gamma[i] = v * 6 * 256;
42 | }
43 | ```
44 |
45 | If we plot the array, to visualize like a function, we get:
46 |
47 | 
48 |
49 | Math is not my strong suit, but I interpret this as normalizing the
50 | range 0 to 2047 to 0 to 1. Then scaling with an exponent of 3 and a
51 | constant `6 * 6 * 256`. So why choose these values?
52 |
53 | Next, the value looked up in the gamma array, is bitwise and'd
54 | (masked) with `0xff`, which means we're sort of chopping off the
55 | significant bits beyond 8. If we were to plot it, we get:
56 |
57 | 
58 |
59 | ### License
60 |
61 | Copyright © 2013
62 |
63 | Distributed under the Eclipse Public License either version 1.0 or (at
64 | your option) any later version.
65 |
66 |
--------------------------------------------------------------------------------
/Kinector/Renderer.m:
--------------------------------------------------------------------------------
1 | //
2 | // Renderer.m
3 | // Kinector
4 | //
5 | // Created by foo on 8/26/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import "Renderer.h"
10 |
11 | // An array of 3 vectors which represents 3 vertices
12 | static const GLfloat g_vertex_buffer_data[] = {
13 | -1.0f, -1.0f, 0.0f,
14 | 1.0f, -1.0f, 0.0f,
15 | 0.0f, 1.0f, 0.0f,
16 | };
17 |
18 | @interface Renderer() {
19 | @private
20 |
21 | Timer *timer;
22 | GLuint width;
23 | GLuint height;
24 | }
25 | @end
26 |
27 | @implementation Renderer
28 |
29 | @synthesize delegate = _delegate;
30 |
31 | // This will identify our vertex buffer
32 | GLuint vertexbuffer;
33 |
34 | /**
35 | * Render the buffer owned by the Kinect object.
36 | */
37 | - (void) render {
38 |
39 | NSLog(@"Renderer - render - fps: %3.1f", [timer timtick]);
40 |
41 | glClear(GL_COLOR_BUFFER_BIT);
42 |
43 | if ([self.delegate getDepthBuffer] != 0) {
44 | glRasterPos2i(0, 0);
45 | glDrawPixels(640, 480, GL_RGB, GL_UNSIGNED_BYTE, [self.delegate getDepthBuffer]);
46 | }
47 |
48 | // point stuff
49 | glColor3f(1.0f, 0.0f, 0.0f);
50 | glPointSize(10.0f);
51 | glBegin(GL_POINTS);
52 | glVertex2i(20, 20);
53 | glEnd();
54 |
55 | glFlush();
56 | }
57 |
58 | - (void) prepare {
59 | NSLog(@"Renderer - prepare");
60 |
61 | glShadeModel(GL_FLAT);
62 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
63 | glPixelZoom(1.0, -1.0);
64 |
65 | glViewport(0, 0, (GLsizei) width, (GLsizei) height);
66 | glMatrixMode(GL_PROJECTION);
67 | glLoadIdentity();
68 | glOrtho(0, width, height, 0, -1.0, 1.0);
69 | glMatrixMode(GL_MODELVIEW);
70 |
71 | glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
72 | }
73 |
74 | - (id) initWithDelegate:(id)adel {
75 |
76 | NSLog(@"Renderer - initWithDelegate - %s %s",
77 | glGetString(GL_RENDERER), glGetString(GL_VERSION));
78 |
79 | if((self = [super init])) {
80 |
81 | self.delegate = adel;
82 |
83 | timer = [[Timer alloc] init];
84 |
85 | width = INITIAL_WIDTH;
86 | height = INITIAL_HEIGHT;
87 |
88 | [self prepare];
89 | }
90 |
91 | return self;
92 | }
93 |
94 | - (void) resizeWithWidth:(GLuint)pwidth AndHeight:(GLuint)pheight {
95 |
96 | width = pwidth;
97 | height = pheight;
98 |
99 | [self prepare];
100 | }
101 |
102 | @end
103 |
104 |
--------------------------------------------------------------------------------
/Kinector.xcodeproj/xcuserdata/foo.xcuserdatad/xcschemes/Kinector.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/Kinector/SimpleGLView.m:
--------------------------------------------------------------------------------
1 | //
2 | // SimpleGLView.m
3 | // Kinector
4 | //
5 | // Created by foo on 8/26/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import "SimpleGLView.h"
10 |
11 | @interface SimpleGLView () {
12 |
13 | CVDisplayLinkRef displayLink;
14 | }
15 |
16 | - (void) drawView;
17 |
18 | @end
19 |
20 | @implementation SimpleGLView
21 |
22 | @synthesize renderer = _renderer;
23 |
24 | /**
25 | * Just delegate to 'drawView'.
26 | */
27 | - (CVReturn) getFrameForTime:(const CVTimeStamp*)outputTime {
28 | [self drawView];
29 | return kCVReturnSuccess;
30 | }
31 |
32 | /**
33 | * Display link callback function
34 | */
35 | static CVReturn dlc(CVDisplayLinkRef displayLink,
36 | const CVTimeStamp* now,
37 | const CVTimeStamp* outputTime,
38 | CVOptionFlags flagsIn,
39 | CVOptionFlags* flagsOut,
40 | void* displayLinkContext)
41 | {
42 | NSLog(@"SimpleGLView - dlc");
43 |
44 | // use the context passed in to call obj-c instance method
45 | CVReturn result = [(__bridge SimpleGLView*) displayLinkContext getFrameForTime:outputTime];
46 | return result;
47 | }
48 |
49 | /**
50 | * Start display link thread loop.
51 | */
52 | - (void) start
53 | {
54 | NSLog(@"SimpleGLView - start");
55 |
56 | // start the link
57 | CVDisplayLinkStart(displayLink);
58 | }
59 |
60 | /**
61 | * Stop the loop.
62 | */
63 | - (void) stop
64 | {
65 | NSLog(@"SimpleGLView - stop");
66 |
67 | // stop the link
68 | CVDisplayLinkStop(displayLink);
69 | }
70 |
71 | /**
72 | * Public status method.
73 | */
74 | - (BOOL) isRunning {
75 | return CVDisplayLinkIsRunning(displayLink);
76 | }
77 |
78 | /**
79 | * Initial setup.
80 | */
81 | - (void) awakeFromNib {
82 | NSLog(@"SimpleGLView - awakeFromNib");
83 |
84 | NSOpenGLPixelFormatAttribute attrs[] = {};
85 |
86 | NSOpenGLPixelFormat *pf = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
87 |
88 | if (!pf) NSLog(@"No OpenGL pixel format");
89 |
90 | NSOpenGLContext* ctx = [[NSOpenGLContext alloc] initWithFormat:pf shareContext:nil];
91 |
92 | [self setPixelFormat:pf];
93 | [self setOpenGLContext:ctx];
94 | }
95 |
96 | - (void) prepareOpenGL {
97 | NSLog(@"SimpleGLView - prepareOpenGL");
98 |
99 | GLint swapInt = 1;
100 |
101 | [super prepareOpenGL];
102 |
103 | [[self openGLContext] makeCurrentContext];
104 | [[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
105 |
106 | CVDisplayLinkCreateWithActiveCGDisplays(&displayLink);
107 | CVDisplayLinkSetOutputCallback(displayLink, &dlc, (__bridge void *)(self));
108 | CGLContextObj cglContext = [[self openGLContext] CGLContextObj];
109 | CGLPixelFormatObj cglPixelFormat = [[self pixelFormat] CGLPixelFormatObj];
110 | CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, cglContext, cglPixelFormat);
111 |
112 | [self.renderer prepare];
113 | }
114 |
115 | - (void) reshape {
116 |
117 | [super reshape];
118 |
119 | CGLLockContext([[self openGLContext] CGLContextObj]);
120 |
121 | NSRect rect = [self bounds];
122 |
123 | [self.renderer resizeWithWidth:rect.size.width AndHeight:rect.size.height];
124 |
125 | CGLUnlockContext([[self openGLContext] CGLContextObj]);
126 | }
127 |
128 | - (void) drawView
129 | {
130 | [[self openGLContext] makeCurrentContext];
131 |
132 | // We draw on a secondary thread through the display link
133 | // When resizing the view, -reshape is called automatically on the main thread
134 | // Add a mutex around to avoid the threads accessing the context simultaneously when resizing
135 | CGLLockContext([[self openGLContext] CGLContextObj]);
136 |
137 | [self.renderer render];
138 |
139 |
140 | CGLFlushDrawable([[self openGLContext] CGLContextObj]);
141 | CGLUnlockContext([[self openGLContext] CGLContextObj]);
142 | }
143 |
144 | - (void) dealloc
145 | {
146 | // Stop the display link BEFORE releasing anything in the view
147 | // otherwise the display link thread may call into the view and crash
148 | // when it encounters something that has been release
149 | CVDisplayLinkStop(displayLink);
150 |
151 | CVDisplayLinkRelease(displayLink);
152 | }
153 |
154 | @end
155 |
--------------------------------------------------------------------------------
/Kinector/Kinect.m:
--------------------------------------------------------------------------------
1 | //
2 | // Kinect.m
3 | // Kinector
4 | //
5 | // Created by foo on 8/14/12.
6 | // Copyright (c) 2012 Ockham Solutions GmbH. All rights reserved.
7 | //
8 |
9 | #import "Kinect.h"
10 | #import "timing.h"
11 | #import
12 |
13 | // global to comp unit
14 |
15 | volatile int die = 0;
16 |
17 | uint16_t t_gamma[2048];
18 |
19 | uint8_t *depth_mid;
20 |
21 | freenect_device *f_dev;
22 | freenect_context *f_ctx;
23 |
24 | struct ktimeinfo *mytimerctx;
25 |
26 | //
27 | // c-lang functions for libfreenect callbacks
28 | //
29 |
30 | void logcb(freenect_context *ctx, freenect_loglevel level, const char *msg) {
31 | NSLog(@"Kinect - recieved msg: %s", msg);
32 | }
33 |
34 | void depth_cb(freenect_device *dev, void *v_depth, uint32_t timestamp) {
35 | NSLog(@"Kinect - depth_cb - fps: %3.1f", timtick(mytimerctx));
36 |
37 | uint16_t *depth = (uint16_t*) v_depth;
38 |
39 | for (int i=0; i<640*480; i++) {
40 | int pval = t_gamma[depth[i]];
41 | int lb = pval & 0xff;
42 |
43 | switch (pval>>8) {
44 | case 0:
45 | depth_mid[3*i+0] = 255;
46 | depth_mid[3*i+1] = 255-lb;
47 | depth_mid[3*i+2] = 255-lb;
48 | break;
49 | case 1:
50 | depth_mid[3*i+0] = 255;
51 | depth_mid[3*i+1] = lb;
52 | depth_mid[3*i+2] = 0;
53 | break;
54 | case 2:
55 | depth_mid[3*i+0] = 255-lb;
56 | depth_mid[3*i+1] = 255;
57 | depth_mid[3*i+2] = 0;
58 | break;
59 | case 3:
60 | depth_mid[3*i+0] = 0;
61 | depth_mid[3*i+1] = 255;
62 | depth_mid[3*i+2] = lb;
63 | break;
64 | case 4:
65 | depth_mid[3*i+0] = 0;
66 | depth_mid[3*i+1] = 255-lb;
67 | depth_mid[3*i+2] = 255;
68 | break;
69 | case 5:
70 | depth_mid[3*i+0] = 0;
71 | depth_mid[3*i+1] = 0;
72 | depth_mid[3*i+2] = 255-lb;
73 | break;
74 | default:
75 | depth_mid[3*i+0] = 0;
76 | depth_mid[3*i+1] = 0;
77 | depth_mid[3*i+2] = 0;
78 | break;
79 | }
80 | }
81 | }
82 |
83 |
84 | /**
85 | * Interface
86 | */
87 | @interface Kinect() {
88 | BOOL kinectContextIsOpen;
89 | BOOL kinectDepthIsOpen;
90 | }
91 |
92 | - (BOOL) openDevice;
93 |
94 | - (BOOL) closeDevice;
95 |
96 | - (BOOL) openDepth;
97 |
98 | - (BOOL) closeDepth;
99 |
100 | @end
101 |
102 | /**
103 | * Implementation
104 | */
105 | @implementation Kinect
106 |
107 | - (BOOL) isRunning {
108 | return kinectDepthIsOpen || kinectContextIsOpen;
109 | }
110 |
111 | /**
112 | * Get pointer to depth buffer.
113 | */
114 | - (uint8_t *) getDepthBuffer {
115 | NSLog(@"Kinect - getDepthBuffer");
116 |
117 | if (kinectDepthIsOpen) return depth_mid;
118 |
119 | return 0;
120 | }
121 |
122 | - (void) start {
123 | NSLog(@"Kinect - start");
124 |
125 | kinectContextIsOpen = [self openDevice];
126 | kinectDepthIsOpen = [self openDepth];
127 | }
128 |
129 | - (void) stop {
130 | NSLog(@"Kinect - stop");
131 |
132 | if (kinectDepthIsOpen) {
133 | NSLog(@"Kinect - result from closing depth is: %d", [self closeDepth]);
134 | }
135 |
136 | if (kinectContextIsOpen) {
137 | NSLog(@"Kinect - result from closing device is: %d", [self closeDevice]);
138 | }
139 | }
140 |
141 | - (void) depthLoop {
142 | NSLog(@"Kinect - depthLoop");
143 |
144 | while (!die) {
145 | int rez = freenect_process_events(f_ctx);
146 | if (rez < 0) break;
147 | }
148 | }
149 |
150 | - (BOOL) closeDepth {
151 | NSLog(@"Kinect - closeDepth");
152 |
153 | die = 1;
154 | free(mytimerctx);
155 |
156 | // stop depth
157 | freenect_stop_depth(f_dev);
158 |
159 | // free buffer
160 | free(depth_mid);
161 |
162 | kinectDepthIsOpen = NO;
163 |
164 | return YES;
165 | }
166 |
167 | - (BOOL) openDepth {
168 | NSLog(@"Kinect - openDepth");
169 |
170 | die = 0;
171 | mytimerctx = timinit();
172 |
173 | // init gamma array
174 | for (int i=0; i < 2048; i++) {
175 | float v = i / 2048.0;
176 | v = powf(v, 3) * 6;
177 | t_gamma[i] = v * 6 * 256;
178 | }
179 |
180 | // allocate memory (freed in close depth)
181 | depth_mid = (uint8_t*)malloc(640*480*3);
182 |
183 | freenect_set_depth_callback(f_dev, &depth_cb);
184 | // freenect_set_depth_mode(f_dev, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_MM));
185 | freenect_set_depth_mode(f_dev, freenect_find_depth_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT));
186 |
187 | freenect_start_depth(f_dev);
188 |
189 | // start reading run loop thread
190 | NSThread* myThread = [[NSThread alloc] initWithTarget:self
191 | selector:@selector(depthLoop)
192 | object:nil];
193 | [myThread start]; // actually create the thread
194 |
195 | return YES;
196 | }
197 |
198 | - (BOOL) closeDevice {
199 | NSLog(@"Kinect - closeDevice");
200 |
201 | // close device and context
202 | freenect_close_device(f_dev);
203 | freenect_shutdown(f_ctx);
204 |
205 | kinectContextIsOpen = NO;
206 |
207 | return YES;
208 | }
209 |
210 | - (BOOL) openDevice {
211 | NSLog(@"Kinect - openDevice");
212 |
213 | if (freenect_init(&f_ctx, NULL) < 0) {
214 | NSLog(@"freenect_init() failed");
215 | return NO;
216 | }
217 |
218 | freenect_set_log_level(f_ctx, FREENECT_LOG_SPEW);
219 |
220 | freenect_set_log_callback(f_ctx, &logcb);
221 |
222 | freenect_select_subdevices(f_ctx, FREENECT_DEVICE_CAMERA);
223 |
224 | int nr_devices = freenect_num_devices(f_ctx);
225 | NSLog(@"Number of devices found: %d", nr_devices);
226 |
227 | if (nr_devices < 1) {
228 | freenect_shutdown(f_ctx);
229 | return NO;
230 | }
231 |
232 | int sub_devices = freenect_supported_subdevices();
233 | NSLog(@"subdevice int: %i", sub_devices);
234 | if ((sub_devices & FREENECT_DEVICE_MOTOR) == 0) NSLog(@"no motor");
235 | if ((sub_devices & FREENECT_DEVICE_CAMERA) == 0) NSLog(@"no camera");
236 | if ((sub_devices & FREENECT_DEVICE_AUDIO) == 0) NSLog(@"no audio");
237 | if ((sub_devices & 0x05) == 0) NSLog(@"no fake");
238 |
239 | if (freenect_open_device(f_ctx, &f_dev, 0) < 0) {
240 | NSLog(@"Could not open device");
241 | freenect_shutdown(f_ctx);
242 | return NO;
243 | }
244 |
245 | return YES;
246 | }
247 |
248 | - (id) init {
249 |
250 | self = [super init];
251 |
252 | if (self) {
253 |
254 | kinectContextIsOpen = NO;
255 | kinectDepthIsOpen = NO;
256 | }
257 |
258 | return self;
259 | }
260 |
261 | @end
262 |
--------------------------------------------------------------------------------
/Kinector.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | FC2365C915EFC6BD00E45589 /* Timer.m in Sources */ = {isa = PBXBuildFile; fileRef = FC2365C815EFC6BD00E45589 /* Timer.m */; };
11 | FC2365CC15EFE05100E45589 /* timing.c in Sources */ = {isa = PBXBuildFile; fileRef = FC2365CA15EFE05100E45589 /* timing.c */; };
12 | FC67A03917DC4DD900097C17 /* libfreenect.0.2.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = FC67A03817DC4DD900097C17 /* libfreenect.0.2.0.dylib */; };
13 | FCDC2FBB15ED0B8F00F8A14A /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FCDC2FBA15ED0B8F00F8A14A /* Cocoa.framework */; };
14 | FCDC2FC515ED0B8F00F8A14A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = FCDC2FC315ED0B8F00F8A14A /* InfoPlist.strings */; };
15 | FCDC2FC715ED0B8F00F8A14A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FCDC2FC615ED0B8F00F8A14A /* main.m */; };
16 | FCDC2FCB15ED0B8F00F8A14A /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = FCDC2FC915ED0B8F00F8A14A /* Credits.rtf */; };
17 | FCDC2FCE15ED0B8F00F8A14A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = FCDC2FCD15ED0B8F00F8A14A /* AppDelegate.m */; };
18 | FCDC2FD115ED0B8F00F8A14A /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = FCDC2FCF15ED0B8F00F8A14A /* MainMenu.xib */; };
19 | FCDC2FD915ED0BAE00F8A14A /* Kinect.m in Sources */ = {isa = PBXBuildFile; fileRef = FCDC2FD815ED0BAE00F8A14A /* Kinect.m */; };
20 | FCDC2FE315ED0BCC00F8A14A /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = FCDC2FDA15ED0BCC00F8A14A /* MainWindow.xib */; };
21 | FCDC2FE415ED0BCC00F8A14A /* MainWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCDC2FDC15ED0BCC00F8A14A /* MainWindowController.m */; };
22 | FCDC2FE515ED0BCC00F8A14A /* SimpleGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = FCDC2FDE15ED0BCC00F8A14A /* SimpleGLView.m */; };
23 | FCDC2FE615ED0BCC00F8A14A /* Renderer.m in Sources */ = {isa = PBXBuildFile; fileRef = FCDC2FE015ED0BCC00F8A14A /* Renderer.m */; };
24 | FCDC2FEC15ED159D00F8A14A /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FCDC2FEB15ED159D00F8A14A /* OpenGL.framework */; };
25 | FCDC2FEE15ED15B300F8A14A /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FCDC2FED15ED15B300F8A14A /* CoreVideo.framework */; };
26 | /* End PBXBuildFile section */
27 |
28 | /* Begin PBXFileReference section */
29 | FC2365C715EFC6BD00E45589 /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Timer.h; sourceTree = ""; };
30 | FC2365C815EFC6BD00E45589 /* Timer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Timer.m; sourceTree = ""; };
31 | FC2365CA15EFE05100E45589 /* timing.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = timing.c; sourceTree = ""; };
32 | FC2365CB15EFE05100E45589 /* timing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = timing.h; sourceTree = ""; };
33 | FC67A03817DC4DD900097C17 /* libfreenect.0.2.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfreenect.0.2.0.dylib; path = /usr/local/lib/libfreenect.0.2.0.dylib; sourceTree = ""; };
34 | FCABF65C15EE89A500584A4F /* KinectorProtocols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KinectorProtocols.h; sourceTree = ""; };
35 | FCDC2FB615ED0B8F00F8A14A /* Kinector.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Kinector.app; sourceTree = BUILT_PRODUCTS_DIR; };
36 | FCDC2FBA15ED0B8F00F8A14A /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
37 | FCDC2FBD15ED0B8F00F8A14A /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
38 | FCDC2FBE15ED0B8F00F8A14A /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
39 | FCDC2FBF15ED0B8F00F8A14A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
40 | FCDC2FC215ED0B8F00F8A14A /* Kinector-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Kinector-Info.plist"; sourceTree = ""; };
41 | FCDC2FC415ED0B8F00F8A14A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
42 | FCDC2FC615ED0B8F00F8A14A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
43 | FCDC2FC815ED0B8F00F8A14A /* Kinector-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Kinector-Prefix.pch"; sourceTree = ""; };
44 | FCDC2FCA15ED0B8F00F8A14A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = ""; };
45 | FCDC2FCC15ED0B8F00F8A14A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
46 | FCDC2FCD15ED0B8F00F8A14A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
47 | FCDC2FD015ED0B8F00F8A14A /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; };
48 | FCDC2FD715ED0BAE00F8A14A /* Kinect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Kinect.h; sourceTree = ""; };
49 | FCDC2FD815ED0BAE00F8A14A /* Kinect.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Kinect.m; sourceTree = ""; };
50 | FCDC2FDA15ED0BCC00F8A14A /* MainWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; };
51 | FCDC2FDB15ED0BCC00F8A14A /* MainWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainWindowController.h; sourceTree = ""; };
52 | FCDC2FDC15ED0BCC00F8A14A /* MainWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainWindowController.m; sourceTree = ""; };
53 | FCDC2FDD15ED0BCC00F8A14A /* SimpleGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleGLView.h; sourceTree = ""; };
54 | FCDC2FDE15ED0BCC00F8A14A /* SimpleGLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimpleGLView.m; sourceTree = ""; };
55 | FCDC2FDF15ED0BCC00F8A14A /* Renderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Renderer.h; sourceTree = ""; };
56 | FCDC2FE015ED0BCC00F8A14A /* Renderer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Renderer.m; sourceTree = ""; };
57 | FCDC2FEB15ED159D00F8A14A /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; };
58 | FCDC2FED15ED15B300F8A14A /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = System/Library/Frameworks/CoreVideo.framework; sourceTree = SDKROOT; };
59 | /* End PBXFileReference section */
60 |
61 | /* Begin PBXFrameworksBuildPhase section */
62 | FCDC2FB315ED0B8F00F8A14A /* Frameworks */ = {
63 | isa = PBXFrameworksBuildPhase;
64 | buildActionMask = 2147483647;
65 | files = (
66 | FCDC2FEE15ED15B300F8A14A /* CoreVideo.framework in Frameworks */,
67 | FCDC2FEC15ED159D00F8A14A /* OpenGL.framework in Frameworks */,
68 | FCDC2FBB15ED0B8F00F8A14A /* Cocoa.framework in Frameworks */,
69 | FC67A03917DC4DD900097C17 /* libfreenect.0.2.0.dylib in Frameworks */,
70 | );
71 | runOnlyForDeploymentPostprocessing = 0;
72 | };
73 | /* End PBXFrameworksBuildPhase section */
74 |
75 | /* Begin PBXGroup section */
76 | FCDC2FAB15ED0B8F00F8A14A = {
77 | isa = PBXGroup;
78 | children = (
79 | FCDC2FC015ED0B8F00F8A14A /* Kinector */,
80 | FCDC2FEA15ED156300F8A14A /* libs */,
81 | FCDC2FB915ED0B8F00F8A14A /* Frameworks */,
82 | FCDC2FB715ED0B8F00F8A14A /* Products */,
83 | );
84 | sourceTree = "";
85 | };
86 | FCDC2FB715ED0B8F00F8A14A /* Products */ = {
87 | isa = PBXGroup;
88 | children = (
89 | FCDC2FB615ED0B8F00F8A14A /* Kinector.app */,
90 | );
91 | name = Products;
92 | sourceTree = "";
93 | };
94 | FCDC2FB915ED0B8F00F8A14A /* Frameworks */ = {
95 | isa = PBXGroup;
96 | children = (
97 | FCDC2FED15ED15B300F8A14A /* CoreVideo.framework */,
98 | FCDC2FEB15ED159D00F8A14A /* OpenGL.framework */,
99 | FCDC2FBA15ED0B8F00F8A14A /* Cocoa.framework */,
100 | FCDC2FBC15ED0B8F00F8A14A /* Other Frameworks */,
101 | );
102 | name = Frameworks;
103 | sourceTree = "";
104 | };
105 | FCDC2FBC15ED0B8F00F8A14A /* Other Frameworks */ = {
106 | isa = PBXGroup;
107 | children = (
108 | FCDC2FBD15ED0B8F00F8A14A /* AppKit.framework */,
109 | FCDC2FBE15ED0B8F00F8A14A /* CoreData.framework */,
110 | FCDC2FBF15ED0B8F00F8A14A /* Foundation.framework */,
111 | );
112 | name = "Other Frameworks";
113 | sourceTree = "";
114 | };
115 | FCDC2FC015ED0B8F00F8A14A /* Kinector */ = {
116 | isa = PBXGroup;
117 | children = (
118 | FCDC2FDD15ED0BCC00F8A14A /* SimpleGLView.h */,
119 | FCDC2FDE15ED0BCC00F8A14A /* SimpleGLView.m */,
120 | FCDC2FDF15ED0BCC00F8A14A /* Renderer.h */,
121 | FCDC2FE015ED0BCC00F8A14A /* Renderer.m */,
122 | FC2365C715EFC6BD00E45589 /* Timer.h */,
123 | FC2365C815EFC6BD00E45589 /* Timer.m */,
124 | FCDC2FD715ED0BAE00F8A14A /* Kinect.h */,
125 | FCDC2FD815ED0BAE00F8A14A /* Kinect.m */,
126 | FCDC2FDB15ED0BCC00F8A14A /* MainWindowController.h */,
127 | FCDC2FDC15ED0BCC00F8A14A /* MainWindowController.m */,
128 | FCDC2FCC15ED0B8F00F8A14A /* AppDelegate.h */,
129 | FCDC2FCD15ED0B8F00F8A14A /* AppDelegate.m */,
130 | FCDC2FCF15ED0B8F00F8A14A /* MainMenu.xib */,
131 | FCDC2FDA15ED0BCC00F8A14A /* MainWindow.xib */,
132 | FCABF65C15EE89A500584A4F /* KinectorProtocols.h */,
133 | FC2365CA15EFE05100E45589 /* timing.c */,
134 | FC2365CB15EFE05100E45589 /* timing.h */,
135 | FCDC2FC115ED0B8F00F8A14A /* Supporting Files */,
136 | );
137 | path = Kinector;
138 | sourceTree = "";
139 | };
140 | FCDC2FC115ED0B8F00F8A14A /* Supporting Files */ = {
141 | isa = PBXGroup;
142 | children = (
143 | FCDC2FC215ED0B8F00F8A14A /* Kinector-Info.plist */,
144 | FCDC2FC315ED0B8F00F8A14A /* InfoPlist.strings */,
145 | FCDC2FC615ED0B8F00F8A14A /* main.m */,
146 | FCDC2FC815ED0B8F00F8A14A /* Kinector-Prefix.pch */,
147 | FCDC2FC915ED0B8F00F8A14A /* Credits.rtf */,
148 | );
149 | name = "Supporting Files";
150 | sourceTree = "";
151 | };
152 | FCDC2FEA15ED156300F8A14A /* libs */ = {
153 | isa = PBXGroup;
154 | children = (
155 | FC67A03817DC4DD900097C17 /* libfreenect.0.2.0.dylib */,
156 | );
157 | name = libs;
158 | sourceTree = "";
159 | };
160 | /* End PBXGroup section */
161 |
162 | /* Begin PBXNativeTarget section */
163 | FCDC2FB515ED0B8F00F8A14A /* Kinector */ = {
164 | isa = PBXNativeTarget;
165 | buildConfigurationList = FCDC2FD415ED0B8F00F8A14A /* Build configuration list for PBXNativeTarget "Kinector" */;
166 | buildPhases = (
167 | FCDC2FB215ED0B8F00F8A14A /* Sources */,
168 | FCDC2FB315ED0B8F00F8A14A /* Frameworks */,
169 | FCDC2FB415ED0B8F00F8A14A /* Resources */,
170 | );
171 | buildRules = (
172 | );
173 | dependencies = (
174 | );
175 | name = Kinector;
176 | productName = Kinector;
177 | productReference = FCDC2FB615ED0B8F00F8A14A /* Kinector.app */;
178 | productType = "com.apple.product-type.application";
179 | };
180 | /* End PBXNativeTarget section */
181 |
182 | /* Begin PBXProject section */
183 | FCDC2FAD15ED0B8F00F8A14A /* Project object */ = {
184 | isa = PBXProject;
185 | attributes = {
186 | LastUpgradeCheck = 0440;
187 | ORGANIZATIONNAME = "Ockham Solutions GmbH";
188 | };
189 | buildConfigurationList = FCDC2FB015ED0B8F00F8A14A /* Build configuration list for PBXProject "Kinector" */;
190 | compatibilityVersion = "Xcode 3.2";
191 | developmentRegion = English;
192 | hasScannedForEncodings = 0;
193 | knownRegions = (
194 | en,
195 | );
196 | mainGroup = FCDC2FAB15ED0B8F00F8A14A;
197 | productRefGroup = FCDC2FB715ED0B8F00F8A14A /* Products */;
198 | projectDirPath = "";
199 | projectRoot = "";
200 | targets = (
201 | FCDC2FB515ED0B8F00F8A14A /* Kinector */,
202 | );
203 | };
204 | /* End PBXProject section */
205 |
206 | /* Begin PBXResourcesBuildPhase section */
207 | FCDC2FB415ED0B8F00F8A14A /* Resources */ = {
208 | isa = PBXResourcesBuildPhase;
209 | buildActionMask = 2147483647;
210 | files = (
211 | FCDC2FC515ED0B8F00F8A14A /* InfoPlist.strings in Resources */,
212 | FCDC2FCB15ED0B8F00F8A14A /* Credits.rtf in Resources */,
213 | FCDC2FD115ED0B8F00F8A14A /* MainMenu.xib in Resources */,
214 | FCDC2FE315ED0BCC00F8A14A /* MainWindow.xib in Resources */,
215 | );
216 | runOnlyForDeploymentPostprocessing = 0;
217 | };
218 | /* End PBXResourcesBuildPhase section */
219 |
220 | /* Begin PBXSourcesBuildPhase section */
221 | FCDC2FB215ED0B8F00F8A14A /* Sources */ = {
222 | isa = PBXSourcesBuildPhase;
223 | buildActionMask = 2147483647;
224 | files = (
225 | FCDC2FC715ED0B8F00F8A14A /* main.m in Sources */,
226 | FCDC2FCE15ED0B8F00F8A14A /* AppDelegate.m in Sources */,
227 | FCDC2FD915ED0BAE00F8A14A /* Kinect.m in Sources */,
228 | FCDC2FE415ED0BCC00F8A14A /* MainWindowController.m in Sources */,
229 | FCDC2FE515ED0BCC00F8A14A /* SimpleGLView.m in Sources */,
230 | FCDC2FE615ED0BCC00F8A14A /* Renderer.m in Sources */,
231 | FC2365C915EFC6BD00E45589 /* Timer.m in Sources */,
232 | FC2365CC15EFE05100E45589 /* timing.c in Sources */,
233 | );
234 | runOnlyForDeploymentPostprocessing = 0;
235 | };
236 | /* End PBXSourcesBuildPhase section */
237 |
238 | /* Begin PBXVariantGroup section */
239 | FCDC2FC315ED0B8F00F8A14A /* InfoPlist.strings */ = {
240 | isa = PBXVariantGroup;
241 | children = (
242 | FCDC2FC415ED0B8F00F8A14A /* en */,
243 | );
244 | name = InfoPlist.strings;
245 | sourceTree = "";
246 | };
247 | FCDC2FC915ED0B8F00F8A14A /* Credits.rtf */ = {
248 | isa = PBXVariantGroup;
249 | children = (
250 | FCDC2FCA15ED0B8F00F8A14A /* en */,
251 | );
252 | name = Credits.rtf;
253 | sourceTree = "";
254 | };
255 | FCDC2FCF15ED0B8F00F8A14A /* MainMenu.xib */ = {
256 | isa = PBXVariantGroup;
257 | children = (
258 | FCDC2FD015ED0B8F00F8A14A /* en */,
259 | );
260 | name = MainMenu.xib;
261 | sourceTree = "";
262 | };
263 | /* End PBXVariantGroup section */
264 |
265 | /* Begin XCBuildConfiguration section */
266 | FCDC2FD215ED0B8F00F8A14A /* Debug */ = {
267 | isa = XCBuildConfiguration;
268 | buildSettings = {
269 | ALWAYS_SEARCH_USER_PATHS = NO;
270 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
271 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
272 | CLANG_ENABLE_OBJC_ARC = YES;
273 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
274 | COPY_PHASE_STRIP = NO;
275 | GCC_C_LANGUAGE_STANDARD = gnu99;
276 | GCC_DYNAMIC_NO_PIC = NO;
277 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
278 | GCC_OPTIMIZATION_LEVEL = 0;
279 | GCC_PREPROCESSOR_DEFINITIONS = (
280 | "DEBUG=1",
281 | "$(inherited)",
282 | );
283 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
284 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
285 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
286 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
287 | GCC_WARN_UNUSED_VARIABLE = YES;
288 | MACOSX_DEPLOYMENT_TARGET = 10.8;
289 | ONLY_ACTIVE_ARCH = YES;
290 | SDKROOT = macosx;
291 | };
292 | name = Debug;
293 | };
294 | FCDC2FD315ED0B8F00F8A14A /* Release */ = {
295 | isa = XCBuildConfiguration;
296 | buildSettings = {
297 | ALWAYS_SEARCH_USER_PATHS = NO;
298 | ARCHS = "$(ARCHS_STANDARD_64_BIT)";
299 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
300 | CLANG_ENABLE_OBJC_ARC = YES;
301 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
302 | COPY_PHASE_STRIP = YES;
303 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
304 | GCC_C_LANGUAGE_STANDARD = gnu99;
305 | GCC_ENABLE_OBJC_EXCEPTIONS = YES;
306 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
307 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
308 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
309 | GCC_WARN_UNUSED_VARIABLE = YES;
310 | MACOSX_DEPLOYMENT_TARGET = 10.8;
311 | SDKROOT = macosx;
312 | };
313 | name = Release;
314 | };
315 | FCDC2FD515ED0B8F00F8A14A /* Debug */ = {
316 | isa = XCBuildConfiguration;
317 | buildSettings = {
318 | COMBINE_HIDPI_IMAGES = YES;
319 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
320 | GCC_PREFIX_HEADER = "Kinector/Kinector-Prefix.pch";
321 | "HEADER_SEARCH_PATHS[arch=*]" = /usr/local/include;
322 | INFOPLIST_FILE = "Kinector/Kinector-Info.plist";
323 | "LIBRARY_SEARCH_PATHS[arch=*]" = /usr/local/lib;
324 | PRODUCT_NAME = "$(TARGET_NAME)";
325 | WRAPPER_EXTENSION = app;
326 | };
327 | name = Debug;
328 | };
329 | FCDC2FD615ED0B8F00F8A14A /* Release */ = {
330 | isa = XCBuildConfiguration;
331 | buildSettings = {
332 | COMBINE_HIDPI_IMAGES = YES;
333 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
334 | GCC_PREFIX_HEADER = "Kinector/Kinector-Prefix.pch";
335 | "HEADER_SEARCH_PATHS[arch=*]" = /usr/local/include;
336 | INFOPLIST_FILE = "Kinector/Kinector-Info.plist";
337 | "LIBRARY_SEARCH_PATHS[arch=*]" = /usr/local/lib;
338 | PRODUCT_NAME = "$(TARGET_NAME)";
339 | WRAPPER_EXTENSION = app;
340 | };
341 | name = Release;
342 | };
343 | /* End XCBuildConfiguration section */
344 |
345 | /* Begin XCConfigurationList section */
346 | FCDC2FB015ED0B8F00F8A14A /* Build configuration list for PBXProject "Kinector" */ = {
347 | isa = XCConfigurationList;
348 | buildConfigurations = (
349 | FCDC2FD215ED0B8F00F8A14A /* Debug */,
350 | FCDC2FD315ED0B8F00F8A14A /* Release */,
351 | );
352 | defaultConfigurationIsVisible = 0;
353 | defaultConfigurationName = Release;
354 | };
355 | FCDC2FD415ED0B8F00F8A14A /* Build configuration list for PBXNativeTarget "Kinector" */ = {
356 | isa = XCConfigurationList;
357 | buildConfigurations = (
358 | FCDC2FD515ED0B8F00F8A14A /* Debug */,
359 | FCDC2FD615ED0B8F00F8A14A /* Release */,
360 | );
361 | defaultConfigurationIsVisible = 0;
362 | defaultConfigurationName = Release;
363 | };
364 | /* End XCConfigurationList section */
365 | };
366 | rootObject = FCDC2FAD15ED0B8F00F8A14A /* Project object */;
367 | }
368 |
--------------------------------------------------------------------------------
/Kinector/MainWindow.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1080
5 | 12B19
6 | 2549
7 | 1187
8 | 624.00
9 |
13 |
14 | IBNSLayoutConstraint
15 | NSButton
16 | NSButtonCell
17 | NSCustomObject
18 | NSOpenGLView
19 | NSView
20 | NSWindowTemplate
21 |
22 |
23 | com.apple.InterfaceBuilder.CocoaPlugin
24 |
25 |
29 |
30 |
33 |
36 |
39 |
130 |
131 |
132 |
133 |
134 |
135 | window
136 |
137 |
138 |
139 | 3
140 |
141 |
142 |
143 | toggleDisplay
144 |
145 |
146 |
147 | 20
148 |
149 |
150 |
151 | toggleDisplay:
152 |
153 |
154 |
155 | 22
156 |
157 |
158 |
159 | glView
160 |
161 |
162 |
163 | 23
164 |
165 |
166 |
167 | toggleKinect:
168 |
169 |
170 |
171 | 30
172 |
173 |
174 |
175 | delegate
176 |
177 |
178 |
179 | 4
180 |
181 |
182 |
183 |
184 |
185 | 0
186 |
187 |
188 |
189 |
190 |
191 | -2
192 |
193 |
194 | File's Owner
195 |
196 |
197 | -1
198 |
199 |
200 | First Responder
201 |
202 |
203 | -3
204 |
205 |
206 | Application
207 |
208 |
209 | 1
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 | 2
218 |
219 |
220 |
221 |
222 | 5
223 | 0
224 |
225 | 5
226 | 1
227 |
228 | 559
229 |
230 | 1000
231 |
232 | 3
233 | 9
234 | 3
235 |
236 |
237 |
238 | 6
239 | 0
240 |
241 | 6
242 | 1
243 |
244 | 0.0
245 |
246 | 1000
247 |
248 | 6
249 | 24
250 | 2
251 |
252 |
253 |
254 | 11
255 | 0
256 |
257 | 11
258 | 1
259 |
260 | 0.0
261 |
262 | 1000
263 |
264 | 6
265 | 24
266 | 2
267 |
268 |
269 |
270 | 3
271 | 0
272 |
273 | 4
274 | 1
275 |
276 | 20
277 |
278 | 1000
279 |
280 | 6
281 | 24
282 | 3
283 |
284 |
285 |
286 | 4
287 | 0
288 |
289 | 4
290 | 1
291 |
292 | 20
293 |
294 | 1000
295 |
296 | 8
297 | 29
298 | 3
299 |
300 |
301 |
302 | 5
303 | 0
304 |
305 | 5
306 | 1
307 |
308 | 20
309 |
310 | 1000
311 |
312 | 8
313 | 29
314 | 3
315 |
316 |
317 |
318 | 5
319 | 0
320 |
321 | 5
322 | 1
323 |
324 | 20
325 |
326 | 1000
327 |
328 | 8
329 | 29
330 | 3
331 |
332 |
333 |
334 | 3
335 | 0
336 |
337 | 3
338 | 1
339 |
340 | 179
341 |
342 | 1000
343 |
344 | 3
345 | 9
346 | 3
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 | 5
356 |
357 |
358 |
359 |
360 | 8
361 |
362 |
363 |
364 |
365 | 12
366 |
367 |
368 |
369 |
370 | 15
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 | 16
379 |
380 |
381 |
382 |
383 | 17
384 |
385 |
386 |
387 |
388 | 18
389 |
390 |
391 |
392 |
393 | 19
394 |
395 |
396 |
397 |
398 | 24
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 | 25
407 |
408 |
409 |
410 |
411 | 26
412 |
413 |
414 |
415 |
416 | 28
417 |
418 |
419 |
420 |
421 | 29
422 |
423 |
424 |
425 |
426 |
427 |
428 | com.apple.InterfaceBuilder.CocoaPlugin
429 | com.apple.InterfaceBuilder.CocoaPlugin
430 | com.apple.InterfaceBuilder.CocoaPlugin
431 | com.apple.InterfaceBuilder.CocoaPlugin
432 | {{357, 418}, {480, 270}}
433 |
434 | com.apple.InterfaceBuilder.CocoaPlugin
435 |
436 | com.apple.InterfaceBuilder.CocoaPlugin
437 | com.apple.InterfaceBuilder.CocoaPlugin
438 | com.apple.InterfaceBuilder.CocoaPlugin
439 | com.apple.InterfaceBuilder.CocoaPlugin
440 | com.apple.InterfaceBuilder.CocoaPlugin
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 | com.apple.InterfaceBuilder.CocoaPlugin
452 |
453 | com.apple.InterfaceBuilder.CocoaPlugin
454 | com.apple.InterfaceBuilder.CocoaPlugin
455 | com.apple.InterfaceBuilder.CocoaPlugin
456 | com.apple.InterfaceBuilder.CocoaPlugin
457 | com.apple.InterfaceBuilder.CocoaPlugin
458 | SimpleGLView
459 |
460 | com.apple.InterfaceBuilder.CocoaPlugin
461 | com.apple.InterfaceBuilder.CocoaPlugin
462 |
463 |
464 |
465 |
466 |
467 | 30
468 |
469 |
470 |
471 |
472 | MainWindowController
473 | NSWindowController
474 |
475 | NSButton
476 | NSButton
477 |
478 |
479 |
480 | toggleDisplay:
481 | NSButton
482 |
483 |
484 | toggleKinect:
485 | NSButton
486 |
487 |
488 |
489 | glView
490 | SimpleGLView
491 |
492 |
493 | glView
494 |
495 | glView
496 | SimpleGLView
497 |
498 |
499 |
500 | IBProjectSource
501 | ./Classes/MainWindowController.h
502 |
503 |
504 |
505 | NSLayoutConstraint
506 | NSObject
507 |
508 | IBProjectSource
509 | ./Classes/NSLayoutConstraint.h
510 |
511 |
512 |
513 | SimpleGLView
514 | NSOpenGLView
515 |
516 | IBProjectSource
517 | ./Classes/SimpleGLView.h
518 |
519 |
520 |
521 |
522 | 0
523 | IBCocoaFramework
524 | YES
525 | 3
526 | YES
527 |
528 |
529 |
--------------------------------------------------------------------------------