adjust counting methodology for tracking plugins

- tracking plugins are currently not available to public but you may still use the counting feature on a per-frame basis instead of tracked object
build-default-monitor-config-from-definitions
Moe 2020-05-24 22:10:31 -07:00
parent 48e6483550
commit 479efbf228
2 changed files with 10 additions and 8 deletions

View File

@ -14,9 +14,9 @@ module.exports = function(s,config,lang){
const eventsCounted = s.group[event.ke].activeMonitors[event.id].eventsCounted || {}
if(matrices){
matrices.forEach((matrix)=>{
const id = !isNaN(matrix.id) ? matrix.id + '_' + matrix.tag : matrix.tag
if(!eventsCounted[id])eventsCounted[id] = {times: [], count: 0}
++eventsCounted[id].count
const id = matrix.tag
if(!eventsCounted[id])eventsCounted[id] = {times: [], count: {}, tag: matrix.tag}
if(!isNaN(matrix.id))eventsCounted[id].count[matrix.id] = 1
eventsCounted[id].times.push(new Date().getTime())
})
}

View File

@ -1014,9 +1014,9 @@ module.exports = function(s,config,lang){
if(monitor.details.detector_obj_count === '1'){
const activeMonitor = s.group[monitor.ke].activeMonitors[monitor.id]
activeMonitor.eventsCountStartTime = new Date()
const eventsCounted = activeMonitor.eventsCounted || {}
clearInterval(activeMonitor.objectCountIntervals)
activeMonitor.objectCountIntervals = setInterval(() => {
const eventsCounted = activeMonitor.eventsCounted || {}
const countsToSave = Object.assign(eventsCounted,{})
activeMonitor.eventsCounted = {}
const groupKey = monitor.ke
@ -1027,18 +1027,20 @@ module.exports = function(s,config,lang){
activeMonitor.eventsCountStartTime = new Date()
if(countedKeys.length > 0)countedKeys.forEach((tag) => {
const tagInfo = countsToSave[tag]
const count = tagInfo.count
const count = Object.keys(tagInfo.count)
const times = tagInfo.times
const realTag = tagInfo.tag
s.sqlQuery('INSERT INTO `Events Counts` (ke,mid,details,time,end,count,tag) VALUES (?,?,?,?,?,?,?)',[
groupKey,
monitorId,
JSON.stringify({
times: times
times: times,
count: count,
}),
startTime,
endTime,
count,
tag
count.length,
realTag
])
})
},60000) //every minute