Add LInked Event Trigger Id and Object Score to Events
Posted: Mon Feb 03, 2020 12:03 pm
I'm using Asker's most excellent zmeventnotification Object Detection stuff with the end goal of removing all events that did not have an object detected so that I'm not looking at endless events triggered by Bats'n'Bugs For the record, I'm also recording the high-res streams without detection as a fallback.
Asker's Object Detection adds a detected string to the Events Notes field so that one ends up with something like "[a] detected;car:87% Motion: Gate Closeup".
This works very well for single Monitors as I can, albeit inefficiently from the Db perspective searching for strings in text fields , delete all events that do not have "detected:" in the Notes.
However, this goes horribly wrong for linked Monitors.
I have Monitor A which is a closeup of the entrance gate linked to Monitors B & C which give a wider angle view.
When Monitor A gets a motion trigger, Monitors B&C trigger and get a cause of "Linked" and "Linked: House Gate" in the Notes field but there is no mechanism for determining which event Id on Monitor A was the trigger. Asker's Objection Detection runs on Monitor A and, if an object is found, changes the Notes field appropriately for the triggering event but obviously not for the linked events on B&C - because it can't determine which ones they are.
This means that my filter on "detected:" will delete the events on Monitors B&C thereby negating the purpose of having the linkage
What I'm proposing is that Events gets a couple more fields like so:
Asker's Object Detection code could then simply do something like:
I'm also suggesting adding an ObjectScore field (like the existing MaxScore, TotScore etc) so that Asker's code could record the detection confidence percentage for the event. This would allow filters to be based on the Object Score. The sql in Asker's code would then become:
I have raised this with Asker and he suggested putting it as an enhancement request... so I am
FWIW, I have looked at monitor.cpp where it sets LINKED_CAUSE for the linked monitor's events but my understanding of the code structure is zero so I'm not confident enough to propose a patch but I'm more than happy to contribute with testing code written by someone who does know what they're doing
Asker's Object Detection adds a detected string to the Events Notes field so that one ends up with something like "[a] detected;car:87% Motion: Gate Closeup".
This works very well for single Monitors as I can, albeit inefficiently from the Db perspective searching for strings in text fields , delete all events that do not have "detected:" in the Notes.
However, this goes horribly wrong for linked Monitors.
I have Monitor A which is a closeup of the entrance gate linked to Monitors B & C which give a wider angle view.
When Monitor A gets a motion trigger, Monitors B&C trigger and get a cause of "Linked" and "Linked: House Gate" in the Notes field but there is no mechanism for determining which event Id on Monitor A was the trigger. Asker's Objection Detection runs on Monitor A and, if an object is found, changes the Notes field appropriately for the triggering event but obviously not for the linked events on B&C - because it can't determine which ones they are.
This means that my filter on "detected:" will delete the events on Monitors B&C thereby negating the purpose of having the linkage
What I'm proposing is that Events gets a couple more fields like so:
Code: Select all
alter table Events add column LinkedId bigint(20) unsigned default 0 after SecondaryStorageId;
alter table Events add column ObjectScore tinyint(3) unsigned NOT NULL DEFAULT '0' after MaxScore;
create index Events_LinkedId_idx on Events(LinkedId);
create index Events_ObjectScore_idx on Events(ObjectScore);
Code: Select all
update Events set Notes=CONCAT(Notes,<detect string>) where LinkedId=<ThisEventId>
Code: Select all
update Events set Notes=CONCAT(Notes,<detect string>), ObjectScore=<objectscore> where LinkedId=<ThisEventId>
FWIW, I have looked at monitor.cpp where it sets LINKED_CAUSE for the linked monitor's events but my understanding of the code structure is zero so I'm not confident enough to propose a patch but I'm more than happy to contribute with testing code written by someone who does know what they're doing