Commits

Cliff Biffle committed 23ce9a9

Wired the Kinect drivers into the viewer.

Comments (0)

Files changed (5)

 #import <OpenGL/gl.h>
 #import <OpenGL/glext.h>
 #import <OpenGL/glu.h>
+#import "KFKinect.h"
 
 typedef struct {
   GLfloat x, y, z;
   GLint viewWidth, viewHeight;
 } camera_t;
 
-@interface KVDepthView : NSOpenGLView {
-  NSData *rawDepthField;
+@interface KVDepthView : NSOpenGLView <KFKinectDelegate> {
+  NSMutableData *rawDepthField;
   
   camera_t camera;
   
   BOOL usingTrackball;
   GLfloat trackballRotation[4];
   GLfloat worldRotation[4];
+  GLfloat spin;
 }
 
-@property(retain) NSData *rawDepthField;
+@property(retain) NSMutableData *rawDepthField;
+
+- (void) depthFieldUpdated: (KFKinect *)kinect;
 
 @end
 }
 
 - (void) awakeFromNib {
-  rawDepthField = [[NSData alloc] initWithBytes: calloc(640 * 480, sizeof(uint16_t))
-                                         length: (640 * 480 * sizeof(uint16_t))];
+  rawDepthField = [[NSMutableData alloc] initWithBytes: calloc(640 * 480, sizeof(uint16_t))
+                                                length: (640 * 480 * sizeof(uint16_t))];
 }
 
 #pragma mark --- NSOpenGLView Overrides ---
   BOOL changes = NO;
   if (deltaV) {
     camera.pos.z += deltaV / 100.;
+    camera.target.z += deltaV / 100.;
     changes = YES;
   }
   
   }
 }
 
+-(void)keyDown: (NSEvent *)theEvent
+{
+  NSString *characters = [theEvent characters];
+  if ([characters length]) {
+    unichar character = [characters characterAtIndex:0];
+		switch (character) {
+			case 'a':
+				spin += 10;
+				[self setNeedsDisplay: YES];
+				break;
+			case 'd':
+				spin -= 10;
+				[self setNeedsDisplay: YES];
+				break;
+		}
+	}
+}
+
+- (void) depthFieldUpdated: (KFKinect *)kinect {
+  [self setNeedsDisplay: YES];
+}
+
+
 #pragma mark --- Properties ---
 
 @synthesize rawDepthField;
   glLoadIdentity();
   
   GLdouble near = -camera.pos.z - MAXIMUM_DEPTH;  
-  GLdouble far = -camera.pos.z + MAXIMUM_DEPTH * 2;
+  GLdouble far = -camera.pos.z + MAXIMUM_DEPTH * 16;
   
   // I do not fully understand this.
   if (near < 0.0001) near = 0.0001;
   
   glRotatef(trackballRotation[0], trackballRotation[1], trackballRotation[2], trackballRotation[3]);
   glRotatef(worldRotation[0], worldRotation[1], worldRotation[2], worldRotation[3]);
-  glScalef(-1/160., -1/160., 1);
+  glRotatef(spin, 0, 1, 0);
+  glScalef(-1/640., -1/640., 1);
   glTranslatef(-320, -240, 0);
 }
 
+GLfloat linearizeDepth(uint16_t reading) {
+  return (-325.616 / (((GLfloat) reading) + -1084.61));
+}
+
 - (void) drawDepthField {
   glBegin(GL_LINES);
   glColor3f(1, 1, 1);
   glEnd();
   
   const uint16_t *depths = [rawDepthField bytes];
-  glBegin(GL_LINES);
-  glColor3f (1.0, 0.5, 0.0);
+  
+  glBegin(GL_POINTS);
   for (int y = 0; y < 479; y++) {
     for (int x = 0; x < 639; x++) {
-      GLfloat d1 = depths[y * 640 + x], d2 = depths[y * 640 + x + 1];
-      glVertex3f(x, y, d1);
-      glVertex3f(x, y+1, d1);
-
-      glVertex3f(x, y+1, d1);
-      glVertex3f(x+1, y+1, d2);
+      GLfloat d1 = linearizeDepth(depths[y * 640 + x]);
+      if (d1 < 0.1) continue;
       
-      glVertex3f(x+1, y+1, d2);
-      glVertex3f(x+1, y, d2);
+      GLfloat dr = 1 + (d1 / 1);
+      GLfloat px = (x - 320) * dr + 320;
+      GLfloat py = (y - 240) * dr + 240;
       
-      glVertex3f(x+1, y, d2);
-      glVertex3f(x, y, d1);
+      GLfloat c = 1 - (d1/6.);
+      glColor3f(c,c,c);
+      glVertex3f(px, py, d1);
     }
   }
   glEnd();

KinectViewer.xcodeproj/project.pbxproj

 		C70E62AF129C5055004A44B3 /* KVDepthView.m in Sources */ = {isa = PBXBuildFile; fileRef = C70E62AE129C5055004A44B3 /* KVDepthView.m */; };
 		C70E62FB129C572E004A44B3 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C70E62FA129C572E004A44B3 /* OpenGL.framework */; };
 		C70E635F129C63BE004A44B3 /* trackball.c in Sources */ = {isa = PBXBuildFile; fileRef = C70E635D129C63BE004A44B3 /* trackball.c */; };
