Category Archives: Kinect

Realbasic: Upcoming tutorials on robotics

In our last lessons, we did a lot of work on Computer Vision and filters. In the upcoming lessons, I would like to use some of them together with a lot of new things to create a framework for robotics.

As you know me from my previous lessons, I don’t always take the conventional path (like in our pixel precise mouse detection lesson).

In the robot vision lessons it will probably be the same. If I can find a shortcut instead of complicated math, I will do so.

Some things I would like to cover:

– As not all of us have a robot, we’ll make a simulated version of it
– Build a framework with sensors for our robot
– Let the robot find the shortest path in a known plan (like a house in the left picture)
– Let the robot map an unknown plan (like in the right picture)
– Let the robot find objects in our plans (known and unknown)
– Let multiple robots work together
– …

So a lot of exciting stuff is coming up!

Robotics is a new adventure for me too so leave a message if you have ideas for these tutorials.

And last but not least, I want to thank all of you who followed the previous tutorials. I hope I inspired some of you to make some great things in RealStudio.

A Merry Christmas and a Happy New Year to all of you! Until next time…


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

Example of Using the XBox 360 Kinect in Realbasic

This is my first attempt to control a pc with the Kinect. It’s written in Realbasic.

The attached video is commented in West-Flemisch so here is what it is about:

It shows a list of mobile phones on top where you can scroll through by making gestures. You can pick a phone, drag it out and place it on the desktop. With two hands, you can then resize the picture, or grab it and place it somewhere else. You can control the menu on the left side by pointing to it with a finger. Then you get some more information about the phone.

Here is the demo:

%d bloggers like this: