Samurai Potato Blog

The place where things that should make sense... Don't....

20 May 2008

Vision Systems... There must be an easier way to take over the world!

Written by Glasswalker ( Contact the author of this post )
Published on May 20th, 2008 @ 11:59:59 am, using 716 words, 432 views

I am having some problems with the vision system I am coding for the RoboChamps Amazed Challenge I talked about in a previous blog post. The system is coming together very nice, but now it is in the fine tuning that there appears to be an error somewhere in my logic. I will give below 2 samples of data, and an explenation of the algorithm (in pseudocode) so it is easily understood. Then below that I will describe the details of my problem. (and provide links to the actual source that accomplishes this).

Sample 1

..........
..1.1.....
..111.....
..1111....
...1.111..
.111.11.1.
.11..1..1.
.1111.111.
.1..1111..
..........

Sample 2

..........
.111......
.1.11.....
.11111....
..111222..
.11112222.
.111.2222.
.111.2222.
.111.22...
.111......

Algorithm:

Walk through each pixel, starting top left, ending bottom right, scanning horizontal rows.
For each Pixel:
  If pixel is not "." then:
    if it has no ID associated already:
      Assign a new ID
  Scan all immediately adjacent pixel (8 adjacent pixels):
  for each pixel:
    If it is the same number as the center pixel:
      If it has an ID assigned already:
        Mark the ID of the center, and the ID of the adjacent one, as related
      If it has no ID assigned already:
	Assign it as the same ID as the center one.

Now Clean up the relationships:
  Walk through each "relationship" which has 2 values to start:
  For each relationship:
    Look through all other relationships farther ahead in the array than this one.
    For each scanned relationship:
      If this scanned relationship contains any int from the original relationship:
        Append any new ints from the scanned one onto the end of the original one.
        Delete the scanned relationship from the main list.

Then walk through each pixel again
for each pixel:
  If this pixel's ID is not zero:
    walk through each relationship
      for each relationship:
        If this pixel's ID exists in this relationship:
          Set this pixels ID to the ID at index 0 of Relationship.

Now all pixels should be renumbered so all contiguous IDs are resolved.

Now walk through the pixels again
for each pixel:
  If there is already a blob ID for this Pixel's ID, then
    Is this pixel farther left than the lefthand edge of the blob?
      IF so then update the blob's lefthand edge to be at this pixel
    Is this pixel farther right than the righthand edge?
      If so then update blobs righthand edge to be this pixel
    Is this pixel farther up than the top edge?
      if so then update blobs top edge to be this pixel
    is this pixel farther down than the bottom edge?
      if so update blobs bottom edge to be this pixel.
  If there is not already a blob ID in the blob array for this Pixels ID then
    Create a new blob ID in the blob array and give it this pixels ID.

Now we have an array of each distinct blob in the image
Each with an ID and a defined rectangular outer boundry for it.

The Problem:
In an image such as Sample 1, only one type of object is visible. It detects the blob perfectly, and puts an accurate bounding box around it.

In an image such as Sample 2, there are 2 adjacent blobs of different types.
This example tends to confuse my code, and instead it sees many small blobs of either all 1, all 2, or mixed 1 and 2 type pixels.
From what I can gather this should not be possible with my algorithm as described.
I have stepped through the code extensively and cannot find the problem. I am not sure if the issue is in the relational sorting, or if it is in another stage of the vision system.

Here are a couple images of the vision system in use in MSRDS environment. The images on the right show the actual scene, and on the left is what the robot is interpreting.
The first image shows a scene with 2 objects in it, and you can see how the detected bounding boxes are broken up and smaller
The second image shows a scene with only one, and suddenly detection is perfect (all I have done is slightly turn the robot, so it is the exact same object)

Also here are links to the source code:
This is the main algorithm for blob detection: http://pastebin.com/m5a4bea0a
(encompases all the above pseudocode besides the cleaning up relationships part)

And this is the cleanup relationships code: http://pastebin.com/m63b15850

05 May 2008

An army of robots you say??? Interesting...

Written by Glasswalker ( Contact the author of this post )
Published on May 5th, 2008 @ 09:35:03 am, using 444 words, 152 views

So I found out about this new project by microsoft a week or two ago. They launched it in late April. Called Microsoft Robotics Development Studio (MRDS). At first I thought it was a half baked way for MS to get into another market, but after looking at some of the technology behind the platform, it’s quite ingenious… It is really well made and well thought through.

The system is entirely centered around Visual Studio, developing for robots using any of the known .net languages (I am using C# for example). which really makes it easy to get into for existing developers. Also the entire system is done using Services, which is very nice (and very similar to current enterprise development trends right now).

Anyway, alongside the launch of the product, they launched a community driven contest. For anyone to participate in, free to download the software, and one other great feature I forgot to mention about MRDS… It allows 100% simulation of a real robot in a 3d environment. With full physics and everything. So you can write your code for the sim, test, debug, and play with it, then take that same code and it will run out of the box on the real thing. Very nice concept. Anyway the sim is included so no need to have a real robot to compete, because all the competitions are done in the simulated environment.

It’s very very cool. So I am working on my entry for the first challenge. We will see how it goes. Been a long time since I have written code for .net, so I am getting back up to speed there, and back in the day I worked with .net, I didn’t do any services stuff, (while I know about it from my IT work, I have never first hand coded in that paradigm). So It’s a bit of an adjustment for me.

Either way I am coming along alright. The first challenge is a maze, and I have the robot pretty reliably navigating the maze and avoiding obstacles. Now the main challenge is avoiding the traps placed throughout the maze, and finally improving efficiency and speed.

I have till the end of may, so we will see if I can win it.

(did I mention there are nice prizes for these challenges, in the form of REAL robots, that are worth a fair bit of money. Gives an opportunity for me to get a real robot to work on in the future that I normally wouldn’t be able to afford, so I hope I can win it!).

Well that’s all for now, I will update later as things progress!

Samurai Potato Blog

This is our Blog. We are using it to journal our deeds and thoughts, in preparation for when Wombats rise to power and enslave the human race.


September 2010
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    

Miscellany

XML Feeds

Users Currently Online

  • Guest Users: 2

The Extras

Blog Flux Directory
Contact the admin  /   Custom B2Evo skin design by Andrew Hreschak
Credits: blog soft | low cost hosting | adsense