+		C70E6691129C8FD5004A44B3 /* KFKinect.m in Sources */ = {isa = PBXBuildFile; fileRef = C70E6685129C8FD5004A44B3 /* KFKinect.m */; };
+		C70E66A2129C9017004A44B3 /* freenect_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = C70E668A129C8FD5004A44B3 /* freenect_internal.h */; };
+		C70E66A3129C9017004A44B3 /* libfreenect.h in Headers */ = {isa = PBXBuildFile; fileRef = C70E668C129C8FD5004A44B3 /* libfreenect.h */; };
+		C70E66A4129C9017004A44B3 /* usb_libusb10.h in Headers */ = {isa = PBXBuildFile; fileRef = C70E668E129C8FD5004A44B3 /* usb_libusb10.h */; };
+		C70E66A5129C901E004A44B3 /* accelerometers.c in Sources */ = {isa = PBXBuildFile; fileRef = C70E6687129C8FD5004A44B3 /* accelerometers.c */; };
+		C70E66A6129C901E004A44B3 /* cameras.c in Sources */ = {isa = PBXBuildFile; fileRef = C70E6688129C8FD5004A44B3 /* cameras.c */; };
+		C70E66A7129C901E004A44B3 /* core.c in Sources */ = {isa = PBXBuildFile; fileRef = C70E6689129C8FD5004A44B3 /* core.c */; };
+		C70E66A8129C901E004A44B3 /* inits.c in Sources */ = {isa = PBXBuildFile; fileRef = C70E668B129C8FD5004A44B3 /* inits.c */; };
+		C70E66A9129C901E004A44B3 /* usb_libusb10.c in Sources */ = {isa = PBXBuildFile; fileRef = C70E668D129C8FD5004A44B3 /* usb_libusb10.c */; };
+		C70E66AA129C9024004A44B3 /* libusb.h in Headers */ = {isa = PBXBuildFile; fileRef = C70E6690129C8FD5004A44B3 /* libusb.h */; };
+		C70E66BB129C906C004A44B3 /* libdriver.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C70E669F129C9005004A44B3 /* libdriver.a */; };
+		C70E66CA129C9121004A44B3 /* libusb-1.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C70E66C9129C9121004A44B3 /* libusb-1.0.dylib */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
-		C70E6295129C4F50004A44B3 /* PBXContainerItemProxy */ = {
+		C70E66BC129C906F004A44B3 /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
-			containerPortal = C70E6290129C4F50004A44B3 /* KinectFW.xcodeproj */;
-			proxyType = 2;
-			remoteGlobalIDString = C70E61DE129C4257004A44B3 /* libfreenect.a */;
-			remoteInfo = freenect;
-		};
-		C70E6297129C4F50004A44B3 /* PBXContainerItemProxy */ = {
-			isa = PBXContainerItemProxy;
-			containerPortal = C70E6290129C4F50004A44B3 /* KinectFW.xcodeproj */;
-			proxyType = 2;
-			remoteGlobalIDString = 8DC2EF5B0486A6940098B216 /* Kinect.framework */;
-			remoteInfo = "Build Framework";
+			containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = C70E669E129C9005004A44B3 /* driver */;
+			remoteInfo = driver;
 		};
 /* End PBXContainerItemProxy section */
 
 		29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
 		8D1107310486CEB800E47090 /* KinectViewer-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "KinectViewer-Info.plist"; sourceTree = "<group>"; };
 		8D1107320486CEB800E47090 /* KinectViewer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KinectViewer.app; sourceTree = BUILT_PRODUCTS_DIR; };
-		C70E6290129C4F50004A44B3 /* KinectFW.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = KinectFW.xcodeproj; path = ../KinectFW/KinectFW.xcodeproj; sourceTree = SOURCE_ROOT; };
 		C70E62AD129C5055004A44B3 /* KVDepthView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KVDepthView.h; sourceTree = "<group>"; };
 		C70E62AE129C5055004A44B3 /* KVDepthView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KVDepthView.m; sourceTree = "<group>"; };
 		C70E62FA129C572E004A44B3 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; };
 		C70E635D129C63BE004A44B3 /* trackball.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = trackball.c; sourceTree = "<group>"; };
 		C70E635E129C63BE004A44B3 /* trackball.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = trackball.h; sourceTree = "<group>"; };
+		C70E6684129C8FD5004A44B3 /* KFKinect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KFKinect.h; sourceTree = "<group>"; };
+		C70E6685129C8FD5004A44B3 /* KFKinect.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KFKinect.m; sourceTree = "<group>"; };
+		C70E6687129C8FD5004A44B3 /* accelerometers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = accelerometers.c; sourceTree = "<group>"; };
+		C70E6688129C8FD5004A44B3 /* cameras.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cameras.c; sourceTree = "<group>"; };
+		C70E6689129C8FD5004A44B3 /* core.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = core.c; sourceTree = "<group>"; };
+		C70E668A129C8FD5004A44B3 /* freenect_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = freenect_internal.h; sourceTree = "<group>"; };
+		C70E668B129C8FD5004A44B3 /* inits.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = inits.c; sourceTree = "<group>"; };
+		C70E668C129C8FD5004A44B3 /* libfreenect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libfreenect.h; sourceTree = "<group>"; };
+		C70E668D129C8FD5004A44B3 /* usb_libusb10.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = usb_libusb10.c; sourceTree = "<group>"; };
+		C70E668E129C8FD5004A44B3 /* usb_libusb10.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = usb_libusb10.h; sourceTree = "<group>"; };
+		C70E6690129C8FD5004A44B3 /* libusb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libusb.h; sourceTree = "<group>"; };
+		C70E669F129C9005004A44B3 /* libdriver.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libdriver.a; sourceTree = BUILT_PRODUCTS_DIR; };
+		C70E66C9129C9121004A44B3 /* libusb-1.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libusb-1.0.dylib"; path = "usr/local/lib/libusb-1.0.dylib"; sourceTree = SDKROOT; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
 			files = (
 				8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
 				C70E62FB129C572E004A44B3 /* OpenGL.framework in Frameworks */,
