Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Recognise a object in an image

Posted on 2006-07-12
7
206 Views
Last Modified: 2010-04-05
I need a script that recognises an object in an image.

Lets say I have a picture (a jpg or bmp file) of a room, and in the room is a red ball. The image hast the size of lets say 400px X 400px big. I need a good script that tells me the coordinates from the rectange in which the red ball is, so if the red ball is in the center of the picture the script should give me a rectangle like this: TRect(180, 180, 40, 40).

The best would be if I could "feed" the algorithm with a clean photo of the object and it would recognise it in the picture. It only needs to recognise clean objects like a ball or a box that has a bright color.

Important is that I only need the rectagle, nothing more. I hope to find here some good help.

Thanks!
0
Comment
Question by:KBunk
7 Comments
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 17096100
is the object that you are searching for always the same size?
0
 

Author Comment

by:KBunk
ID: 17097266
the object itself yes, but in the picture the object may be further away and thus smaller or nearer and bigger... the purpose of this is to make my hexabot (a spider robot with 6 legs) able to recognise a red ball and follow it. For this I just need an algorithm that solves me the above mentioned problem.

It is not important in which language.. best would be delphi, but any other language woul do it to. Does maybe someone know any open source projects or sdk that handle this?
0
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 168 total points
ID: 17105574
without googling, 1 method off the top of my head would be to get a "magic wand" routine, like many paint programs have, and perform the routine at various places in your image (eg. every "half the minimum width of the image you are trying to find"). then compare the "shape points" from the "magic wand" to the shape you are trying to find (allowing for size, so you will want either angles, or % change rather than just x,y)

another thought I had is you could do a mask on "red" so everything else is removed from teh image. it's then just a simple loop to find the "red" objects, and find their borders.
The problem with tracking a red ball is the light. you get light spots on it and the colour quickly fades making it hard to find. Make the ball matte, not shiny for a start.

I checked out some other EE questions on the subject, and the general theme seems to be
use as few colours as possible.
shape recognition is usually made of the following steps:
1) contour extraction (usually made by a convolution mask applied on the image)
2) Removal of isolated pixels (and small groups of pixels too)
3) Recognition of the borders (previously extracted and cleaned) you have to find coordinates of segments that best fit with the contour pixels

some c++ references here

http://users.isr.ist.utl.pt/~alex/resources.html
http://www.cs.cmu.edu/~cil/v-source.html
and autotrace my have some possibilities
http://autotrace.sourceforge.net/

sorry I couldn't be of more help.
0
 
LVL 17

Assisted Solution

by:Wim ten Brink
Wim ten Brink earned 166 total points
ID: 17106922
Unless I am mistaken, yo have multiple images which you can compare with each other. So what I would do is first "subtract" the images from each other and see where the two are different. If two images are identical, nothing will have moved. But if something has moved, then the two pictures will be slightly different and basically, what you want to analyse are the differences, not the whole picture.
Once you know the locations of where these differences are, all you need to do is check out the shapes in those locations. If you find a red ball there, using the method described by TheRealLoki, then you'll have found your target.

But you will have to deal with other issues too here. First of all, it sounds the pictures are coming from a webcam or whatever. This means that you will have to keep in mind some slight variances in lights and shadows in the two pictures. And if your robot can turn it's head or walk around, you will also have to adjust your calculations to include the small amounts that the picture might have changed, meaning that the area that you're comparing will be a bit smaller than the whole picture. For example, your bot moves it's head slightly to the left. This means that your 400x400 pictures will be completely different if you just subtract them. You will have to find the area that picture 1 and picture 2 have in common and just subtract compare those two pictures. (And you'd also have to check the area that was added to the new picture in case the ball turned up in that area.

You're dealing here with a very complex situation which requires very good math skills and good knowledge of certain algorithms. Even the experts haven't found good solutions for this.
0
 
LVL 26

Assisted Solution

by:EddieShipman
EddieShipman earned 166 total points
ID: 17111600
If it always the same color...

You can use the BitmapToRegion code here: http://www.delphipages.com/threads/thread.cfm?ID=34151&G=34042

Set the transparent color to the color you want to detect, then combine the region returned with a region
that encompasses the entire bitmap to get the region that contains the color. Then check the location of the
spider to the "ball" using PtInRgn
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question