RealBasic: XBOX 360 Kinect source code

Note: This is a PC only project.

I had some requests for the XBOX 360 Kinect source code so I decided to put it up on the blog. It contains an encrypted object KinectCanvas that can be freely used in your own projects and an example on how to use it.

The blob detection is done in pure RealBasic. Provided is a PC driver for the kinect. The only thing this gives back are pictures, just like a normal webcam. As it is a Kinect, we also get a depth picture and that is the one we’ll use to do the fun stuff. The depth picture is something like this:

For the attached demo project this is my setup at home:

This is how you install the included driver:

1. Unzip everything to a folder (let’s say c:\KinectCanvas).
2. Start CL-NUI-Platform- to install the kinect driver
3. plug in your Kinect and power
4. start KinectCanvas.exe or open the source code

You may have to change the position of the kinect camera by using the motor functions:

ret = KinectCanvas1.startMotor
' value between -8000 and 8000
ret = Kinectcanvas1.SetMotorPosition(-4500)

The most import function is the FindBlobs() function:

' for the moment use these params as they are for hand detection
aantalblobs= KinectCanvas1.FindBlobs(110, 170, 15, 150, false) 

Here are the available functions, but not all of them are tested yet:

FindBlobs (MinRangeCM as integer, MaxRangeCM as integer, DepthOfBlobCM as integer, SizeOfBlobPixels as integer, Optional CheckGestures as Boolean = false) as integer
GetCameraColorFrameRAW(MakePicture as boolean, timeOut as integer) as boolean
GetCameraColorFrameRGB24(MakePicture as boolean, timeOut as integer) as boolean
GetCameraColorFrameRGB32(MakePicture as boolean, timeOut as integer) as boolean
GetCameraDepthFrameCorrected12(MakePicture as boolean, timeOut as integer) as boolean
GetCameraDepthFrameCorrected8(MakePicture as boolean, timeOut as integer) as boolean
GetCameraDepthFrameRAW(MakePicture as boolean, timeOut as integer) as boolean
GetCameraDepthFrameRGB32(MakePicture as boolean, timeOut as integer) as boolean
GetMotorAccelerometer(byref x as integer, byref y as integer, byref z as integer) as boolean
SetMotorLED(mode as integer) as boolean
SetMotorPosition(Position as integer) as boolean
StartCamera(tmpTimer as KinectTimer) as boolean
StartMotor() as boolean

The makepicture param is not used yet. It may be build in to speed up things. For the moment this is what you do if you want to get the picture for example from the depth camera in 32 bit colors:

' in the KinectTimer1.Action
Dim Ret as boolean
Dim a as integer
Dim b as integer
Dim tmpPic as picture
Dim surf as RGBSurface
Dim Tel as integer

Ret = KinectCanvas1.GetCameraDepthFrameRGB32(false, 1000)

tmpPic = newpicture(640, 480, 32)
surf = tmpPic.RGBSurface

for a =0 to 479
    for b =0 to 639
        surf.Pixel(b,a) = rgb(KinectCanvas1.CameraData.byte(Tel),KinectCanvas1.CameraData.byte(Tel+1), KinectCanvas1.CameraData.byte(Tel+2))
        Tel = Tel + 4
next tmpPic, 0,0

This code will result into the depth picture you see on top of this article.

The code is very experimental but you can use it to play with the Kinect in RealBasic!

The source code and driver:
A video of what the demo does, but in West-Flemish 🙂

Until next time!

Click here to Donation if you like my work


About Alwaysbusy

My name is Alain Bailleul and I'm the Senior Software Architect/Engineer at One-Two. I like to experiment with new technologies, Computer Vision and A.I. My projects are programmed in B4X , Xojo, C#, java, HTML, CSS and JavaScript. View all posts by Alwaysbusy

4 responses to “RealBasic: XBOX 360 Kinect source code

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: