Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I've got a project that requires me to use C# to detect fire and smoke in a video.
For now I am just starting to try and detect red and glow in a video.

I'm also interested in exploring the bump map matrix thing, if anyone can help.

I'm also recommended to use AForge.NET framework. Which I have 0 knowledge in.

please help :confused:
Posted
Updated 6-Jan-11 21:37pm
v4
Comments
Sergey Alexandrovich Kryukov 23-Dec-10 1:38am    
Is it for indoors, outdoors or both? It may make a big difference -- see my answer (very preliminary).
Sergey Alexandrovich Kryukov 23-Dec-10 1:43am    
Also, could you modify the title of your question (it your really hope for help)? Name it "fire detection", because it can be very different from motion detection. I know many people who dealt with motion detection (including those at CodeProject) but hardly one looking for fire detection.

People are afraid of intruders much more than of fires! Huh?
Justuskun 23-Dec-10 3:02am    
sorry about that, i've just changed the title, its a indoor surveillance camera so actually I'm required to do it in colored video and also monochrome video.
So I'm actually more interested in learning to filter the video into monochrome and detect the pixels characteristic of a fire ( white among black )
Sergey Alexandrovich Kryukov 23-Dec-10 3:11am    
I would say indoor make the problem easier. I would sorry if infra-red camera is out of options -- could be much better then visible part of spectrum for the flames. I think you're required to design a budget-saving system, which is not easy. Interesting, anyway.

What do you mean "also monochrome video"? Does it mean 1) your system can rely on reading from both cameras at the same time; or 2) you system is required to provide two options: one working with a single colored video camera, another option -- with single monochrome? or something else?
Justuskun 23-Dec-10 4:49am    
I meant 2, I have to be able to detect from a single camera/video , I've decided to just go ahead and try and solve for the monochrome, since if it works for the monochrome video it'll probably work for the colored one too.

and thank you so much for your interest and help!:D

so do you know of any good guide that actually deals with bump map ?

Andrew Kirillov, http://www.codeproject.com/script/Membership/View.aspx?mid=1181072[^] is the author of AForge.NET and is a very knowledgeable person; he would be able to give the most help.

A have a naive idea about smoke detection. You can evaluate global level of contrast in the picture. The smoke will degrade contrast very well. The sample (no-smoke) contrast level should be re-taken from time to time. Unfortunately, it cannot tell smoke from fog :<.

If you think the flame is always red, you're wrong.

Also, the flame will be much more visible and detectable in infra-red, not visible part of spectrum. Practically, fire will look as "a lot of light" versus "almost no light" if you totally block visible light and see only near infra-red; I know for sure.

Related article by Andrew Kirillov
Motion Detection Algorithms[^]
 
Share this answer
 
v3
Comments
thatraja 23-Dec-10 2:40am    
Added link for quick navigation for enquirer. cheers :-)
Sergey Alexandrovich Kryukov 23-Dec-10 3:03am    
thatraja, thank you very much for addition to my Answer.

Justuskun, however again, don't forget that fire detection can be very different from motion detection. First of all, fire might pass motion detection (false negative) if it develops slowly. In motion detection the key problem is the threshold of the motion. Secondly, for fire direction you might need a quasi-static method.
thatraja 23-Dec-10 14:10pm    
Forgot to vote you. 5!
Justuskun 23-Dec-10 19:50pm    
What is quasi-static mathod? I can't seem to find that code in the internet
Sergey Alexandrovich Kryukov 25-Dec-10 3:01am    
Sorry for rather arbitrary terminology. This is a methodical term typical for physics. This is when you take a non-static (strictly speaking) model and figure out that the motion is relatively slow compared to other critical speeds (for example, if a piston is moving slowly enough that thermal conductivity has enough time to consider system inside cylinder in equilibrium); and, based on that, you apply such approach to the analysis of the system, which considers a system's static states first, and consider motion for next iteration of correction of the calculation, like in Perturbation theory.

This can be exactly a case in your fire thing. Imagine you take a sample picture of non-fire situation (in industrial robotics it is often considered as a part of "teaching"), in presence of human operator. The fire situation is evaluated based on comparison of just two frames: the sample and the present. This would work, however, if general lighting condition never changes, which is hardly the case. Let's consider slow motion: let's make the following iteration: when we resolved then the new (current) frame shows non-fire picture, from time to time replace sample with the most recent non-fire picture. So, I called this quasi-static, because it is based on comparison of two (or few) static pictures, fast motion is not considered (and can be effectively canceled out), but on top of it, slow motion (like change in daytime lighting condition is taken into account as a "slow" correction procedure).

The comparison criteria could be some kind of correlation function... I don't know. This is just a first idea; different combinations can be considered as well as timing parameters. Something to think about...

What do you think? Can it make sense?
I found that your handler videoSourcePlayer_NewFrame is never called. In turn, this is because Initializevideo is never called. I simply called Initializevideo from the form's constructor (is it appropriate to call it just once, or you need to call it on every stream again and again? (I don't think so)), and now the NewFrame event is fired and your handler is called. I don't see any visual effects, but now this is your problem. The bug is found.

That was easy to find, but the code is hard to read. This is the only reason for the bug -- you have compromised control and vision just because of some (minor) mess. You need to do some steps:

1. Stop doing Microsoft suggested all-design-time way -- it's just for cool demos and lamers. I mean, simply remove all auto-generated codes setting events. Do it in manual code in one place (see some suggestion below). Use clear lambda syntax:

C#
MyComponent.MyEvent += (sender, eventArgs) => {
/* some handler code here:
   using sender or not,
   using eventArgs or not...
*/
}


2. Please create another source file for the form (the class is partial, so you can have as many as you want).

3. Please separate your own code from auto-generated, moreover, UI from logics (maybe create another source file for the form: you will have 3 files: 1) your own UI aspects, 2) your own video aspects, 3) Microsoft auto-generated stuff (which is already there)

4. From Properties node, remove everything except AssemblyInfo.cs until you actually use this crap (good chances are -- you will never use them; resources are better in separate Resources directory; you will create them at any moment).

5. Create one single method to setup all events in one place (maybe, two: SetupUiEvents and SetupVideoEvents in syntax shown in (1)). Call both methods from the form constructors, better at the very end.

6. You should never submit .\bin .\obj *.suo, (also *.user, etc.). You need to know exactly what files belong to the source.

That's it. This layout maybe 1) not perfect, 2) too much of my own style; no matter, still better then yours; with time, you'll improve it closer to your taste. I mean, you may choose not to do put things in order in this way, but consider this: I spent only few seconds to discover the bug, but... how long? well, wasted too much time to review where is what. Next time it may bother me too much to take care.

As I answered your question precisely, I think you should accept this answer. A good vote will not hurt either.
 
Share this answer
 
v6
Comments
Sergey Alexandrovich Kryukov 7-Jan-11 2:51am    
Any feedback?
Justuskun 7-Jan-11 3:10am    
Thanks again for answering my questions, most of the code i used was from sample projects, now i'll try using this method to create a new project.
Dalek Dave 7-Jan-11 3:38am    
Excellent Answer.
Nuri Ismail 7-Jan-11 12:00pm    
+5 for the excellent answer.

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