+				C70E66BB129C906C004A44B3 /* libdriver.a in Frameworks */,
+				C70E66CA129C9121004A44B3 /* libusb-1.0.dylib in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		C70E669D129C9005004A44B3 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 		080E96DDFE201D6D7F000001 /* Classes */ = {
 			isa = PBXGroup;
 			children = (
+				C70E6684129C8FD5004A44B3 /* KFKinect.h */,
+				C70E6685129C8FD5004A44B3 /* KFKinect.m */,
 				256AC3D80F4B6AC300CF3369 /* KinectViewerAppDelegate.h */,
 				256AC3D90F4B6AC300CF3369 /* KinectViewerAppDelegate.m */,
 				C70E62AD129C5055004A44B3 /* KVDepthView.h */,
 		1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				C70E62FA129C572E004A44B3 /* OpenGL.framework */,
 				29B97324FDCFA39411CA2CEA /* AppKit.framework */,
 				13E42FB307B3F0F600E4EEF1 /* CoreData.framework */,
 				29B97325FDCFA39411CA2CEA /* Foundation.framework */,
 			isa = PBXGroup;
 			children = (
 				8D1107320486CEB800E47090 /* KinectViewer.app */,
+				C70E669F129C9005004A44B3 /* libdriver.a */,
 			);
 			name = Products;
 			sourceTree = "<group>";
 		29B97314FDCFA39411CA2CEA /* KinectViewer */ = {
 			isa = PBXGroup;
 			children = (
+				C70E6683129C8FD5004A44B3 /* driver */,
 				080E96DDFE201D6D7F000001 /* Classes */,
 				29B97315FDCFA39411CA2CEA /* Other Sources */,
 				29B97317FDCFA39411CA2CEA /* Resources */,
-				C70E628D129C4F33004A44B3 /* Projects */,
 				29B97323FDCFA39411CA2CEA /* Frameworks */,
 				19C28FACFE9D520D11CA2CBB /* Products */,
-				C70E62FA129C572E004A44B3 /* OpenGL.framework */,
+				C70E66C9129C9121004A44B3 /* libusb-1.0.dylib */,
 			);
 			name = KinectViewer;
 			sourceTree = "<group>";
 			name = Frameworks;
 			sourceTree = "<group>";
 		};
-		C70E628D129C4F33004A44B3 /* Projects */ = {
+		C70E6683129C8FD5004A44B3 /* driver */ = {
 			isa = PBXGroup;
 			children = (
-				C70E6290129C4F50004A44B3 /* KinectFW.xcodeproj */,
+				C70E6686129C8FD5004A44B3 /* libfreenect */,
+				C70E668F129C8FD5004A44B3 /* libusb */,
 			);
-			name = Projects;
+			path = driver;
 			sourceTree = "<group>";
 		};
-		C70E6291129C4F50004A44B3 /* Products */ = {
+		C70E6686129C8FD5004A44B3 /* libfreenect */ = {
 			isa = PBXGroup;
 			children = (
-				C70E6296129C4F50004A44B3 /* libfreenect.a */,
-				C70E6298129C4F50004A44B3 /* Kinect.framework */,
+				C70E6687129C8FD5004A44B3 /* accelerometers.c */,
+				C70E6688129C8FD5004A44B3 /* cameras.c */,
+				C70E6689129C8FD5004A44B3 /* core.c */,
+				C70E668A129C8FD5004A44B3 /* freenect_internal.h */,
+				C70E668B129C8FD5004A44B3 /* inits.c */,
+				C70E668C129C8FD5004A44B3 /* libfreenect.h */,
+				C70E668D129C8FD5004A44B3 /* usb_libusb10.c */,
+				C70E668E129C8FD5004A44B3 /* usb_libusb10.h */,
 			);
-			name = Products;
+			path = libfreenect;
+			sourceTree = "<group>";
+		};
+		C70E668F129C8FD5004A44B3 /* libusb */ = {
+			isa = PBXGroup;
+			children = (
+				C70E6690129C8FD5004A44B3 /* libusb.h */,
+			);
+			path = libusb;
 			sourceTree = "<group>";
 		};
 /* End PBXGroup section */
 
+/* Begin PBXHeadersBuildPhase section */
+		C70E669B129C9005004A44B3 /* Headers */ = {
+			isa = PBXHeadersBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				C70E66AA129C9024004A44B3 /* libusb.h in Headers */,
+				C70E66A2129C9017004A44B3 /* freenect_internal.h in Headers */,
+				C70E66A3129C9017004A44B3 /* libfreenect.h in Headers */,
+				C70E66A4129C9017004A44B3 /* usb_libusb10.h in Headers */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXHeadersBuildPhase section */
+
 /* Begin PBXNativeTarget section */
 		8D1107260486CEB800E47090 /* KinectViewer */ = {
 			isa = PBXNativeTarget;
 			buildRules = (
 			);
 			dependencies = (
+				C70E66BD129C906F004A44B3 /* PBXTargetDependency */,
 			);
 			name = KinectViewer;
 			productInstallPath = "$(HOME)/Applications";
 			productReference = 8D1107320486CEB800E47090 /* KinectViewer.app */;
 			productType = "com.apple.product-type.application";
 		};
+		C70E669E129C9005004A44B3 /* driver */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = C70E66BA129C903C004A44B3 /* Build configuration list for PBXNativeTarget "driver" */;
+			buildPhases = (
+				C70E669B129C9005004A44B3 /* Headers */,
+				C70E669C129C9005004A44B3 /* Sources */,
+				C70E669D129C9005004A44B3 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = driver;
+			productName = driver;
+			productReference = C70E669F129C9005004A44B3 /* libdriver.a */;
+			productType = "com.apple.product-type.library.static";
+		};
 /* End PBXNativeTarget section */
 
 /* Begin PBXProject section */
 			hasScannedForEncodings = 1;
 			mainGroup = 29B97314FDCFA39411CA2CEA /* KinectViewer */;
 			projectDirPath = "";
-			projectReferences = (
-				{
-					ProductGroup = C70E6291129C4F50004A44B3 /* Products */;
-					ProjectRef = C70E6290129C4F50004A44B3 /* KinectFW.xcodeproj */;
-				},
-			);
 			projectRoot = "";
 			targets = (
 				8D1107260486CEB800E47090 /* KinectViewer */,
+				C70E669E129C9005004A44B3 /* driver */,
 			);
 		};
 /* End PBXProject section */
 
-/* Begin PBXReferenceProxy section */
-		C70E6296129C4F50004A44B3 /* libfreenect.a */ = {
-			isa = PBXReferenceProxy;
-			fileType = archive.ar;
-			path = libfreenect.a;
-			remoteRef = C70E6295129C4F50004A44B3 /* PBXContainerItemProxy */;
-			sourceTree = BUILT_PRODUCTS_DIR;
-		};
-		C70E6298129C4F50004A44B3 /* Kinect.framework */ = {
-			isa = PBXReferenceProxy;
-			fileType = wrapper.framework;
-			path = Kinect.framework;
-			remoteRef = C70E6297129C4F50004A44B3 /* PBXContainerItemProxy */;
-			sourceTree = BUILT_PRODUCTS_DIR;
-		};
-/* End PBXReferenceProxy section */
-
 /* Begin PBXResourcesBuildPhase section */
 		8D1107290486CEB800E47090 /* Resources */ = {
 			isa = PBXResourcesBuildPhase;
 				256AC3DA0F4B6AC300CF3369 /* KinectViewerAppDelegate.m in Sources */,
 				C70E62AF129C5055004A44B3 /* KVDepthView.m in Sources */,
 				C70E635F129C63BE004A44B3 /* trackball.c in Sources */,
+				C70E6691129C8FD5004A44B3 /* KFKinect.m in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		C70E669C129C9005004A44B3 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				C70E66A5129C901E004A44B3 /* accelerometers.c in Sources */,
+				C70E66A6129C901E004A44B3 /* cameras.c in Sources */,
+				C70E66A7129C901E004A44B3 /* core.c in Sources */,
+				C70E66A8129C901E004A44B3 /* inits.c in Sources */,
+				C70E66A9129C901E004A44B3 /* usb_libusb10.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 /* End PBXSourcesBuildPhase section */
 
+/* Begin PBXTargetDependency section */
+		C70E66BD129C906F004A44B3 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = C70E669E129C9005004A44B3 /* driver */;
+			targetProxy = C70E66BC129C906F004A44B3 /* PBXContainerItemProxy */;
+		};
+/* End PBXTargetDependency section */
+
 /* Begin PBXVariantGroup section */
 		089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = {
 			isa = PBXVariantGroup;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
 				COPY_PHASE_STRIP = NO;
+				FRAMEWORK_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)/../KinectFW/build/Debug\"",
+				);
 				GCC_DYNAMIC_NO_PIC = NO;
 				GCC_ENABLE_FIX_AND_CONTINUE = YES;
 				GCC_MODEL_TUNING = G5;
 				GCC_OPTIMIZATION_LEVEL = 0;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = KinectViewer_Prefix.pch;
+				HEADER_SEARCH_PATHS = "/usr/local/include/**";
 				INFOPLIST_FILE = "KinectViewer-Info.plist";
 				INSTALL_PATH = "$(HOME)/Applications";
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)/build/Debug\"",
+				);
 				PRODUCT_NAME = KinectViewer;
 			};
 			name = Debug;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				FRAMEWORK_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)/../KinectFW/build/Debug\"",
