Object Detect for 5 seconds instead of 1 frame when check Motion first

auto-build-api-doc-with-code
Moe 2021-04-09 14:10:31 -07:00
parent 04ec802951
commit a47b40444e
2 changed files with 29 additions and 11 deletions

View File

@ -490,6 +490,29 @@ module.exports = (s,config,lang,app,io) => {
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) => {
var didCountingAlready = false
const filter = {
@ -559,14 +582,7 @@ module.exports = (s,config,lang,app,io) => {
//
if(d.doObjectDetection === true){
s.ocvTx({
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
})
sendFramesFromSecondaryOutput(d.ke,d.id)
}
//
if(

View File

@ -58,6 +58,7 @@ module.exports = function(s,config,lang){
if(!activeMonitor.eventsCounted){activeMonitor.eventsCounted = {}};
if(!activeMonitor.isStarted){activeMonitor.isStarted = false};
if(!activeMonitor.pipe4BufferPieces){activeMonitor.pipe4BufferPieces = []};
if(!activeMonitor.secondaryDetectorOutput){activeMonitor.secondaryDetectorOutput = new events.EventEmitter()};
if(activeMonitor.delete){clearTimeout(activeMonitor.delete)}
if(!s.group[e.ke].rawMonitorConfigurations){s.group[e.ke].rawMonitorConfigurations={}}
if(!activeMonitor.criticalErrors)activeMonitor.criticalErrors = {
@ -690,11 +691,12 @@ module.exports = function(s,config,lang){
}
const onDetectorJpegOutputSecondary = (e,buffer) => {
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)
if(buffer[buffer.length-2] === 0xFF && buffer[buffer.length-1] === 0xD9){
s.group[e.ke].activeMonitors[e.id].lastJpegDetectorFrame = Buffer.concat(theArray)
s.group[e.ke].activeMonitors[e.id].pipe4BufferPieces = []
activeMonitor.secondaryDetectorOutput.emit('data',Buffer.concat(theArray))
activeMonitor.pipe4BufferPieces = []
}
}
}