Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I want to detect a cars in an image and determine the number of cars in term of its lights " shape detection " in my research ,, someone told me to use Aforge.net and use blobs counter ,, I have seen a sample example but I have not understood the function of the blob counter and how to use it to detect the car lights !! can any one help me to understand the function of the blob counter and how to use it ,, or can any one give me a useful link or tutorial !!
Posted
Updated 30-Jan-13 9:14am
v3
Comments
Sergey Alexandrovich Kryukov 18-Jan-13 15:35pm    
What exactly is the difficulty? I produced some basic guidance for your, and all you need would be sufficient understanding of programming and this field. I don't see any need in a special tutorial, just the reference, which is readily available.
If you need something else, you are welcome to ask your follow-up questions.
—SA

Here you go[^].

/ravi
 
Share this answer
 
This algorithm works very well in AForge.NET, and it is very fast. I don't know what did you miss from the code sample (it is quite clear), but you basically need to use the class AForge.Imaging.BlobCounter.

Also, you should remember that the algorithm is supposed to work for blobs on black background. In your case, it looks like you are looking for light car light spots on the dark background, but some cases or opposite, so you need to invert the image. If so, use the class AForge.Imaging.Filters.Invert.

Now, the background may or may not be "black enough". To improve is, you simply need to boost contrast. I never knew any cases where the maximum contrast could be wrong, so use the filter AForge.Imaging.Filters.ContrastCorrection. I always use its property Factor equal to int.MaxValue.

The contrasting might work better if you also adjust brightness slightly before applying the contrasting filter. Use the class AForge.Imaging.Filters.BrightnessCorrection. It's important not to darken or burn too much; it all depends on the initial image, which could be poorly exposed, or exposed not for the region you are looking for blob recognition.

When you find your blobs recognized, it's very typical if you want to select only some blobs. It is likely that some highlights will be recognized as blobs, but they are not the spots of the car lights. In this case, you can use one more filter, which filters out unwanted blobs. You need to apply it after all other adjustments, but before using of your BlobCounter. This is the class AForge.Imaging.Filters.BlobsFiltering. Most typically, you would need to filter out some blobs by their maximum and minimum size.

In some cases, you may want to give the user some UI to adjust some filter parameters, but the search of the "best blob recognition" can also be automated. It heavily depends on how complex your typical scene is. If you accurately use my advice, you can perform successful recognition even in very tricky situations.

Good luck,
—SA
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 18-Jan-13 17:20pm    
I saw your feedback message, thank you for accepting both answers, but... I removed it, sorry.
You see, you should NOT post your reply this way. Please be advised that "Add your solution here" is reserved for the cases when you try to actually provide some help, in response to the question from some other member. In all other cases, you should either add comment to any other post (and the author of the post will get a notification), reply to existing comment, in other cases, use "Improve question". Inappropriate posts may give you down-votes or abuse reports. Not a problem right now though, just please keep it in mind.

By the way, I only noticed your post by chance, as I did not get notification from the site — yes another reason to properly place your posts.

Anyway, you are very welcome.
Good luck, call again.
—SA
Sergey Alexandrovich Kryukov 18-Jan-13 18:46pm    
Oh, no need to apologize, in this case. My note was only to help you to avoid wrong ways of communications in future...
Good luck,
—SA
Sergey Alexandrovich Kryukov 20-Jan-13 13:36pm    
This is such a pleasure to talk to someone who actually was able to use an advice and make things working. (And I remember about your low experience; it only means that you are also quite able to learn and teach yourself, which one of the most important things.)
You are very welcome.
Good luck, call again.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900