Firstly let me start by showcasing a little game I made using the Kinect sensor and Adobe AIR.
If you would like to make a game using Skeletal Tracking and full body interaction, read on!
In this tutorial series I will be explaining how to get the Microsoft Kinect sensor installed on your desktop PC and ready to use with Adobe AIR.
I will cover the installation of the Kinect sensor, installation of the AS3NUI API (used to interface with the Kinect) – as well as providing a basic Skeletal tracking example.
To follow on you are required to have a Microsoft Kinect sensor with the PC USB kit.
Note, the USB cable may not come with the Kinect if purchased in an Xbox bundle. If you purchase it separately it comes with a cable.
STEP 1- Download and install the Kinect Drivers
The first thing you want to do is download the official Kinect SDK, it will give you all the required drivers. You can also get the required Kinect drivers by downloading OpenNI .However I recommend getting the Kinect SDK from Microsoft.
Get it here http://www.microsoft.com/en-us/kinectforwindowsdev/Start.aspx.
Download the latest SDK as indicated by the red outline below.
Do not yet plugin your Kinect. If you did, you may find that the Kinect doesn’t show any lights flashing and is not functional.
Step 2: Plug in your Kinect Via the USB cable
Plug in the device using special USB cable kit provided in the Kinect bundle. If all went correctly, you should see the green light on the device start flashing.
Step 3: Download the AS3NUI ANE
https://github.com/AS3NUI/airkinect-2-core/raw/master/bin/airkinect-2-core-mssdk.ane
After downloading the ANE, the easiest way to get up and running is to setup in Flash Pro and use it as a compiler. You can use Flash Builder, FlashDevelop, or your fav development environment, but I will only be covering Flash Pro IDE for now.
Open flash and create a new project
- Go the File > Actionscript settings.
- On the Library Path tab, click on the “Browse to a Native Extension (ANE)” button (button to the right of the SWC button)
- Choose the ane file you just downloaded.
Step 4 : Simple Example
Create a document class and paste in the following source
package { import com.as3nui.nativeExtensions.air.kinect.constants.CameraResolution; import com.as3nui.nativeExtensions.air.kinect.data.SkeletonJoint; import com.as3nui.nativeExtensions.air.kinect.data.User; import com.as3nui.nativeExtensions.air.kinect.events.CameraImageEvent; import com.as3nui.nativeExtensions.air.kinect.events.DeviceErrorEvent; import com.as3nui.nativeExtensions.air.kinect.events.DeviceEvent; import com.as3nui.nativeExtensions.air.kinect.events.DeviceInfoEvent; import com.as3nui.nativeExtensions.air.kinect.frameworks.mssdk.data.MSSkeletonJoint; import com.as3nui.nativeExtensions.air.kinect.Kinect; import com.as3nui.nativeExtensions.air.kinect.KinectSettings; import flash.display.Bitmap; import flash.display.MovieClip; import flash.display.Sprite; import flash.display.StageDisplayState; import flash.events.Event; /** * ... * @author John Stejskal * Johnstejskal@gmail.com * www.johnstejskal.com */ public class Main extends Sprite { private var kinect:Kinect; private var cameraBitmap:Bitmap; private var skeletonHolder:Sprite; public function Main():void { stage.displayState = StageDisplayState.FULL_SCREEN //check if the kinect is supported if (Kinect.isSupported()) { //establish the kinect device kinect = Kinect.getDevice(); //declare bitmap that will hold the camera data cameraBitmap = new Bitmap(); addChild(cameraBitmap); //Create an empty spite which will hold out joins/bones skeletonHolder = new Sprite(); addChild(skeletonHolder); //add a kinect rbg update listener (this fires every time the camera frame updates) kinect.addEventListener(CameraImageEvent.RGB_IMAGE_UPDATE, rbg_update, false, 0, true); //listen to when the kinect is ready kinect.addEventListener(DeviceEvent.STARTED, kinectStarted); //Core settings, these will determin how the device behaves, what it see's and what it ignores. var settings:KinectSettings = new KinectSettings(); settings.rgbEnabled = true; settings.rgbResolution = CameraResolution.RESOLUTION_1280_960; settings.depthEnabled = true; settings.depthResolution = CameraResolution.RESOLUTION_1280_960; settings.depthShowUserColors = true; settings.skeletonEnabled = true; kinect.start(settings); //add the main loop in which the skeleton updates addEventListener(Event.ENTER_FRAME, on_enterFrame, false, 0, true); } else { trace("device is not supported"); } } private function on_enterFrame(e:Event):void { //clear all dots to make way for new ones skeletonHolder.graphics.clear(); //loop through all skeletons in frame, up to 2 with as3Nui. for each(var user:User in kinect.usersWithSkeleton) { skeletonHolder.graphics.beginFill(0x00ccff); for each(var joint:MSSkeletonJoint in user.skeletonJoints) { trace("joints :"+joint.name) //Draw a circle on all the joints skeletonHolder.graphics.drawCircle(joint.position.depth.x, joint.position.depth.y, 15 ); } //-------------------o //Points for tracking /* user.leftHand.position.depth; user.rightHand.position.depth; user.head.position.depth; user.rightHip.position.depth; user.leftHip.position.depth; user.rightShoulder.position.depth; user.leftShoulder.position.depth; user.leftElbow.position.depth; user.rightElbow.position.depth; user.neck.position.depth; */ //-------------------o //Some other useful info //trace(user.hasSkeleton); //trace(user.position.world); } } //udates the camera feed private function rbg_update(event:CameraImageEvent):void { cameraBitmap.bitmapData = event.imageData; } private function kinectStarted(e:DeviceEvent):void { trace("kinect has started") } } }
Here is a list of some useful points which can be retrieved through the user object.
user.leftHand.position.depth; user.rightHand.position.depth; user.head.position.depth; user.rightHip.position.depth; user.leftHip.position.depth; user.rightShoulder.position.depth; user.leftShoulder.position.depth; user.leftElbow.position.depth; user.rightElbow.position.depth; user.neck.position.depth;
Once you are tracking the above points, you can do so much cool stuff – like tracking a fist hitting a flash MC, overlay MCs to move with body parts.. etc, Get creative with it.
I have provided a simple functional template of the above code on my github, grab it here:
https://github.com/johnstejskal/as3NuiKinect_template
For easily compiling use the src/main.fla with Flash CS6.
In upcoming posts I will do some tutorials on how top make some simple games with Kinect.
Bye for now!
really cool thx a lot !
great tutorial. thanks.
[…] If you would like to make a game using Skeletal Tracking and full body interaction, read on!In this tutorial series I will be explaining how to get the Microsoft Kinect sensor installed on your desktop PC and ready to use with Adobe AIR.I will cover the installation of the Kinect sensor, installation of the AS3NUI API (used to interface with the Kinect) – as well as providing a basic Skeletal tracking example.To follow on you are required to have a Microsoft Kinect sensor with the PC USB kit.Note, the USB cable may not come with the Kinect if purchased in an Xbox bundle. If you purchase it separately it comes with a cable. […]
Thank you. That’s healpful.
Ah this is a great time saver 🙂
thanks!
Thanks Fillippo! I’m glad you found it useful.
Hi johnstejskal
Amazing, thanks for sharing!
You have other tutorials for kinect?
Hi Lucas, I have put Kinect on hold for the moment, I have an Oculus Rift dev kit 2 comming in soon, so I will try to combine the 2 technologies to make some awesome tutes! thanks for the visit 🙂
Sorry for the Late reply Lucas. Yes I would like to do more Kinect stuff! Is there anything specific you would like to see done with the Kinect that I can post about?
Hi
Do the air works with Kinect 2 as well ? ?
Yes it should work, however Kinect sensor 2 requires the Microsoft Kinect SDK 2.0 which only works on Windows 8.
Hi John,
I really love your work. I am actually doing a Capstone Project that is related to this (Kinect and Flash) for my university thesis at UTS. I am actually stuck in registering the buttons to react with my hands. I am trying to develop a game that will assist people with partial-hearing impairment.
I would really appreciate it if you can please contact me at xynebrix.punzalan@student.uts.edu.au and and assist me with this hurdle of mine.
Your help and expertise is very much appreciated.
Kind regards,
Xyne Brix Punzalan
No Problem Xyne, I would be happy to help where possible 🙂
Will this code work with kinect v2 sensor if I get the SDK2.0..??
Thanks in advance..!!
Can you make a tutorial on how to make this work on mac?
Thank you 🙂
Are you using Kinect V2 (for xbox one)?
Or are you using the original Kinect?
Thank you!
original v1 sensor
Hey, I’m working on a group project in college, we are trying to create an interactive installation using the Kinect for xbox and flash CS6 on windows 8.1.
I dont have flash builder and IDE’s are not something I am familiar to.
We have the AS3NUI and we have gotten as far as having Flash recognise the kinect and outputting a video. but we are struggling with creating any interactivity.
I realise this is not allot to go on, but I’m wondering if you have any advice with this..
Thank you
Thank you very much for this tutorial!!!
got this working in flash… what a life saver
hero…
[…] http://johnstejskal.com/wp/getting-started-with-motion-tracking-using-the-kinect-sensor-and-adobe-ai… […]
Hi, nice work, help me a lot , can you give the detail of how to link your work with flash professional ?
hello, this work really help me a lot , but when I run the program, the screen is black , may I know what`s wrong ?
I have the function on flash professional CS6 , and how to combine your program to interaction ? thank you
Did you try compile with the included .fla ? Black screen can mean the Kinect drivers aren’t installed properly. Check for any Error logs in the output panel and let me know if any.
Hi sir… can u help me? I’m new in programing kinect and i really need to know because it is for my project in our university…
Wat i need is how to create a fix xyz axis on kinect and my origin is the right shoulder…thanks lot
Hi john
I got problems about the tracking points, help me please.
Hi john
I got problems about the tracking points, i dont know how to use the next code:
user.leftHand.position.depth:
please help me.
This looks amazing! I checked different setups with Flash and Kinect, this one looks like the easiest one without download shit tons of unnecessary stuff that does not work anyway. Thank you!
Thanks Dovile, I too had to dig through a lot of the shit to get the simple implementation. I hope you find it useful. 🙂
I’m was supposed to follow this tutorial. Unfortunately, my kinect doesn’t fit into my pc. I was able to buy the kinect adapter on ebay to be delivered this april. I hope it works! 🙂
Hi Sir johnstejskal,
I tried to download your sample at github and compile but the ide prompts an error. “Test movie launch failed”. im using air 3.9.0.1030. I hope we can make this work.
Thank you!
air 3.9 is very old… sounds like an air sdk path issue.. did you have any luck fixing your problem?
Hi, how about the kinect flash game with the use of hand only?
Yeah sure, that’s what Kinect is for… it’s all in the sample code I provided 😉
Hi, will this work with the latest Windows Kinect SDK v2 and the latest AIR?
Thanks a million 🙂
Hi, sorry for repeated questions but time is an issue here…
Can this be used with the latest Kinect SDK or would it be better to install an earlier one – and if so which did you use?
(If you could reply to my home email – andy@andyfoulds.co.uk – as well it would be a great help 🙂
Many thanks
Andy__Foulds
i have the next problem
Intento de inicio y conexión con el reproductor mediante la URL C:/Users/Arg Rdz/Desktop/as3NuiKinect_template-master/as3NuiKinect_template-master/src/main-app.xml
Sesión de depuración finalizada.
Adobe (R) AIR (R) Debug Launcher (ADL)
Version 3.2.0.2060
Copyright (c) 2008-2012 Adobe Systems Incorporated. All Rights Reserved.
The -extdir argument must specify an existing directory.
usage:
adl ( -runtime )? ( -pubid )? -nodebug? ( -profile PROFILE )? ( -extdir )? ( -screensize SCREEN_SIZE )? ? ( — … )?
adl -help
PROFILE : mobileDevice|extendedMobileDevice|desktop|extendedDesktop|tv|extendedTV
SCREEN_SIZE : ( x:x )|PREDEFINED_SCREEN_SIZE
PREDEFINED_SCREEN_SIZE : iPhone|iPhoneRetina|iPod|iPodRetina|iPad|Droid|NexusOne|SamsungGalaxyS|SamsungGalaxyTab|QVGA|WQVGA|FWQVGA|HVGA|WVGA|FWVGA|1080|720|480
i had installed AIR 22, are you have idea?
Hi Sir johnstejskal,
i have kinect for xbox one + kinect adaptor for windows…
but my computer is WINDOWS 10
intel core i5-4200u
NVIDIA GeForce 820M with 2GB Dedicated VRAM
and have USB3 port
..and i read your comment with LUCAS on 11 july 2014
“…Kinect sensor 2 requires the Microsoft Kinect SDK 2.0 which only works on Windows 8. ”
..can i use my kinect with WINDOWS 10 ?
please help me
thank you sir
Hi Sir johnstejskal,
i have kinect for xbox one + kinect adaptor for windows…
but my computer is WINDOWS 10
intel core i5-4200u
NVIDIA GeForce 820M with 2GB Dedicated VRAM
and have USB3 port
..and i read your comment with LUCAS on 11 july 2014
“…Kinect sensor 2 requires the Microsoft Kinect SDK 2.0 which only works on Windows 8. ”
..can i use my kinect with WINDOWS 10 ?
please help me
thank you sir
*** i send this message to you again because the first message not show me