Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 18-Jan-13 9:15am
Edited 30-Jan-13 9:14am
v3
Comments
Sergey Alexandrovich Kryukov at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 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 at 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 at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Here you go[^].
 
/ravi
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 693
1 George Jonsson 345
2 BillWoodruff 337
3 Sergey Alexandrovich Kryukov 244
4 Garth J Lancaster 240
0 Sergey Alexandrovich Kryukov 10,764
1 Maciej Los 5,474
2 OriginalGriff 5,472
3 CPallini 3,819
4 BillWoodruff 3,594


Advertise | Privacy | Mobile
Web01 | 2.8.141030.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100