Object Detect for 5 seconds instead of 1 frame when check Motion first
parent
04ec802951
commit
a47b40444e
|
@ -490,6 +490,29 @@ module.exports = (s,config,lang,app,io) => {
|
||||||
extender(x,d)
|
extender(x,d)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
const sendFramesFromSecondaryOutput = (groupKey,monitorId,timeout) => {
|
||||||
|
const activeMonitor = s.group[groupKey].activeMonitors[monitorId]
|
||||||
|
const theEmitter = activeMonitor.secondaryDetectorOutput
|
||||||
|
if(!activeMonitor.sendingFromSecondaryDetectorOuput){
|
||||||
|
s.debugLog('start sending object frames',groupKey,monitorId)
|
||||||
|
theEmitter.on('data',activeMonitor.secondaryDetectorOuputContentWriter = (data) => {
|
||||||
|
console.log(data)
|
||||||
|
s.ocvTx({
|
||||||
|
f : 'frame',
|
||||||
|
mon : s.group[groupKey].rawMonitorConfigurations[monitorId].details,
|
||||||
|
ke : groupKey,
|
||||||
|
id : monitorId,
|
||||||
|
time : s.formattedTime(),
|
||||||
|
frame : data
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
clearTimeout(activeMonitor.sendingFromSecondaryDetectorOuput)
|
||||||
|
activeMonitor.sendingFromSecondaryDetectorOuput = setTimeout(() => {
|
||||||
|
theEmitter.removeListener('data',activeMonitor.secondaryDetectorOuputContentWriter)
|
||||||
|
delete(activeMonitor.sendingFromSecondaryDetectorOuput)
|
||||||
|
},timeout || 5000)
|
||||||
|
}
|
||||||
const triggerEvent = async (d,forceSave) => {
|
const triggerEvent = async (d,forceSave) => {
|
||||||
var didCountingAlready = false
|
var didCountingAlready = false
|
||||||
const filter = {
|
const filter = {
|
||||||
|
@ -559,14 +582,7 @@ module.exports = (s,config,lang,app,io) => {
|
||||||
|
|
||||||
//
|
//
|
||||||
if(d.doObjectDetection === true){
|
if(d.doObjectDetection === true){
|
||||||
s.ocvTx({
|
sendFramesFromSecondaryOutput(d.ke,d.id)
|
||||||
f : 'frame',
|
|
||||||
mon : s.group[d.ke].rawMonitorConfigurations[d.id].details,
|
|
||||||
ke : d.ke,
|
|
||||||
id : d.id,
|
|
||||||
time : s.formattedTime(),
|
|
||||||
frame : s.group[d.ke].activeMonitors[d.id].lastJpegDetectorFrame
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if(
|
if(
|
||||||
|
|
|
@ -58,6 +58,7 @@ module.exports = function(s,config,lang){
|
||||||
if(!activeMonitor.eventsCounted){activeMonitor.eventsCounted = {}};
|
if(!activeMonitor.eventsCounted){activeMonitor.eventsCounted = {}};
|
||||||
if(!activeMonitor.isStarted){activeMonitor.isStarted = false};
|
if(!activeMonitor.isStarted){activeMonitor.isStarted = false};
|
||||||
if(!activeMonitor.pipe4BufferPieces){activeMonitor.pipe4BufferPieces = []};
|
if(!activeMonitor.pipe4BufferPieces){activeMonitor.pipe4BufferPieces = []};
|
||||||
|
if(!activeMonitor.secondaryDetectorOutput){activeMonitor.secondaryDetectorOutput = new events.EventEmitter()};
|
||||||
if(activeMonitor.delete){clearTimeout(activeMonitor.delete)}
|
if(activeMonitor.delete){clearTimeout(activeMonitor.delete)}
|
||||||
if(!s.group[e.ke].rawMonitorConfigurations){s.group[e.ke].rawMonitorConfigurations={}}
|
if(!s.group[e.ke].rawMonitorConfigurations){s.group[e.ke].rawMonitorConfigurations={}}
|
||||||
if(!activeMonitor.criticalErrors)activeMonitor.criticalErrors = {
|
if(!activeMonitor.criticalErrors)activeMonitor.criticalErrors = {
|
||||||
|
@ -690,11 +691,12 @@ module.exports = function(s,config,lang){
|
||||||
}
|
}
|
||||||
const onDetectorJpegOutputSecondary = (e,buffer) => {
|
const onDetectorJpegOutputSecondary = (e,buffer) => {
|
||||||
if(s.isAtleatOneDetectorPluginConnected){
|
if(s.isAtleatOneDetectorPluginConnected){
|
||||||
const theArray = s.group[e.ke].activeMonitors[e.id].pipe4BufferPieces
|
const activeMonitor = s.group[e.ke].activeMonitors[e.id]
|
||||||
|
const theArray = activeMonitor.pipe4BufferPieces
|
||||||
theArray.push(buffer)
|
theArray.push(buffer)
|
||||||
if(buffer[buffer.length-2] === 0xFF && buffer[buffer.length-1] === 0xD9){
|
if(buffer[buffer.length-2] === 0xFF && buffer[buffer.length-1] === 0xD9){
|
||||||
s.group[e.ke].activeMonitors[e.id].lastJpegDetectorFrame = Buffer.concat(theArray)
|
activeMonitor.secondaryDetectorOutput.emit('data',Buffer.concat(theArray))
|
||||||
s.group[e.ke].activeMonitors[e.id].pipe4BufferPieces = []
|
activeMonitor.pipe4BufferPieces = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue