Skip to content

chrisporter/OpenFlKinect

Repository files navigation

OpenFlKinect

Openfl / Haxe native extension for Microsoft Kinect for Windows SDK

To build ndll library:

haxelib run hxcpp Build.xml

To compile samples:

[haxelib run] openfl build project.xml windows

Copy KinectInteraction180_32.dll from %KINECT_TOOLKIT_DIR%/bin into same directory as .exe

xcopy "%KINECT_TOOLKIT_DIR%\Redist\x86\KinectInteraction180_32.dll" "./Export/Windows/cpp/bin" /Y /C

Usage

// Set options
d = new DeviceOptions();
d.depthEnabled = true;
d.depthResolution = ImageResolution.NUI_IMAGE_RESOLUTION_640x480;

// Create a Kinect references
k = new Kinect(d);
k.start();

// Add the image stream display list
addChild(k.bmDepth);

// call update each frame
addEventListener(Event.ENTER_FRAME, function(e)
{
  k.update();
});

Dependencies

Depth Stream

d = new DeviceOptions();
d.depthEnabled = true;
d.depthResolution = ImageResolution.NUI_IMAGE_RESOLUTION_640x480;
d.userColor = false;
d.userTrackingEnabled = false

k = new Kinect(d);
k.start();

addChild(k.bmDepth);;

Colour Stream

d = new DeviceOptions();
d.irEnabled = false;
d.colorEnabled = true;
d.colorResolution = ImageResolution.NUI_IMAGE_RESOLUTION_640x480;
     
k = new Kinect(d);
k.start();
tilt = k.tilt;
addChild(k.bmColor);

IR Stream

d = new DeviceOptions();
d.irEnabled = true;
d.irResolution = ImageResolution.NUI_IMAGE_RESOLUTION_640x480;

k = new Kinect(d);
k.start();

addChild(k.bmIr);

User Tracking

d = new DeviceOptions();
d.depthEnabled = true;
d.depthResolution = ImageResolution.NUI_IMAGE_RESOLUTION_320x240;
d.userTrackingEnabled = true;
//d.binaryMode = true;
//d.inverted = true;
d.removeBackground = true;
d.userColor = true;

k = new Kinect(d);
k.start();
addChild(k.bmDepth);

Skeleton Stream

d = new DeviceOptions();
d.depthEnabled = true;
d.irEnabled = false;
d.colorEnabled = false;
d.nearModeEnabled = false;
d.skeletonTrackingEnabled = true;
d.userTrackingEnabled = true;
//d.depthResolution = ImageResolution.NUI_IMAGE_RESOLUTION_320x240;
d.flipped = false;

k = new Kinect(d);
k.start();


for ( i in k.skeletons )
{
    if ( i.isTracked )
    {
        k.adjustBonesToColor(i);
        
        var c = k.userColor(col);
        s.graphics.beginFill( c );
        s.graphics.lineStyle(2, c, .75);
        
        for ( j in i.joints.keys() )
        {
            var b = i.joints[j];
            s.graphics.drawCircle(b.position.x, b.position.y, 5);
            
            var start = i.joints[b.startJoint];
            s.graphics.moveTo(start.position.x, start.position.y); 
            s.graphics.lineTo(b.position.x, b.position.y);
        }
        
        bmdSkel.draw(s);
        s.graphics.endFill();
        bmdSkel.draw(s);
        
    }
    col++;
}

Interactions

class Navigation extends KinectRegion
addInteractiveChild(s);
s.addEventListener(TouchEvent.TOUCH_OVER, handOver);
s.addEventListener(TouchEvent.TOUCH_BEGIN, handDown);
s.addEventListener(TouchEvent.TOUCH_END, handUp);
s.addEventListener(TouchEvent.TOUCH_MOVE, handDrag);
s.addEventListener(TouchEvent.TOUCH_TAP, handTap);

About

Openfl Native Extension for Microsoft Kinect for Windows SDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published