Skip to content

Commit e7fe0e1

Browse files
author
Tom Softreck
committed
update
1 parent c11a2c1 commit e7fe0e1

9 files changed

Lines changed: 884 additions & 147 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.env.1
12
.idea
23
.old
34
.todo.txt

examples/camera.yaml

Lines changed: 5 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -6,75 +6,22 @@ routes:
66
from: "rtsp://{{CAMERA_USER}}:{{CAMERA_PASS}}@{{CAMERA_IP}}/stream1"
77

88
processors:
9-
# Stage 1: Python YOLO object detection
10-
- type: "external"
11-
command: "python scripts/detect_objects.py"
12-
input_format: "json"
13-
output_format: "json"
14-
config:
15-
confidence_threshold: 0.6
16-
model: "yolov8n.pt"
17-
target_objects: ["person", "car", "motorcycle", "bicycle"]
18-
batch_processing: false
19-
20-
# Stage 2: Go-based risk assessment and zone analysis
21-
- type: "external"
22-
command: "go run scripts/image_processor.go"
23-
input_format: "json"
24-
output_format: "json"
25-
config:
26-
zone_mapping: "entrance:critical,parking:medium,garden:low"
27-
threat_threshold: 0.7
28-
risk_factors: "time_of_day,object_type,zone,confidence"
29-
30-
# Stage 3: C++ performance optimization and NMS
31-
- type: "external"
32-
command: "./bin/cpp_postprocessor"
33-
input_format: "json"
34-
output_format: "json"
35-
config:
36-
algorithm: "fast_nms"
37-
nms_threshold: 0.5
38-
confidence_threshold: 0.7
39-
40-
# Stage 4: Filter only high-risk detections
41-
- type: "filter"
42-
condition: "{{threat_level}} in ['high', 'critical']"
43-
44-
# Stage 5: Node.js business rules engine
45-
- type: "external"
46-
command: "node scripts/business_rules.js"
47-
input_format: "json"
48-
output_format: "json"
49-
config:
50-
rules_file: "security_rules.json"
51-
business_hours: "09:00-17:00"
52-
escalation_time: 300
53-
54-
# Stage 6: Transform to alert format
9+
5510
- type: "transform"
5611
template: |
5712
🚨 SECURITY ALERT - {{camera_name}}
5813
59-
Threat Level: {{threat_level}} ({{business_priority}})
60-
Time: {{timestamp}}
61-
Location: {{zone}} ({{position}})
62-
6314
Detections:
64-
{{#enhanced_detections}}
65-
• {{object_type}} - Confidence: {{confidence}}% - Risk: {{risk_score}}
66-
Recommended Action: {{recommended_action}}
67-
{{/enhanced_detections}}
6815
6916
Business Context:
7017
• Business Hours: {{#business_context.is_business_hours}}Yes{{/business_context.is_business_hours}}{{^business_context.is_business_hours}}No{{/business_context.is_business_hours}}
7118
• Zone Risk: {{business_context.zone_risk_level}}
7219
• Immediate Response Required: {{business_context.requires_immediate_response}}
7320
7421
to:
75-
- "email://{{SMTP_SERVER}}:{{SMTP_PORT}}?user={{SMTP_USER}}&password={{SMTP_PASS}}&to={{SECURITY_EMAIL}}"
76-
- "http://{{SECURITY_WEBHOOK}}/critical-alert"
77-
- "mqtt://{{MQTT_BROKER}}:1883/security/alerts/{{CAMERA_NAME}}"
22+
- "email://{{SMTP_SERVER}}:{{SMTP_PORT}}?user={{SMTP_USER}}&password={{SMTP_PASS}}&to={{ALERT_EMAIL}}"
23+
# - "http://{{SECURITY_WEBHOOK}}/critical-alert"
24+
# - "mqtt://{{MQTT_BROKER}}:1883/security/alerts/{{CAMERA_NAME}}"
7825
- "log://logs/security_{{CAMERA_NAME}}.log"
7926

8027
- name: "camera_health_monitoring"
@@ -91,28 +38,8 @@ routes:
9138
- type: "filter"
9239
condition: "{{status}} != 'healthy'"
9340

94-
to: "email://{{SMTP_SERVER}}:{{SMTP_PORT}}?user={{SMTP_USER}}&password={{SMTP_PASS}}&to={{ADMIN_EMAIL}}"
41+
to: "email://{{SMTP_SERVER}}:{{SMTP_PORT}}?user={{SMTP_USER}}&password={{SMTP_PASS}}&to={{ALERT_EMAIL}}"
9542

96-
- name: "motion_detection_backup"
97-
from: "rtsp://{{BACKUP_CAMERA_USER}}:{{BACKUP_CAMERA_PASS}}@{{BACKUP_CAMERA_IP}}/stream1"
98-
99-
processors:
100-
- type: "external"
101-
command: "python scripts/motion_detector.py"
102-
config:
103-
sensitivity: 0.3
104-
min_area: 5000
105-
background_subtraction: true
106-
107-
- type: "aggregate"
108-
strategy: "collect"
109-
timeout: "30s"
110-
max_size: 5
111-
112-
- type: "transform"
113-
template: "Motion detected on backup camera: {{count}} events in last 30s"
114-
115-
to: "log://logs/motion_backup.log"
11643

11744
env_vars:
11845
- CAMERA_USER

examples/camera2.yaml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Advanced Camera Processing Routes
2+
# Demonstrates multi-stage processing with different languages
3+
4+
routes:
5+
- name: "advanced_camera_detection"
6+
from: "rtsp://{{CAMERA_USER}}:{{CAMERA_PASS}}@{{CAMERA_IP}}/stream1"
7+
8+
processors:
9+
# Stage 1: Python YOLO object detection
10+
- type: "external"
11+
command: "python scripts/detect_objects.py"
12+
input_format: "json"
13+
output_format: "json"
14+
config:
15+
confidence_threshold: 0.6
16+
model: "yolov8n.pt"
17+
target_objects: ["person", "car", "motorcycle", "bicycle"]
18+
batch_processing: false
19+
20+
# Stage 2: Go-based risk assessment and zone analysis
21+
- type: "external"
22+
command: "go run scripts/image_processor.go"
23+
input_format: "json"
24+
output_format: "json"
25+
config:
26+
zone_mapping: "entrance:critical,parking:medium,garden:low"
27+
threat_threshold: 0.7
28+
risk_factors: "time_of_day,object_type,zone,confidence"
29+
30+
# Stage 3: C++ performance optimization and NMS
31+
- type: "external"
32+
command: "./bin/cpp_postprocessor"
33+
input_format: "json"
34+
output_format: "json"
35+
config:
36+
algorithm: "fast_nms"
37+
nms_threshold: 0.5
38+
confidence_threshold: 0.7
39+
40+
# Stage 4: Filter only high-risk detections
41+
- type: "filter"
42+
condition: "{{threat_level}} in ['high', 'critical']"
43+
44+
# Stage 5: Node.js business rules engine
45+
- type: "external"
46+
command: "node scripts/business_rules.js"
47+
input_format: "json"
48+
output_format: "json"
49+
config:
50+
rules_file: "security_rules.json"
51+
business_hours: "09:00-17:00"
52+
escalation_time: 300
53+
54+
# Stage 6: Transform to alert format
55+
- type: "transform"
56+
template: |
57+
🚨 SECURITY ALERT - {{camera_name}}
58+
59+
Threat Level: {{threat_level}} ({{business_priority}})
60+
Time: {{timestamp}}
61+
Location: {{zone}} ({{position}})
62+
63+
Detections:
64+
{{#enhanced_detections}}
65+
• {{object_type}} - Confidence: {{confidence}}% - Risk: {{risk_score}}
66+
Recommended Action: {{recommended_action}}
67+
{{/enhanced_detections}}
68+
69+
Business Context:
70+
• Business Hours: {{#business_context.is_business_hours}}Yes{{/business_context.is_business_hours}}{{^business_context.is_business_hours}}No{{/business_context.is_business_hours}}
71+
• Zone Risk: {{business_context.zone_risk_level}}
72+
• Immediate Response Required: {{business_context.requires_immediate_response}}
73+
74+
to:
75+
- "email://{{SMTP_SERVER}}:{{SMTP_PORT}}?user={{SMTP_USER}}&password={{SMTP_PASS}}&to={{SECURITY_EMAIL}}"
76+
- "http://{{SECURITY_WEBHOOK}}/critical-alert"
77+
- "mqtt://{{MQTT_BROKER}}:1883/security/alerts/{{CAMERA_NAME}}"
78+
- "log://logs/security_{{CAMERA_NAME}}.log"
79+
80+
- name: "camera_health_monitoring"
81+
from: "timer://2m"
82+
83+
processors:
84+
- type: "external"
85+
command: "python scripts/camera_health_check.py"
86+
config:
87+
camera_endpoints: "{{CAMERA_HEALTH_ENDPOINTS}}"
88+
timeout: 10
89+
expected_fps: 25
90+
91+
- type: "filter"
92+
condition: "{{status}} != 'healthy'"
93+
94+
to: "email://{{SMTP_SERVER}}:{{SMTP_PORT}}?user={{SMTP_USER}}&password={{SMTP_PASS}}&to={{ADMIN_EMAIL}}"
95+
96+
- name: "motion_detection_backup"
97+
from: "rtsp://{{CAMERA_USER}}:{{CAMERA_PASS}}@{{CAMERA_IP}}/stream1"
98+
99+
processors:
100+
- type: "external"
101+
command: "python scripts/motion_detector.py"
102+
config:
103+
sensitivity: 0.3
104+
min_area: 5000
105+
background_subtraction: true
106+
107+
- type: "aggregate"
108+
strategy: "collect"
109+
timeout: "30s"
110+
max_size: 5
111+
112+
- type: "transform"
113+
template: "Motion detected on backup camera: {{count}} events in last 30s"
114+
115+
to: "log://logs/motion_backup.log"
116+
117+
env_vars:
118+
- CAMERA_USER
119+
- CAMERA_PASS
120+
- CAMERA_IP
121+
- CAMERA_NAME
122+
- BACKUP_CAMERA_USER
123+
- BACKUP_CAMERA_PASS
124+
- BACKUP_CAMERA_IP
125+
- SMTP_SERVER
126+
- SMTP_PORT
127+
- SMTP_USER
128+
- SMTP_PASS
129+
- SECURITY_EMAIL
130+
- ADMIN_EMAIL
131+
- SECURITY_WEBHOOK
132+
- MQTT_BROKER
133+
- CAMERA_HEALTH_ENDPOINTS
134+
135+
settings:
136+
max_concurrent_routes: 5
137+
default_timeout: 60
138+
log_level: "info"
139+
metrics_enabled: true
140+
health_check_port: 8080
141+
frame_skip_ratio: 3
142+
max_memory_usage: "2GB"

examples/email.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Advanced Camera Processing Routes
2+
# Demonstrates multi-stage processing with different languages
3+
4+
routes:
5+
6+
- name: "camera_health_monitoring"
7+
from: "timer://5s"
8+
9+
processors:
10+
- type: "external"
11+
command: "python scripts/camera_health_check.py"
12+
config:
13+
camera_endpoints: "{{CAMERA_HEALTH_ENDPOINTS}}"
14+
timeout: 10
15+
expected_fps: 25
16+
17+
- type: "filter"
18+
condition: >
19+
{{ (result is defined and result.status is defined and result.status != 'healthy') or
20+
(result is defined and result.cameras is defined and
21+
result.cameras|selectattr('status', 'equalto', 'healthy')|list|length < result.cameras|length) }}
22+
on_error: "log:Failed to process camera status check: {{ error }}"
23+
24+
- type: "transform"
25+
template: |
26+
📷 Camera Health Alert
27+
28+
Status: {{ '❌ Unhealthy' if result.status == 'error' else '⚠️ Degraded' }}
29+
30+
{% if result.cameras is defined %}
31+
Camera Status:
32+
{% for camera in result.cameras %}
33+
• {{ camera.camera }}: {{ '✅ Healthy' if camera.status == 'healthy' else '❌ ' + (camera.status|capitalize) }}
34+
Message: {{ camera.message }}
35+
FPS: {{ camera.fps|default('N/A') }}
36+
37+
{% endfor %}
38+
{% else %}
39+
Message: {{ result.message|default('No status message available') }}
40+
FPS: {{ result.fps|default('N/A') }}
41+
{% endif %}
42+
43+
Timestamp: {{ now()|datetime }}
44+
45+
to:
46+
- "email://{{SMTP_SERVER}}:{{SMTP_PORT}}?user={{SMTP_USER}}&password={{SMTP_PASS}}&to={{ALERT_EMAIL}}&subject=📷 Camera Health Alert"
47+
- "log://logs/security_{{CAMERA_NAME}}.log"
48+
49+
50+
env_vars:
51+
- CAMERA_USER
52+
- CAMERA_PASS
53+
- CAMERA_IP
54+
- CAMERA_NAME
55+
- BACKUP_CAMERA_USER
56+
- BACKUP_CAMERA_PASS
57+
- BACKUP_CAMERA_IP
58+
- SMTP_SERVER
59+
- SMTP_PORT
60+
- SMTP_USER
61+
- SMTP_PASS
62+
- SECURITY_EMAIL
63+
- ADMIN_EMAIL
64+
- SECURITY_WEBHOOK
65+
- MQTT_BROKER
66+
- CAMERA_HEALTH_ENDPOINTS
67+
68+
settings:
69+
max_concurrent_routes: 5
70+
default_timeout: 60
71+
log_level: "info"
72+
metrics_enabled: true
73+
health_check_port: 8080
74+
frame_skip_ratio: 3
75+
max_memory_usage: "2GB"

examples/emailog.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Simple Email Logger Configuration
2+
routes:
3+
- name: email_logger
4+
from: "timer://5s" # Trigger every 5 seconds
5+
6+
processors:
7+
- type: transform
8+
template: |
9+
{
10+
"message": "Hello {{ now().strftime('%Y-%m-%d %H:%M:%S') }}",
11+
"timestamp": "{{ now().isoformat() }}"
12+
}
13+
14+
to:
15+
- "email://{{SMTP_SERVER}}:{{SMTP_PORT}}?user={{SMTP_USER}}&password={{SMTP_PASS}}&to={{ALERT_EMAIL}}&subject=Log Message {{ now().strftime('%H:%M:%S') }}"
16+
- "log:info"
17+
18+
# Required environment variables
19+
env_vars:
20+
- SMTP_SERVER
21+
- SMTP_PORT
22+
- SMTP_USER
23+
- SMTP_PASS
24+
- ALERT_EMAIL
25+
26+
settings:
27+
log_level: "info"
28+
max_concurrent_routes: 1

0 commit comments

Comments
 (0)