Zone setup vs Alarm numbers

Forum for questions and support relating to the 1.28.x releases only.
Locked
liderbug
Posts: 125
Joined: Wed Dec 19, 2007 4:46 pm

Zone setup vs Alarm numbers

Post by liderbug »

Not quite sure how to phrase this ...

I have a camera, I setup a zone and use say "Default" preset.
Then later I get an alarm. I'm having problems (mental) with the numbers in the alarm spread sheet vs the number in the zone setup (min/max etc). Can someone give a simple how to? Total Score vs Max Blob? Max Area? What?

Thanks
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Zone setup vs Alarm numbers

Post by asker »

The score is a "function" of the values you put in, not quite 1:1 mapped, according to what I see:

a) Scores for triggered (OPT_Trigger), Signal reacquire and forced via web (Force Alarm) are static - which makes sense - lets ignore those
b) Lets focus on scores for motion detection:
b.1) The score computation is triggered here: https://github.com/ZoneMinder/ZoneMinde ... .cpp#L1445. At its core, it calculates a "Score" value for each zone that says there was motion and adds them together (and then does a *2 or /2 adjustment - why I am not sure - more on that later)

Diving into what MotionDetect does:
b.2) It first iterates though all preclusive zones, and adds up individual scores of each zone, if motion was detected (checkAlarm) https://github.com/ZoneMinder/ZoneMinde ... 3475-L3508 (we still don't know how individual scores are calculated - lets get there later)

b.3) Then it goes about iterating through all the active zones of the monitor and adds up the score of each one to the same score variable used in b.2) https://github.com/ZoneMinder/ZoneMinde ... 3521-L3545, if motion was detected there (checkAlarm)

b.4) Then it goes about doing the same thing for inclusive and exclusive zones https://github.com/ZoneMinder/ZoneMinde ... 3549-L3596

Then it returns the value of summation (in other words, the value of score == sum of some magical "score" value for each zone where an alarm was detected)

So now lets dive into the magical "score" computation. The magic seems to happen in zone->Score() & zone->CheckAlarms() so lets see both

zone->Score() is just a function that returns score value, so we can ignore it (https://github.com/ZoneMinder/ZoneMinde ... one.h#L137)

CheckAlarms is here: https://github.com/ZoneMinder/ZoneMinde ... e.cpp#L199

The magic score math starts here: https://github.com/ZoneMinder/ZoneMinde ... e.cpp#L273

1) At it's essence, it computes the % of "changed" (pixels/filtered pixels/blobs) relative to the surface area of the zone. It starts with alarm pixels, then filtered pixels then blobs. For example, for alarmed pixels (stage 1) check, it figures how how many pixels are alarmed, them compared it to your min and max you specified, if it is less than min or more than max, it returns false. If it is in range, score is calculated as as % to the zone area defined (https://github.com/ZoneMinder/ZoneMinde ... e.cpp#L273)

The same score computation applies to filtered pixels https://github.com/ZoneMinder/ZoneMinde ... e.cpp#L368
and to blobs https://github.com/ZoneMinder/ZoneMinde ... e.cpp#L667, each time overwriting the value of score

In other words, the final score value is a % of the alarmed(pixels, filtered pixels, blob area) relative to the zone area

Finally, it does an adjustment here - https://github.com/ZoneMinder/ZoneMinde ... e.cpp#L724
if the zone is "inclusive" it halves the computed score and if its exclusive it doubles the score.

Inclusive zone == triggers an alarm only if some other active zone also has an alarm
Exclusive zone == triggers an alarm only if NO other active zone also has an alarm

There must be some concrete logic to why this related to halve the score/double the score - I did not quite understand why

Hope this helps. I'd love to know why scores are adjusted for inclusive and exclusive zones.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Locked