nedo-vision-worker-core 0.2.0__py3-none-any.whl → 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of nedo-vision-worker-core might be problematic. Click here for more details.
- nedo_vision_worker_core/__init__.py +47 -12
- nedo_vision_worker_core/callbacks/DetectionCallbackManager.py +306 -0
- nedo_vision_worker_core/callbacks/DetectionCallbackTypes.py +150 -0
- nedo_vision_worker_core/callbacks/__init__.py +27 -0
- nedo_vision_worker_core/cli.py +24 -34
- nedo_vision_worker_core/core_service.py +121 -55
- nedo_vision_worker_core/database/DatabaseManager.py +2 -2
- nedo_vision_worker_core/detection/BaseDetector.py +2 -1
- nedo_vision_worker_core/detection/DetectionManager.py +2 -2
- nedo_vision_worker_core/detection/RFDETRDetector.py +23 -5
- nedo_vision_worker_core/detection/YOLODetector.py +18 -5
- nedo_vision_worker_core/detection/detection_processing/DetectionProcessor.py +1 -1
- nedo_vision_worker_core/detection/detection_processing/HumanDetectionProcessor.py +57 -3
- nedo_vision_worker_core/detection/detection_processing/PPEDetectionProcessor.py +173 -10
- nedo_vision_worker_core/models/ai_model.py +23 -2
- nedo_vision_worker_core/pipeline/PipelineProcessor.py +299 -14
- nedo_vision_worker_core/pipeline/PipelineSyncThread.py +32 -0
- nedo_vision_worker_core/repositories/PPEDetectionRepository.py +18 -15
- nedo_vision_worker_core/repositories/RestrictedAreaRepository.py +17 -13
- nedo_vision_worker_core/services/SharedVideoStreamServer.py +276 -0
- nedo_vision_worker_core/services/VideoSharingDaemon.py +808 -0
- nedo_vision_worker_core/services/VideoSharingDaemonManager.py +257 -0
- nedo_vision_worker_core/streams/SharedVideoDeviceManager.py +383 -0
- nedo_vision_worker_core/streams/StreamSyncThread.py +16 -2
- nedo_vision_worker_core/streams/VideoStream.py +267 -246
- nedo_vision_worker_core/streams/VideoStreamManager.py +158 -6
- nedo_vision_worker_core/tracker/TrackerManager.py +25 -31
- nedo_vision_worker_core-0.3.1.dist-info/METADATA +444 -0
- {nedo_vision_worker_core-0.2.0.dist-info → nedo_vision_worker_core-0.3.1.dist-info}/RECORD +32 -25
- nedo_vision_worker_core-0.2.0.dist-info/METADATA +0 -347
- {nedo_vision_worker_core-0.2.0.dist-info → nedo_vision_worker_core-0.3.1.dist-info}/WHEEL +0 -0
- {nedo_vision_worker_core-0.2.0.dist-info → nedo_vision_worker_core-0.3.1.dist-info}/entry_points.txt +0 -0
- {nedo_vision_worker_core-0.2.0.dist-info → nedo_vision_worker_core-0.3.1.dist-info}/top_level.txt +0 -0
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: nedo-vision-worker-core
|
|
3
|
-
Version: 0.2.0
|
|
4
|
-
Summary: Nedo Vision Worker Core Library for AI Vision Processing
|
|
5
|
-
Author-email: Willy Achmat Fauzi <willy.achmat@gmail.com>
|
|
6
|
-
Maintainer-email: Willy Achmat Fauzi <willy.achmat@gmail.com>
|
|
7
|
-
License-Expression: MIT
|
|
8
|
-
Project-URL: Homepage, https://gitlab.com/sindika/research/nedo-vision/nedo-vision-worker-core-v2
|
|
9
|
-
Project-URL: Documentation, https://gitlab.com/sindika/research/nedo-vision/nedo-vision-worker-core-v2/-/blob/main/README.md
|
|
10
|
-
Project-URL: Repository, https://gitlab.com/sindika/research/nedo-vision/nedo-vision-worker-core-v2
|
|
11
|
-
Project-URL: Bug Reports, https://gitlab.com/sindika/research/nedo-vision/nedo-vision-worker-core-v2/-/issues
|
|
12
|
-
Keywords: computer-vision,machine-learning,ai,worker-core,deep-learning,object-detection,neural-networks,video-processing,pytorch,yolo
|
|
13
|
-
Classifier: Development Status :: 4 - Beta
|
|
14
|
-
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: Operating System :: OS Independent
|
|
16
|
-
Classifier: Programming Language :: Python :: 3
|
|
17
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
-
Classifier: Topic :: Multimedia :: Video
|
|
26
|
-
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
27
|
-
Classifier: Topic :: System :: Hardware
|
|
28
|
-
Classifier: Environment :: GPU
|
|
29
|
-
Classifier: Environment :: No Input/Output (Daemon)
|
|
30
|
-
Requires-Python: >=3.8
|
|
31
|
-
Description-Content-Type: text/markdown
|
|
32
|
-
Requires-Dist: alembic>=1.8.0
|
|
33
|
-
Requires-Dist: numpy>=1.21.0
|
|
34
|
-
Requires-Dist: opencv-python>=4.6.0
|
|
35
|
-
Requires-Dist: pillow>=8.0.0
|
|
36
|
-
Requires-Dist: psutil>=5.9.0
|
|
37
|
-
Requires-Dist: scipy>=1.9.0
|
|
38
|
-
Requires-Dist: shapely>=1.8.0
|
|
39
|
-
Requires-Dist: SQLAlchemy>=1.4.0
|
|
40
|
-
Requires-Dist: torch>=1.9.0
|
|
41
|
-
Requires-Dist: torchvision>=0.10.0
|
|
42
|
-
Requires-Dist: ultralytics>=8.0.0
|
|
43
|
-
Provides-Extra: dev
|
|
44
|
-
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
45
|
-
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
46
|
-
Requires-Dist: isort>=5.10.0; extra == "dev"
|
|
47
|
-
Requires-Dist: mypy>=0.950; extra == "dev"
|
|
48
|
-
Requires-Dist: flake8>=4.0.0; extra == "dev"
|
|
49
|
-
Requires-Dist: pre-commit>=2.17.0; extra == "dev"
|
|
50
|
-
|
|
51
|
-
# Nedo Vision Worker Core
|
|
52
|
-
|
|
53
|
-
A powerful Python library for AI-powered computer vision processing in the Nedo Vision platform. This library provides real-time video processing, object detection, PPE compliance monitoring, and safety violation detection with an extensible callback system.
|
|
54
|
-
|
|
55
|
-
## Features
|
|
56
|
-
|
|
57
|
-
- **Real-time AI Detection**: Advanced PPE and safety compliance detection
|
|
58
|
-
- **Multi-stream Processing**: Handle multiple video sources simultaneously
|
|
59
|
-
- **Extensible Callbacks**: Event-driven architecture for detection handling
|
|
60
|
-
- **System Diagnostics**: Built-in health checking and troubleshooting
|
|
61
|
-
- **Database Integration**: Persistent storage for detections and configurations
|
|
62
|
-
- **Drawing Utilities**: Rich visualization tools for detections
|
|
63
|
-
- **GPU Acceleration**: CUDA support for optimal performance
|
|
64
|
-
- **RTMP Streaming**: Real-time video streaming capabilities
|
|
65
|
-
|
|
66
|
-
## Installation
|
|
67
|
-
|
|
68
|
-
### Basic Installation
|
|
69
|
-
|
|
70
|
-
Install the package from PyPI:
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
pip install nedo-vision-worker-core
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### Installation with RF-DETR Support
|
|
77
|
-
|
|
78
|
-
RF-DETR is an optional dependency for advanced object detection. Install it separately:
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
# Install the main package
|
|
82
|
-
pip install nedo-vision-worker-core
|
|
83
|
-
|
|
84
|
-
# Install RF-DETR from GitHub (requires Git)
|
|
85
|
-
pip install rfdetr @ git+https://github.com/roboflow/rf-detr.git@1e63dbad402eea10f110e86013361d6b02ee0c09
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
**Note:** RF-DETR must be installed separately as PyPI doesn't support direct Git dependencies.
|
|
89
|
-
|
|
90
|
-
### GPU Support
|
|
91
|
-
|
|
92
|
-
For GPU support with CUDA 12.1:
|
|
93
|
-
|
|
94
|
-
```bash
|
|
95
|
-
pip install nedo-vision-worker-core --extra-index-url https://download.pytorch.org/whl/cu121
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### Development Installation
|
|
99
|
-
|
|
100
|
-
For development with all tools:
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
pip install nedo-vision-worker-core[dev]
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## Quick Start
|
|
107
|
-
|
|
108
|
-
### Using the CLI
|
|
109
|
-
|
|
110
|
-
After installation, you can use the worker core CLI:
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
# Show CLI help
|
|
114
|
-
nedo-core --help
|
|
115
|
-
|
|
116
|
-
# Run with default settings
|
|
117
|
-
nedo-core run
|
|
118
|
-
|
|
119
|
-
# Run with custom configuration
|
|
120
|
-
nedo-core run --log-level DEBUG --storage-path /data
|
|
121
|
-
|
|
122
|
-
# System health check
|
|
123
|
-
nedo-core doctor
|
|
124
|
-
|
|
125
|
-
# Run with custom server configuration
|
|
126
|
-
nedo-core run --storage-path /custom/storage --rtmp-server rtmp://server.com:1935/live
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Configuration Options
|
|
130
|
-
|
|
131
|
-
The service supports various configuration options:
|
|
132
|
-
|
|
133
|
-
- `--drawing-assets`: Path to drawing assets directory
|
|
134
|
-
- `--log-level`: Logging level (DEBUG|INFO|WARNING|ERROR)
|
|
135
|
-
- `--storage-path`: Storage path for databases and files
|
|
136
|
-
- `--rtmp-server`: RTMP server URL for video streaming
|
|
137
|
-
|
|
138
|
-
### Using Detection Callbacks
|
|
139
|
-
|
|
140
|
-
The worker core supports an extensible callback system for handling detection events in real-time:
|
|
141
|
-
|
|
142
|
-
```python
|
|
143
|
-
from nedo_vision_worker_core import CoreService
|
|
144
|
-
|
|
145
|
-
def handle_ppe_violation(detection_data):
|
|
146
|
-
"""Handle PPE violation detection."""
|
|
147
|
-
print(f"PPE Violation detected!")
|
|
148
|
-
print(f"Person ID: {detection_data['person_id']}")
|
|
149
|
-
print(f"Violations: {detection_data['attributes']}")
|
|
150
|
-
print(f"Confidence: {detection_data['confidence']}")
|
|
151
|
-
print(f"Image: {detection_data['image_path']}")
|
|
152
|
-
|
|
153
|
-
# Send alert, log to system, etc.
|
|
154
|
-
send_safety_alert(detection_data)
|
|
155
|
-
|
|
156
|
-
def handle_area_violation(detection_data):
|
|
157
|
-
"""Handle restricted area violation."""
|
|
158
|
-
print(f"Area Violation detected!")
|
|
159
|
-
print(f"Person ID: {detection_data['person_id']}")
|
|
160
|
-
print(f"Area: {detection_data['area_name']}")
|
|
161
|
-
# Handle area violation...
|
|
162
|
-
|
|
163
|
-
# Create service and register callbacks
|
|
164
|
-
service = CoreService()
|
|
165
|
-
service.register_detection_callback('ppe_detection', handle_ppe_violation)
|
|
166
|
-
service.register_detection_callback('area_violation', handle_area_violation)
|
|
167
|
-
|
|
168
|
-
# Start processing
|
|
169
|
-
service.run()
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### Advanced Callback Usage
|
|
173
|
-
|
|
174
|
-
For more sophisticated detection handling:
|
|
175
|
-
|
|
176
|
-
```python
|
|
177
|
-
from nedo_vision_worker_core import CoreService
|
|
178
|
-
import json
|
|
179
|
-
import requests
|
|
180
|
-
|
|
181
|
-
class SafetyMonitor:
|
|
182
|
-
def __init__(self):
|
|
183
|
-
self.violation_count = 0
|
|
184
|
-
self.alert_webhook = "https://your-alert-system.com/webhook"
|
|
185
|
-
|
|
186
|
-
def handle_ppe_violation(self, data):
|
|
187
|
-
"""Handle PPE safety violations."""
|
|
188
|
-
self.violation_count += 1
|
|
189
|
-
|
|
190
|
-
# Create alert payload
|
|
191
|
-
alert = {
|
|
192
|
-
"type": "ppe_violation",
|
|
193
|
-
"person_id": data["person_id"],
|
|
194
|
-
"violations": data["attributes"],
|
|
195
|
-
"confidence": data["confidence"],
|
|
196
|
-
"timestamp": data["timestamp"],
|
|
197
|
-
"image_url": self.upload_image(data["image_path"])
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
# Send webhook alert
|
|
201
|
-
try:
|
|
202
|
-
response = requests.post(self.alert_webhook, json=alert)
|
|
203
|
-
print(f"Alert sent: {response.status_code}")
|
|
204
|
-
except Exception as e:
|
|
205
|
-
print(f"Failed to send alert: {e}")
|
|
206
|
-
|
|
207
|
-
def upload_image(self, image_path):
|
|
208
|
-
"""Upload detection image to cloud storage."""
|
|
209
|
-
# Implement your image upload logic
|
|
210
|
-
return f"https://your-storage.com/images/{image_path}"
|
|
211
|
-
|
|
212
|
-
# Setup monitoring
|
|
213
|
-
monitor = SafetyMonitor()
|
|
214
|
-
service = CoreService()
|
|
215
|
-
|
|
216
|
-
# Register callbacks
|
|
217
|
-
service.register_detection_callback('ppe_detection', monitor.handle_ppe_violation)
|
|
218
|
-
|
|
219
|
-
# Start monitoring
|
|
220
|
-
service.run()
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
### Programmatic Usage
|
|
224
|
-
|
|
225
|
-
You can also use the core service programmatically:
|
|
226
|
-
|
|
227
|
-
```python
|
|
228
|
-
from nedo_vision_worker_core import CoreService
|
|
229
|
-
|
|
230
|
-
# Create and run the service with default settings
|
|
231
|
-
service = CoreService()
|
|
232
|
-
success = service.run()
|
|
233
|
-
|
|
234
|
-
# Create with custom parameters
|
|
235
|
-
service = CoreService(
|
|
236
|
-
drawing_assets_path="custom_assets",
|
|
237
|
-
log_level="DEBUG",
|
|
238
|
-
storage_path="/data/storage",
|
|
239
|
-
rtmp_server="rtmp://localhost:1935/live"
|
|
240
|
-
)
|
|
241
|
-
success = service.run()
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
## Architecture
|
|
245
|
-
|
|
246
|
-
### Core Components
|
|
247
|
-
|
|
248
|
-
- **CoreService**: Main service orchestrator for vision processing workflows
|
|
249
|
-
- **Detection Pipeline**: AI model processing with PyTorch backend
|
|
250
|
-
- **Callback System**: Event-driven detection handling via callbacks
|
|
251
|
-
- **Resource Monitor**: System resource monitoring (GPU, CPU, memory)
|
|
252
|
-
- **Database Manager**: Persistent storage for detections and configurations
|
|
253
|
-
|
|
254
|
-
### Callback System
|
|
255
|
-
|
|
256
|
-
#### Event Types
|
|
257
|
-
|
|
258
|
-
- **`ppe_detection`**: Personal Protective Equipment violations
|
|
259
|
-
- **`area_violation`**: Restricted area violations
|
|
260
|
-
- **`general_detection`**: All detection events
|
|
261
|
-
|
|
262
|
-
#### Callback Function Signature
|
|
263
|
-
|
|
264
|
-
```python
|
|
265
|
-
def detection_callback(detection_data: dict):
|
|
266
|
-
"""
|
|
267
|
-
Handle detection events.
|
|
268
|
-
|
|
269
|
-
Args:
|
|
270
|
-
detection_data: Dictionary containing:
|
|
271
|
-
- person_id: Unique identifier for detected person
|
|
272
|
-
- pipeline_id: Pipeline that generated the detection
|
|
273
|
-
- attributes: List of violation attributes
|
|
274
|
-
- confidence: Detection confidence score
|
|
275
|
-
- image_path: Path to detection image
|
|
276
|
-
- timestamp: Detection timestamp
|
|
277
|
-
- event_type: Type of detection event
|
|
278
|
-
"""
|
|
279
|
-
pass
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
#### Convenience Functions
|
|
283
|
-
|
|
284
|
-
```python
|
|
285
|
-
from nedo_vision_worker_core import (
|
|
286
|
-
register_ppe_detection_callback,
|
|
287
|
-
register_area_violation_callback,
|
|
288
|
-
register_general_detection_callback
|
|
289
|
-
)
|
|
290
|
-
|
|
291
|
-
# Register specific callbacks
|
|
292
|
-
register_ppe_detection_callback(my_ppe_handler)
|
|
293
|
-
register_area_violation_callback(my_area_handler)
|
|
294
|
-
register_general_detection_callback(my_general_handler)
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
### Dependencies
|
|
298
|
-
|
|
299
|
-
The service relies on several key technologies:
|
|
300
|
-
|
|
301
|
-
- **PyTorch**: Deep learning framework with CUDA support
|
|
302
|
-
- **OpenCV**: Computer vision and video processing
|
|
303
|
-
- **SQLAlchemy**: Database ORM and management
|
|
304
|
-
- **FFmpeg**: Video streaming and processing
|
|
305
|
-
- **Ultralytics**: YOLO model implementations
|
|
306
|
-
|
|
307
|
-
## Development Setup
|
|
308
|
-
|
|
309
|
-
For development and testing:
|
|
310
|
-
|
|
311
|
-
```bash
|
|
312
|
-
# Clone and setup development environment
|
|
313
|
-
git clone <repository-url>
|
|
314
|
-
cd nedo-vision-worker-core-v2
|
|
315
|
-
|
|
316
|
-
# Create virtual environment
|
|
317
|
-
python -m venv .venv
|
|
318
|
-
source .venv/bin/activate # Linux/Mac
|
|
319
|
-
# or
|
|
320
|
-
.venv\Scripts\activate # Windows
|
|
321
|
-
|
|
322
|
-
# Install in development mode
|
|
323
|
-
pip install -e .
|
|
324
|
-
|
|
325
|
-
# Run tests
|
|
326
|
-
python test.py
|
|
327
|
-
|
|
328
|
-
# Check system health
|
|
329
|
-
nedo-core doctor
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
## Troubleshooting
|
|
333
|
-
|
|
334
|
-
### Common Issues
|
|
335
|
-
|
|
336
|
-
1. **CUDA not detected**: Ensure NVIDIA drivers and CUDA toolkit are installed
|
|
337
|
-
2. **FFmpeg not found**: Install FFmpeg for video processing capabilities
|
|
338
|
-
3. **Permission errors**: Check storage directory permissions
|
|
339
|
-
4. **Model loading issues**: Verify model files and network connectivity
|
|
340
|
-
|
|
341
|
-
### Support
|
|
342
|
-
|
|
343
|
-
For issues and questions:
|
|
344
|
-
|
|
345
|
-
- Check the logs for detailed error information
|
|
346
|
-
- Run `nedo-core doctor` for system diagnostics
|
|
347
|
-
- Verify all dependencies are properly installed
|
|
File without changes
|
{nedo_vision_worker_core-0.2.0.dist-info → nedo_vision_worker_core-0.3.1.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{nedo_vision_worker_core-0.2.0.dist-info → nedo_vision_worker_core-0.3.1.dist-info}/top_level.txt
RENAMED
|
File without changes
|