+				);
 				GCC_MODEL_TUNING = G5;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = KinectViewer_Prefix.pch;
 				INFOPLIST_FILE = "KinectViewer-Info.plist";
 				INSTALL_PATH = "$(HOME)/Applications";
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)/build/Debug\"",
+				);
 				PRODUCT_NAME = KinectViewer;
 			};
 			name = Release;
 			};
 			name = Release;
 		};
+		C70E66A0129C9006004A44B3 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				INSTALL_PATH = /usr/local/lib;
+				PREBINDING = NO;
+				PRODUCT_NAME = driver;
+			};
+			name = Debug;
+		};
+		C70E66A1129C9006004A44B3 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				GCC_MODEL_TUNING = G5;
+				INSTALL_PATH = /usr/local/lib;
+				PREBINDING = NO;
+				PRODUCT_NAME = driver;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;
 		};
+		C70E66BA129C903C004A44B3 /* Build configuration list for PBXNativeTarget "driver" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				C70E66A0129C9006004A44B3 /* Debug */,
+				C70E66A1129C9006004A44B3 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
 /* End XCConfigurationList section */
 	};
 	rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;

KinectViewerAppDelegate.h

 //
 
 #import <Cocoa/Cocoa.h>
+#import "KFKinect.h"
 
 @class KVDepthView;
 
 @interface KinectViewerAppDelegate : NSObject <NSApplicationDelegate> {
   NSWindow *window;
   KVDepthView *depthView;
+  KFKinect *kinect;
 }
 
 @property (assign) IBOutlet NSWindow *window;

KinectViewerAppDelegate.m

 @synthesize depthView;
 
 - (void)applicationDidFinishLaunching: (NSNotification *)aNotification {
-  uint8_t *zeroes = malloc(640 * 480 * 2);
-	depthView.rawDepthField = [NSData dataWithBytes: zeroes length: 640 * 480 * 2];
+  kinect = [[KFKinect alloc] init];
+  kinect.delegate = depthView;
+  [kinect openWithDepthBuffer: [[depthView rawDepthField] mutableBytes] rgbBuffer: nil];
 }
 
 @end