Starting BitmapBlobDetection

Thanks to the NUI Group forum, I found eyePoke library (http://touchevent.riaforge.org/). It does "fingers detection" for images coming from webcams, and it also does events processing, being capable to emulate mouse events. It is written in AS3 and, due to the use of getColorBoundsRect(), it has a great performance.

Nevertheless, it has some little problems, that made me start a new library, based on the work with blobDetection:

  • it is focused on the situation of processing images from a webcam, intended to monitor a multitouch table. It doesn’t accept bitmaps as input; it takes images directly from the camera (using Camera.getCamera()). And I want a more flexible library, that can process bitmaps, video and, also, the camera;
  • it is focused in fingers detection. If you want to track another kind of blobs (bodies, objects, anything), maybe you will need to make some changes;
  • its optimization is based on the subdivision of the area containing the fingers/blobs.  If the blob is greater than a specified width/height, the image is subdivided to find smaller blobs. But, what if you need to track different kinds of blobs, which have different dimensions?
  • it keeps together the code responsible for the image acquisition, events dispatching and for the blob tracking. I want to keep these parts separated, each one in a module;
  • finally, its license doesn’t allow the use in commercial projects. Most of ActionScript libraries are free to use in any kind of project, and I think that this makes more people use and improve an AS library;

So, the main features of the new library, BitmapBlobDetection, are:

  • It receives a BitmapData object. It has to be a two-color bitmap, but not necessarily black and white. You can set the blob and background color, if you don’t want to use white for blobs and black for the background. All you need to do is to use the specified colors in combination with threshold() method of BitmapData() to get a two-color bitmap;
  • Using a BitmapData object is nice because you can process images from different sources (image files, video, webcam);
  • It starts the process of blob detection using getColorBoundsRect(), and it tries to subdivide it, but first it makes some tests;
  • First, it checks if there is any blob that occupies both lower and higher halves of the area returned by getColorBoundsRect(). If there is no blob, the area can be divided horizontally;
  • Second, it checks if there is any blob that occupies both right and left halves of the area. If there is no blob, the area can be divided vertically;
  • Based on these two tests, the area returned by getColorBoundsRect() can be divided in 2 or 4 areas. If it can’t be subdivided and if the area is greater than the maximum dimensions of a blob, we launch the blobDetection algorithm, to find the blobs inside the area selected by getColorBoundsRect(). But, if the blobDetection algorithm finds a blob that is greater than the max dimension, it is not subdivided. The max dimensions are used only to save some calls to the blobDetection algorithm;

The use of getColorBoundsRect() made a good performance increment. And it also gives you the possibility of finding only the blobs bounds, without processing their contours. Usually, we won’t need their contours, so we can save a bit of CPU time.

For its turn, the use of blobDetection algorithm give us the capability of detecting the three blobs in the image below:

I made some tests with the LEDs video. The frame rate changed from 10fps (in a quadcore) to 24fps (detecting only the blobs bounds) and to 22fps (detecting its contours too). I will post the sources soon.

Blob detection (bounds only)
Blob detection (edges and bounds)

7 Responses to “Starting BitmapBlobDetection”

  1. BlobDetection in AS3 | v3ga Says:

    […] adapted the Blob Detection library for Actionscript and extended the functionalities into a BitmapBlobDetection […]

  2. login Says:

    You are doing a wonderful thing here on the Internet. I wish you the very best. Kindest regards.

  3. Filthy RIA : Introduction to Computer-Vision Says:

    […] can be already used to create a complete solution, from input to output, by itself and I’m sure BitmapBlogDetection after a couple of bitmap filters can help you doing a multi-touch system in no time, and most […]

  4. gordee Says:

    hi this is very good news to me. My colleague and I recently made a multitouch table using touchlib and the AS3 libraries. Does this remove the need for infrared lighting? Is there any way to find out more about this? Also is there a thread on Nuigroup?

  5. admin Says:

    no, this doesn’t remove the need for infrared light. I don’t know if there is a thread about it on Nuigroup. If you don’t want to use infrared light, give a look at EyesWeb. It makes backgrouns subtraction, so maybe it can be useful for your needs.

  6. MYO Blog » Blog Archive » Development Research Says:

    […] research for our needs. Motion Tracking using a webcam and AS3 Motion tracking Soulwire Multi point detection using infrared More motion tracking like Soulwire Draw stuff using motion detection [video] More Drawing with […]

  7. Smart-Page.net » Blog Archive » Multiple object motion detection Says:

    […] is using Justin Windle´s “MotionTracker” approach, Andrei Thomaz´s port of the blobDetection-library from v3ga and Josh Chernoff´s version of the MJPEG streaming-component by Doug Hughe […]

Leave a Reply