Hi!
Before being on holidays I wanted to complete this other personal project using my favourite two toys: Python and Blender :D
Today I’ll show you how to get with cheap technology such as a webcam, a pen and a laser, cool things like object tracking in the BGE. Of course when you don’t have enough money to buy awesome (and really expensive..) hardware, then you go with software solutions.
First of all, what’s object tracking? For those who don’t know it yet, it’s a “is the process of locating a moving object (or several ones) in time using a camera. An algorithm analyses the video frames and outputs the location of moving targets within the video frame.” (from Wikipedia) So basically, it’s like the computer is able to see and detect moving objects. There are many approaches to this, I used laser lights and color-tracking. Somehow color-tracking is simpler, but my plan is of course to do full motion tracking in the future. :D Unfortunately I couldn’t use OpenCV because my webcam was not supported, so I used Videocapture to get PIL data from the webcam, Python Imaging Library (PIL) to handle the matrix and sockets to communicate internally with Blender. Why sockets? Read my previous post :)
Laser tracking is simpler, however you can’t have depth which restricts movements in the BGE to two dimensions. On the other hand tracking objects is good if you want to have a full 3D interaction. How do you get the depth? Just checking the size of the bounding box area, when it gets bigger it means the object is closer and viceversa. Another important concept in this is the threshold. You need some time to tune it in order to get a perfect tracking. Spheres are the easiest to track since the shape doesn’t change if you rotate them. I didn’t have any sphere, so I used also a red d20 from my dungeons and dragons kit :D
Anyway, stop talking, enjoy the video and if you have question post it below ;)
Sources will be available in a couple of days, I need to clean them up a bit from test code and write also some comments. If you are interested in another cool thing about webcams and BGE check this video made by Nathan Letwory, one of the Blender’s coder living here in Finland who I never had the pleasure to meet, but just exchange a couple of emails :D

Sources available! :D Click here to download them!

Akta

Edit: look at what Mike Pan did using BlenderTrack, amazing and brilliant idea. I was actually wondering how to head track using this script, but Mike was faster and smarter than me :D
Enjoy his video and let’s see what comes next!


Share →

3 Responses to Object and laser tracking in Blender

  1. Therizinosaurus111 says:

    Hi,

    I wonder, could you use this script to track a an object from two different angles? Using two cameras recording sumultaneously?

    I’m thinking that tracking an object in 2D, like your laser pointer, could be used to track an object moving in 3 dimensions.

  2. AdamT. says:

    Hi, I was wondering how to work your program. I am new to programming in Blender, I usually use it for models and program in Unity. So, how to make the program work after downloading sources?

  3. scott says:

    i know this is for windows but is there any hope of getting this to work on linux

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>