fix condition for detector output

+ automated whitespace removal with atom
merge-requests/21/head
Moe 2018-08-20 14:52:17 -07:00
parent 9217e8ebef
commit ace8c7e916
1 changed files with 69 additions and 71 deletions

140
camera.js
View File

@ -1326,7 +1326,7 @@ s.video=function(x,e,k){
k.stat = fs.statSync(k.dir+k.file) k.stat = fs.statSync(k.dir+k.file)
e.filesize = k.stat.size e.filesize = k.stat.size
e.filesizeMB = parseFloat((e.filesize/1000000).toFixed(2)) e.filesizeMB = parseFloat((e.filesize/1000000).toFixed(2))
e.startTime = new Date(s.nameToTime(k.file)) e.startTime = new Date(s.nameToTime(k.file))
e.endTime = new Date(k.stat.mtime) e.endTime = new Date(k.stat.mtime)
if(config.useUTC === true){ if(config.useUTC === true){
@ -1418,9 +1418,9 @@ s.video=function(x,e,k){
console.error(err) console.error(err)
}) })
s.group[e.ke].aws_s3.upload({ s.group[e.ke].aws_s3.upload({
Bucket: s.group[e.ke].init.aws_s3_bucket, Bucket: s.group[e.ke].init.aws_s3_bucket,
Key: s.group[e.ke].init.aws_s3_dir+e.ke+'/'+e.mid+'/'+k.filename, Key: s.group[e.ke].init.aws_s3_dir+e.ke+'/'+e.mid+'/'+k.filename,
Body:fileStream, Body:fileStream,
ACL:'public-read' ACL:'public-read'
},function(err,data){ },function(err,data){
if(err){ if(err){
@ -1733,7 +1733,7 @@ s.ffmpegCoProcessor = function(e){
//x.input is the input and connection //x.input is the input and connection
if(e.details.loglevel&&e.details.loglevel!==''){x.loglevel='-loglevel '+e.details.loglevel;}else{x.loglevel='-loglevel error'} if(e.details.loglevel&&e.details.loglevel!==''){x.loglevel='-loglevel '+e.details.loglevel;}else{x.loglevel='-loglevel error'}
x.input = x.loglevel+' -re -i '+e.sdir+'cpuOnly.m3u8' x.input = x.loglevel+' -re -i '+e.sdir+'cpuOnly.m3u8'
//x.pipe is the stream out methods //x.pipe is the stream out methods
x.cust_input='' x.cust_input=''
x.cust_detect=' ' x.cust_detect=' '
@ -1817,7 +1817,7 @@ s.ffmpegCoProcessor = function(e){
}else{ }else{
x.dratio=' -s 320x240' x.dratio=' -s 320x240'
} }
if(e.details.cust_detect&&e.details.cust_detect!==''){x.cust_detect+=e.details.cust_detect;} if(e.details.cust_detect&&e.details.cust_detect!==''){x.cust_detect+=e.details.cust_detect;}
if(e.details.detector_pam==='1'){ if(e.details.detector_pam==='1'){
x.pipe += ' -an -c:v pam -pix_fmt gray -f image2pipe -r '+x.detector_fps+x.cust_detect+x.dratio+' pipe:3' x.pipe += ' -an -c:v pam -pix_fmt gray -f image2pipe -r '+x.detector_fps+x.cust_detect+x.dratio+' pipe:3'
@ -2221,26 +2221,24 @@ s.ffmpeg = function(e){
}) })
} }
//detector - plugins, motion //detector - plugins, motion
if(e.details.detector==='1'&&e.details.detector_send_frames==='1'){ if(e.details.detector==='1' && e.details.detector_send_frames==='1' && e.coProcessor === false){
if(e.details.accelerator !== '1'){ if(e.details.input_map_choices&&e.details.input_map_choices.detector){
if(e.details.input_map_choices&&e.details.input_map_choices.detector){ //add input feed map
//add input feed map x.pipe += s.createFFmpegMap(e,e.details.input_map_choices.detector)
x.pipe += s.createFFmpegMap(e,e.details.input_map_choices.detector) }
} if(!e.details.detector_fps||e.details.detector_fps===''){e.details.detector_fps=2}
if(!e.details.detector_fps||e.details.detector_fps===''){e.details.detector_fps=2} if(e.details.detector_scale_x&&e.details.detector_scale_x!==''&&e.details.detector_scale_y&&e.details.detector_scale_y!==''){x.dratio=' -s '+e.details.detector_scale_x+'x'+e.details.detector_scale_y}else{x.dratio=' -s 320x240'}
if(e.details.detector_scale_x&&e.details.detector_scale_x!==''&&e.details.detector_scale_y&&e.details.detector_scale_y!==''){x.dratio=' -s '+e.details.detector_scale_x+'x'+e.details.detector_scale_y}else{x.dratio=' -s 320x240'} if(e.details.cust_detect&&e.details.cust_detect!==''){x.cust_detect+=e.details.cust_detect;}
if(e.details.cust_detect&&e.details.cust_detect!==''){x.cust_detect+=e.details.cust_detect;} if(e.details.detector_pam==='1'){
if(e.details.detector_pam==='1'){ x.pipe+=' -an -c:v pam -pix_fmt gray -f image2pipe -r '+e.details.detector_fps+x.cust_detect+x.dratio+' pipe:3'
x.pipe+=' -an -c:v pam -pix_fmt gray -f image2pipe -r '+e.details.detector_fps+x.cust_detect+x.dratio+' pipe:3' if(e.details.detector_use_detect_object === '1'){
if(e.details.detector_use_detect_object === '1'){ //for object detection
//for object detection x.pipe += s.createFFmpegMap(e,e.details.input_map_choices.detector)
x.pipe += s.createFFmpegMap(e,e.details.input_map_choices.detector) x.pipe += ' -f singlejpeg -vf fps='+e.details.detector_fps+x.cust_detect+x.dratio+' pipe:4';
x.pipe += ' -f singlejpeg -vf fps='+e.details.detector_fps+x.cust_detect+x.dratio+' pipe:4'; }
} }else{
}else{ x.pipe+=' -f singlejpeg -vf fps='+e.details.detector_fps+x.cust_detect+x.dratio+' pipe:3';
x.pipe+=' -f singlejpeg -vf fps='+e.details.detector_fps+x.cust_detect+x.dratio+' pipe:3'; }
}
}
} }
//api - snapshot bin/ cgi.bin (JPEG Mode) //api - snapshot bin/ cgi.bin (JPEG Mode)
if(e.details.snap === '1'){ if(e.details.snap === '1'){
@ -2444,7 +2442,7 @@ s.event = function(x,e,cn){
//read filters //read filters
if( if(
currentConfig.use_detector_filters === '1' && currentConfig.use_detector_filters === '1' &&
((currentConfig.use_detector_filters_object === '1' && d.details.matrices) || ((currentConfig.use_detector_filters_object === '1' && d.details.matrices) ||
currentConfig.use_detector_filters_object !== '1') currentConfig.use_detector_filters_object !== '1')
){ ){
var parseValue = function(key,val){ var parseValue = function(key,val){
@ -2688,7 +2686,7 @@ s.event = function(x,e,cn){
var screenshotName = 'Motion_'+(d.mon.name.replace(/[^\w\s]/gi,''))+'_'+d.id+'_'+d.ke+'_'+s.formattedTime() var screenshotName = 'Motion_'+(d.mon.name.replace(/[^\w\s]/gi,''))+'_'+d.id+'_'+d.ke+'_'+s.formattedTime()
var screenshotBuffer = null var screenshotBuffer = null
var detectorStreamBuffers = null var detectorStreamBuffers = null
//discord bot //discord bot
if(filter.discord && currentConfig.detector_discordbot === '1' && !s.group[d.ke].mon[d.id].detector_discordbot){ if(filter.discord && currentConfig.detector_discordbot === '1' && !s.group[d.ke].mon[d.id].detector_discordbot){
var detector_discordbot_timeout var detector_discordbot_timeout
@ -2868,7 +2866,7 @@ s.camera=function(x,e,cn,tx){
if(!e.details[v])e.details[v]={}; if(!e.details[v])e.details[v]={};
s.group[e.ke].mon[e.id].details = e.details; s.group[e.ke].mon[e.id].details = e.details;
}catch(err){ }catch(err){
} }
} }
}); });
@ -3704,7 +3702,7 @@ s.camera=function(x,e,cn,tx){
} }
if(e.frame_to_stream){ if(e.frame_to_stream){
if(e.coProcessor === true && e.details.stream_type === ('b64'||'mjpeg')){ if(e.coProcessor === true && e.details.stream_type === ('b64'||'mjpeg')){
}else{ }else{
s.group[e.ke].mon[e.id].spawn.stdout.on('data',e.frame_to_stream) s.group[e.ke].mon[e.id].spawn.stdout.on('data',e.frame_to_stream)
} }
@ -5180,42 +5178,42 @@ var tx;
break; break;
} }
}) })
//functions for retrieving cron announcements //functions for retrieving cron announcements
cn.on('cron',function(d){ cn.on('cron',function(d){
if(d.f==='init'){ if(d.f==='init'){
if(config.cron.key){ if(config.cron.key){
if(config.cron.key===d.cronKey){ if(config.cron.key===d.cronKey){
s.cron={started:moment(),last_run:moment(),id:cn.id}; s.cron={started:moment(),last_run:moment(),id:cn.id};
}else{ }else{
cn.disconnect() cn.disconnect()
} }
}else{ }else{
s.cron={started:moment(),last_run:moment(),id:cn.id}; s.cron={started:moment(),last_run:moment(),id:cn.id};
} }
}else{ }else{
if(s.cron&&cn.id===s.cron.id){ if(s.cron&&cn.id===s.cron.id){
delete(d.cronKey) delete(d.cronKey)
switch(d.f){ switch(d.f){
case'filters': case'filters':
s.filterEvents(d.ff,d); s.filterEvents(d.ff,d);
break; break;
case's.tx': case's.tx':
s.tx(d.data,d.to) s.tx(d.data,d.to)
break; break;
case's.video': case's.video':
s.video(d.data,d.file) s.video(d.data,d.file)
break; break;
case'start':case'end': case'start':case'end':
d.mid='_cron';s.log(d,{type:'cron',msg:d.msg}) d.mid='_cron';s.log(d,{type:'cron',msg:d.msg})
break; break;
default: default:
s.systemLog('CRON : ',d) s.systemLog('CRON : ',d)
break; break;
} }
}else{ }else{
cn.disconnect() cn.disconnect()
} }
} }
}) })
cn.on('disconnect', function () { cn.on('disconnect', function () {
if(cn.socketVideoStream){ if(cn.socketVideoStream){
@ -5244,8 +5242,8 @@ var tx;
s.tx({f:'plugin_engine_unplugged',plug:cn.pluginEngine},'CPU') s.tx({f:'plugin_engine_unplugged',plug:cn.pluginEngine},'CPU')
delete(s.api[cn.pluginEngine]) delete(s.api[cn.pluginEngine])
} }
if(cn.cron){ if(cn.cron){
delete(s.cron); delete(s.cron);
} }
if(cn.ocv){ if(cn.ocv){
s.tx({f:'detector_unplugged',plug:s.ocv.plug},'CPU') s.tx({f:'detector_unplugged',plug:s.ocv.plug},'CPU')
@ -5484,7 +5482,7 @@ app.get(config.webPaths.admin, function (req,res){
}); });
//super page //super page
app.get(config.webPaths.super, function (req,res){ app.get(config.webPaths.super, function (req,res){
res.render(config.renderPaths.index,{lang:lang,config:config,screen:'super',originalURL:s.getOriginalUrl(req)},function(err,html){ res.render(config.renderPaths.index,{lang:lang,config:config,screen:'super',originalURL:s.getOriginalUrl(req)},function(err,html){
if(err){ if(err){
s.systemLog(err) s.systemLog(err)
@ -5988,7 +5986,7 @@ app.get([config.webPaths.apiPrefix+':auth/grid/:ke',config.webPaths.apiPrefix+':
res.end(user.lang['Not Permitted']) res.end(user.lang['Not Permitted'])
return return
} }
req.params.protocol=req.protocol; req.params.protocol=req.protocol;
req.sql='SELECT * FROM Monitors WHERE mode!=? AND mode!=? AND ke=?';req.ar=['stop','idle',req.params.ke]; req.sql='SELECT * FROM Monitors WHERE mode!=? AND mode!=? AND ke=?';req.ar=['stop','idle',req.params.ke];
if(!req.params.id){ if(!req.params.id){
@ -6023,7 +6021,7 @@ app.get([config.webPaths.apiPrefix+':auth/grid/:ke',config.webPaths.apiPrefix+':
} }
}) })
}catch(err){ }catch(err){
} }
}) })
r = filteredByGroup; r = filteredByGroup;
@ -7607,7 +7605,7 @@ if(config.childNodes.enabled === true && config.childNodes.mode === 'master'){
}) })
}) })
}else }else
//setup Child for childNodes //setup Child for childNodes
if(config.childNodes.enabled === true && config.childNodes.mode === 'child' && config.childNodes.host){ if(config.childNodes.enabled === true && config.childNodes.mode === 'child' && config.childNodes.host){
s.connected = false; s.connected = false;
childIO = require('socket.io-client')('ws://'+config.childNodes.host); childIO = require('socket.io-client')('ws://'+config.childNodes.host);