Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifications to enable server side motion confidence limits #45

Open
wants to merge 18 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ s.sqlQuery('ALTER TABLE `Videos` ADD COLUMN `details` TEXT NULL DEFAULT NULL AFT
}else{
s.systemLog("Critical update 2/2 already applied");
}
s.sqlQuery('ALTER TABLE `Events` ADD COLUMN `motionConfidence` decimal(20,15) NULL DEFAULT NULL AFTER `details`;',function(err){
if(err){
s.systemLog("Motion update 1/1 already applied");
} else {
s.systemLog("Motion update 1/1 has now been applied");
}
}, true)
},true);
},true);
//kill any ffmpeg running
Expand Down Expand Up @@ -2125,7 +2132,16 @@ s.camera=function(x,e,cn,tx){
}
//save this detection result in SQL, only coords. not image.
if(d.mon.details.detector_save==='1'){
s.sqlQuery('INSERT INTO Events (ke,mid,details) VALUES (?,?,?)',[d.ke,d.id,JSON.stringify(d.details)])
if (d.details.plug==='Motion') {
//console.log(config.motionDetection.minDBConfidence);
if (d.details.confidence > config.motionDetection.minDBConfidence) {
s.sqlQuery('INSERT INTO Events (ke,mid,details,motionConfidence) VALUES (?,?,?,?)', [d.ke, d.id, JSON.stringify(d.details), d.details.confidence]);
} else {
//console.log('Skipping Motion Event Record, Confidence: ' + d.details.confidence);
}
} else {
s.sqlQuery('INSERT INTO Events (ke,mid,details) VALUES (?,?,?)', [d.ke, d.id, JSON.stringify(d.details)])
}
}
if(d.mon.details.detector_command_enable==='1'&&!s.group[d.ke].mon[d.id].detector_command){
if(!d.mon.details.detector_command_timeout||d.mon.details.detector_command_timeout===''){
Expand Down Expand Up @@ -4047,7 +4063,7 @@ app.get(['/:auth/videos/:ke','/:auth/videos/:ke/:id'], function (req,res){
},res,req);
});
// Get events json (motion logs)
app.get(['/:auth/events/:ke','/:auth/events/:ke/:id','/:auth/events/:ke/:id/:limit','/:auth/events/:ke/:id/:limit/:start','/:auth/events/:ke/:id/:limit/:start/:end'], function (req,res){
app.get(['/:auth/events/:ke','/:auth/events/:ke/:id','/:auth/events/:ke/:id/:limit','/:auth/events/:ke/:id/:limit/:start','/:auth/events/:ke/:id/:confidence/:limit/:start/:end'], function (req,res){
req.ret={ok:false};
res.setHeader('Content-Type', 'application/json');
res.header("Access-Control-Allow-Origin",req.headers.origin);
Expand Down Expand Up @@ -4086,8 +4102,11 @@ app.get(['/:auth/events/:ke','/:auth/events/:ke/:id','/:auth/events/:ke/:id/:lim
req.ar.push(decodeURIComponent(req.params.start))
}
}
if(!req.params.confidence||req.params.confidence == ''){ req.params.confidence = config.motionDetection.minDBConfidence; }
req.sql+=' and motionConfidence > ' + req.params.confidence;
if(!req.params.limit||req.params.limit==''){req.params.limit=100}
req.sql+=' ORDER BY `time` DESC LIMIT '+req.params.limit+'';
//console.log(req.sql);
s.sqlQuery(req.sql,req.ar,function(err,r){
if(err){
err.sql=req.sql;
Expand Down
1 change: 1 addition & 0 deletions languages/en_CA.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"Snapshots": "Snapshots",
"Date Range": "Date Range",
"Event Limit": "Event Limit",
"Minimum Confidence": "Minimum Confidence",
"No Data": "No Data",
"Live View": "Live View",
"Add": "Add",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"ejs": "^2.5.5",
"express": "^4.14.0",
"jsonfile": "^3.0.1",
"moment": "^2.17.0",
"ldapauth-fork": "^4.0.2",
"moment": "^2.20.1",
"mysql": "^2.12.0",
"knex": "^0.14.2",
"pam-diff": "0.10.2",
Expand All @@ -36,8 +37,7 @@
"request": "^2.79.0",
"socket.io": "^1.7.1",
"socket.io-client": "^1.7.2",
"webdav": "^0.3.1",
"ldapauth-fork": "^4.0.2"
"webdav": "^0.3.1"
},
"devDependencies": {}
}
5 changes: 5 additions & 0 deletions web/pages/blocks/powervideo.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<div><input type="text" id="pvideo_daterange" class="form-control dark" value="" /></div>
</label>
</div>
<div class="form-group">
<label><div><span><%-lang['Minimum Confidence']%></span></div>
<div><input type="text" id="pvideo_event_min_confidence" class="form-control dark" placeholder="40" localStorage="powerEvtMinConfidenceLimit" /></div>
</label>
</div>
<div class="form-group">
<label><div><span><%-lang['Event Limit']%></span></div>
<div><input type="text" id="pvideo_event_limit" class="form-control dark" placeholder="500" localStorage="powerEventLimit" /></div>
Expand Down