Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mods
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
mods
Commits
cb6ea13a
Commit
cb6ea13a
authored
Jan 6, 2018
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
motion detection working?
parent
ae973490
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/image/motion detect
+22
-7
22 additions, 7 deletions
modules/image/motion detect
with
22 additions
and
7 deletions
modules/image/motion detect
+
22
−
7
View file @
cb6ea13a
...
@@ -27,6 +27,7 @@ var name = 'motion detect'
...
@@ -27,6 +27,7 @@ var name = 'motion detect'
var init = function() {
var init = function() {
mod.threshold.value = 0.1
mod.threshold.value = 0.1
mod.time.value = 15
mod.time.value = 15
mod.dpi = 100
timeout()
timeout()
}
}
//
//
...
@@ -51,14 +52,11 @@ var inputs = {
...
@@ -51,14 +52,11 @@ var inputs = {
var outputs = {
var outputs = {
image:{type:'RGBA',
image:{type:'RGBA',
event:function(){
event:function(){
var ctx = mod.img.getContext("2d")
var img = ctx.getImageData(0,0,mod.img.width,mod.img.height)
mods.output(mod,'image',img)}},
mods.output(mod,'image',img)}},
imageInfo:{type:'object',
imageInfo:{type:'object',
event:function(){
event:function(obj){
var obj = {}
obj.name = mod.name.nodeValue
obj.dpi = parseFloat(mod.dpitext.value)
obj.width = mod.img.width
obj.height = mod.img.height
mods.output(mod,'imageInfo',obj)}},
mods.output(mod,'imageInfo',obj)}},
trigger:{type:'event',
trigger:{type:'event',
event:function(){
event:function(){
...
@@ -154,9 +152,26 @@ function compare_images() {
...
@@ -154,9 +152,26 @@ function compare_images() {
var webworker = new Worker(url)
var webworker = new Worker(url)
webworker.addEventListener('message',function(evt) {
webworker.addEventListener('message',function(evt) {
window.URL.revokeObjectURL(url)
window.URL.revokeObjectURL(url)
mod.change.nodeValue = 'relative change: '+evt.data.change.toFixed(3)
if (evt.data.change > parseFloat(mod.threshold.value)) {
var obj = {}
var date = new Date()
var year = date.getFullYear()
var month = ('0'+(1+parseInt(date.getMonth()))).slice(-2)
var day = ('0'+date.getDate()).slice(-2)
var hour = ('0'+date.getHours()).slice(-2)
var minute = ('0'+date.getMinutes()).slice(-2)
var second = ('0'+date.getSeconds()).slice(-2)
var name = year+'-'+month+'-'+day+'-'+hour+'-'+minute+'-'+second+'.png'
obj.name = name
obj.dpi = mod.dpi
obj.width = mod.img.width
obj.height = mod.img.height
outputs.imageInfo.event(obj)
outputs.image.event()
}
var h = mod.img.height
var h = mod.img.height
var w = mod.img.width
var w = mod.img.width
mod.change.nodeValue = 'relative change: '+evt.data.change.toFixed(3)
if (w > h) {
if (w > h) {
var x0 = 0
var x0 = 0
var y0 = mod.canvas.height*.5*(1-h/w)
var y0 = mod.canvas.height*.5*(1-h/w)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment