File: virtual_switch.sps

package info (click to toggle)
sitplus 1.0.3-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 23,636 kB
  • sloc: cpp: 34,437; ansic: 7,957; xml: 1,141; yacc: 326; lisp: 235; lex: 167; makefile: 107; sh: 5
file content (134 lines) | stat: -rw-r--r-- 2,824 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#
# virtual switch
#
# Input pins
#	image (iplimage)
#	roi (roi)
#
# Output pins
#	roi (roi)
# 	action_fired (bool)
#

type virtual_switch
name "Virtual Switch"
args -x -y -c

# Camera source. Create a forwarder to export the pin ...
create forward forwardin_image
# and export it as "image"
export_ipin forwardin_image in image iplimage

# ROI input
create forward forwardin_roi
export_ipin forwardin_roi in roi roi

# Camera panel ans its roi
#create roi_storage roi -s 0.05 0.05 -c 0.25 0.5 --color 16711680
create roi_storage roi -s 0.05 0.05 -c $-x$ $-y$ --color $-c$
export_opin roi roi

# Connect external viewer
connect forwardin_roi out roi roi_same_id

#connect roi roi viewer roi
#connect forward out viewer image

# Optical flow tracker and its roi
create optical_flow_tracker oftracker
connect roi roi oftracker roi
connect forwardin_image out oftracker image

#
# Optical flow output processing
#

# Split output for each axis
create split split -o 2
connect oftracker motion split input

# Compute motion modulus
create fmul mul_a
create fmul mul_b

connect split 1 mul_a b
connect split 1 mul_a a

connect split 2 mul_b b
connect split 2 mul_b a

create fadd modulus_adder

connect mul_a result modulus_adder b
connect mul_b result modulus_adder a

create fsqrt modulus
connect modulus_adder result modulus a

# DEBUG SLIDER
create widget_slider sldmotion_detected --min 0 --max 1 -l "Motion detected"
connect modulus result sldmotion_detected value
# DEBUG SLIDER



#
# Threshold slider + checkbox
#
import around_zero_threshold.sps
create around_zero_threshold thres -lsld _"Motion detection threshold" -lchk _"Motion detected" -max 0.3 -v 0.01
connect modulus result thres in

#
# Filter events by time
#
import filter_values_by_time.sps
create filter_values_by_time filter -t 1000
connect thres above filter in
create widget_slider sldtime --min 250 --max 5000 -l "Time (ms)" -v 1000 -i
connect sldtime value filter time



#
# Button to set noise level
#

create widget_button setthres_btn -l "Set threshold"
create forward noise_gate
connect setthres_btn pressed noise_gate gate
connect modulus result noise_gate in

# Condition value: average + scale
create freductor avg_motion -a -r 5
connect noise_gate out avg_motion in
create fmul scale_motion -v 10
connect avg_motion out scale_motion a

connect scale_motion result thres thres

create bcast bcast_motion
connect scale_motion result bcast_motion in
create not not_motion
connect bcast_motion out not_motion a
connect not_motion result noise_gate gate

#
# Time wait after 

# 
# Action fired

export_opin filter out action_fired

begin_gui_layout
	layout_begin vbox
		component setthres_btn
		component sldtime
		
		layout_begin collapsible _"Advanced"
			component sldmotion_detected
			component thres
		layout_end
	layout_end
end_gui_layout