# Nedo Vision Worker Core
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.
## Features
- **Real-time AI Detection**: Advanced PPE and safety compliance detection
- **Multi-stream Processing**: Handle multiple video sources simultaneously
- **Extensible Callbacks**: Event-driven architecture for detection handling
- **System Diagnostics**: Built-in health checking and troubleshooting
- **Database Integration**: Persistent storage for detections and configurations
- **Drawing Utilities**: Rich visualization tools for detections
- **GPU Acceleration**: CUDA support for optimal performance
- **RTMP Streaming**: Real-time video streaming capabilities
## Installation
### Basic Installation
Install the package from PyPI:
```bash
pip install nedo-vision-worker-core
```
### Installation with RF-DETR Support
RF-DETR is an optional dependency for advanced object detection. Install it separately:
```bash
# Install the main package
pip install nedo-vision-worker-core
# Install RF-DETR from GitHub (requires Git)
pip install rfdetr @ git+https://github.com/roboflow/rf-detr.git@1e63dbad402eea10f110e86013361d6b02ee0c09
```
**Note:** RF-DETR must be installed separately as PyPI doesn't support direct Git dependencies.
### GPU Support
For GPU support with CUDA 12.1:
```bash
pip install nedo-vision-worker-core --extra-index-url https://download.pytorch.org/whl/cu121
```
### Development Installation
For development with all tools:
```bash
pip install nedo-vision-worker-core[dev]
```
## Quick Start
### Using the CLI
After installation, you can use the worker core CLI:
```bash
# Show CLI help
nedo-core --help
# Run with default settings
nedo-core run
# Run with custom configuration
nedo-core run --log-level DEBUG --storage-path /data
# System health check
nedo-core doctor
# Run with custom server configuration
nedo-core run --storage-path /custom/storage --rtmp-server rtmp://server.com:1935/live
```
### Configuration Options
The service supports various configuration options:
- `--drawing-assets`: Path to drawing assets directory
- `--log-level`: Logging level (DEBUG|INFO|WARNING|ERROR)
- `--storage-path`: Storage path for databases and files
- `--rtmp-server`: RTMP server URL for video streaming
### Using Detection Callbacks
The worker core supports an extensible callback system for handling detection events in real-time:
```python
from nedo_vision_worker_core import CoreService
def handle_ppe_violation(detection_data):
"""Handle PPE violation detection."""
print(f"PPE Violation detected!")
print(f"Person ID: {detection_data['person_id']}")
print(f"Violations: {detection_data['attributes']}")
print(f"Confidence: {detection_data['confidence']}")
print(f"Image: {detection_data['image_path']}")
# Send alert, log to system, etc.
send_safety_alert(detection_data)
def handle_area_violation(detection_data):
"""Handle restricted area violation."""
print(f"Area Violation detected!")
print(f"Person ID: {detection_data['person_id']}")
print(f"Area: {detection_data['area_name']}")
# Handle area violation...
# Create service and register callbacks
service = CoreService()
service.register_detection_callback('ppe_detection', handle_ppe_violation)
service.register_detection_callback('area_violation', handle_area_violation)
# Start processing
service.run()
```
### Advanced Callback Usage
For more sophisticated detection handling:
```python
from nedo_vision_worker_core import CoreService
import json
import requests
class SafetyMonitor:
def __init__(self):
self.violation_count = 0
self.alert_webhook = "https://your-alert-system.com/webhook"
def handle_ppe_violation(self, data):
"""Handle PPE safety violations."""
self.violation_count += 1
# Create alert payload
alert = {
"type": "ppe_violation",
"person_id": data["person_id"],
"violations": data["attributes"],
"confidence": data["confidence"],
"timestamp": data["timestamp"],
"image_url": self.upload_image(data["image_path"])
}
# Send webhook alert
try:
response = requests.post(self.alert_webhook, json=alert)
print(f"Alert sent: {response.status_code}")
except Exception as e:
print(f"Failed to send alert: {e}")
def upload_image(self, image_path):
"""Upload detection image to cloud storage."""
# Implement your image upload logic
return f"https://your-storage.com/images/{image_path}"
# Setup monitoring
monitor = SafetyMonitor()
service = CoreService()
# Register callbacks
service.register_detection_callback('ppe_detection', monitor.handle_ppe_violation)
# Start monitoring
service.run()
```
### Programmatic Usage
You can also use the core service programmatically:
```python
from nedo_vision_worker_core import CoreService
# Create and run the service with default settings
service = CoreService()
success = service.run()
# Create with custom parameters
service = CoreService(
drawing_assets_path="custom_assets",
log_level="DEBUG",
storage_path="/data/storage",
rtmp_server="rtmp://localhost:1935/live"
)
success = service.run()
```
## Architecture
### Core Components
- **CoreService**: Main service orchestrator for vision processing workflows
- **Detection Pipeline**: AI model processing with PyTorch backend
- **Callback System**: Event-driven detection handling via callbacks
- **Resource Monitor**: System resource monitoring (GPU, CPU, memory)
- **Database Manager**: Persistent storage for detections and configurations
### Callback System
#### Event Types
- **`ppe_detection`**: Personal Protective Equipment violations
- **`area_violation`**: Restricted area violations
- **`general_detection`**: All detection events
#### Callback Function Signature
```python
def detection_callback(detection_data: dict):
"""
Handle detection events.
Args:
detection_data: Dictionary containing:
- person_id: Unique identifier for detected person
- pipeline_id: Pipeline that generated the detection
- attributes: List of violation attributes
- confidence: Detection confidence score
- image_path: Path to detection image
- timestamp: Detection timestamp
- event_type: Type of detection event
"""
pass
```
#### Convenience Functions
```python
from nedo_vision_worker_core import (
register_ppe_detection_callback,
register_area_violation_callback,
register_general_detection_callback
)
# Register specific callbacks
register_ppe_detection_callback(my_ppe_handler)
register_area_violation_callback(my_area_handler)
register_general_detection_callback(my_general_handler)
```
### Dependencies
The service relies on several key technologies:
- **PyTorch**: Deep learning framework with CUDA support
- **OpenCV**: Computer vision and video processing
- **SQLAlchemy**: Database ORM and management
- **FFmpeg**: Video streaming and processing
- **Ultralytics**: YOLO model implementations
## Development Setup
For development and testing:
```bash
# Clone and setup development environment
git clone <repository-url>
cd nedo-vision-worker-core-v2
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/Mac
# or
.venv\Scripts\activate # Windows
# Install in development mode
pip install -e .
# Run tests
python test.py
# Check system health
nedo-core doctor
```
## Troubleshooting
### Common Issues
1. **CUDA not detected**: Ensure NVIDIA drivers and CUDA toolkit are installed
2. **FFmpeg not found**: Install FFmpeg for video processing capabilities
3. **Permission errors**: Check storage directory permissions
4. **Model loading issues**: Verify model files and network connectivity
### Support
For issues and questions:
- Check the logs for detailed error information
- Run `nedo-core doctor` for system diagnostics
- Verify all dependencies are properly installed
Raw data
{
"_id": null,
"home_page": null,
"name": "nedo-vision-worker-core",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Willy Achmat Fauzi <willy.achmat@gmail.com>",
"keywords": "computer-vision, machine-learning, ai, worker-core, deep-learning, object-detection, neural-networks, video-processing, pytorch, yolo",
"author": null,
"author_email": "Willy Achmat Fauzi <willy.achmat@gmail.com>",
"download_url": null,
"platform": null,
"description": "# Nedo Vision Worker Core\n\nA 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.\n\n## Features\n\n- **Real-time AI Detection**: Advanced PPE and safety compliance detection\n- **Multi-stream Processing**: Handle multiple video sources simultaneously\n- **Extensible Callbacks**: Event-driven architecture for detection handling\n- **System Diagnostics**: Built-in health checking and troubleshooting\n- **Database Integration**: Persistent storage for detections and configurations\n- **Drawing Utilities**: Rich visualization tools for detections\n- **GPU Acceleration**: CUDA support for optimal performance\n- **RTMP Streaming**: Real-time video streaming capabilities\n\n## Installation\n\n### Basic Installation\n\nInstall the package from PyPI:\n\n```bash\npip install nedo-vision-worker-core\n```\n\n### Installation with RF-DETR Support\n\nRF-DETR is an optional dependency for advanced object detection. Install it separately:\n\n```bash\n# Install the main package\npip install nedo-vision-worker-core\n\n# Install RF-DETR from GitHub (requires Git)\npip install rfdetr @ git+https://github.com/roboflow/rf-detr.git@1e63dbad402eea10f110e86013361d6b02ee0c09\n```\n\n**Note:** RF-DETR must be installed separately as PyPI doesn't support direct Git dependencies.\n\n### GPU Support\n\nFor GPU support with CUDA 12.1:\n\n```bash\npip install nedo-vision-worker-core --extra-index-url https://download.pytorch.org/whl/cu121\n```\n\n### Development Installation\n\nFor development with all tools:\n\n```bash\npip install nedo-vision-worker-core[dev]\n```\n\n## Quick Start\n\n### Using the CLI\n\nAfter installation, you can use the worker core CLI:\n\n```bash\n# Show CLI help\nnedo-core --help\n\n# Run with default settings\nnedo-core run\n\n# Run with custom configuration\nnedo-core run --log-level DEBUG --storage-path /data\n\n# System health check\nnedo-core doctor\n\n# Run with custom server configuration\nnedo-core run --storage-path /custom/storage --rtmp-server rtmp://server.com:1935/live\n```\n\n### Configuration Options\n\nThe service supports various configuration options:\n\n- `--drawing-assets`: Path to drawing assets directory\n- `--log-level`: Logging level (DEBUG|INFO|WARNING|ERROR)\n- `--storage-path`: Storage path for databases and files\n- `--rtmp-server`: RTMP server URL for video streaming\n\n### Using Detection Callbacks\n\nThe worker core supports an extensible callback system for handling detection events in real-time:\n\n```python\nfrom nedo_vision_worker_core import CoreService\n\ndef handle_ppe_violation(detection_data):\n \"\"\"Handle PPE violation detection.\"\"\"\n print(f\"PPE Violation detected!\")\n print(f\"Person ID: {detection_data['person_id']}\")\n print(f\"Violations: {detection_data['attributes']}\")\n print(f\"Confidence: {detection_data['confidence']}\")\n print(f\"Image: {detection_data['image_path']}\")\n\n # Send alert, log to system, etc.\n send_safety_alert(detection_data)\n\ndef handle_area_violation(detection_data):\n \"\"\"Handle restricted area violation.\"\"\"\n print(f\"Area Violation detected!\")\n print(f\"Person ID: {detection_data['person_id']}\")\n print(f\"Area: {detection_data['area_name']}\")\n # Handle area violation...\n\n# Create service and register callbacks\nservice = CoreService()\nservice.register_detection_callback('ppe_detection', handle_ppe_violation)\nservice.register_detection_callback('area_violation', handle_area_violation)\n\n# Start processing\nservice.run()\n```\n\n### Advanced Callback Usage\n\nFor more sophisticated detection handling:\n\n```python\nfrom nedo_vision_worker_core import CoreService\nimport json\nimport requests\n\nclass SafetyMonitor:\n def __init__(self):\n self.violation_count = 0\n self.alert_webhook = \"https://your-alert-system.com/webhook\"\n\n def handle_ppe_violation(self, data):\n \"\"\"Handle PPE safety violations.\"\"\"\n self.violation_count += 1\n\n # Create alert payload\n alert = {\n \"type\": \"ppe_violation\",\n \"person_id\": data[\"person_id\"],\n \"violations\": data[\"attributes\"],\n \"confidence\": data[\"confidence\"],\n \"timestamp\": data[\"timestamp\"],\n \"image_url\": self.upload_image(data[\"image_path\"])\n }\n\n # Send webhook alert\n try:\n response = requests.post(self.alert_webhook, json=alert)\n print(f\"Alert sent: {response.status_code}\")\n except Exception as e:\n print(f\"Failed to send alert: {e}\")\n\n def upload_image(self, image_path):\n \"\"\"Upload detection image to cloud storage.\"\"\"\n # Implement your image upload logic\n return f\"https://your-storage.com/images/{image_path}\"\n\n# Setup monitoring\nmonitor = SafetyMonitor()\nservice = CoreService()\n\n# Register callbacks\nservice.register_detection_callback('ppe_detection', monitor.handle_ppe_violation)\n\n# Start monitoring\nservice.run()\n```\n\n### Programmatic Usage\n\nYou can also use the core service programmatically:\n\n```python\nfrom nedo_vision_worker_core import CoreService\n\n# Create and run the service with default settings\nservice = CoreService()\nsuccess = service.run()\n\n# Create with custom parameters\nservice = CoreService(\n drawing_assets_path=\"custom_assets\",\n log_level=\"DEBUG\",\n storage_path=\"/data/storage\",\n rtmp_server=\"rtmp://localhost:1935/live\"\n)\nsuccess = service.run()\n```\n\n## Architecture\n\n### Core Components\n\n- **CoreService**: Main service orchestrator for vision processing workflows\n- **Detection Pipeline**: AI model processing with PyTorch backend\n- **Callback System**: Event-driven detection handling via callbacks\n- **Resource Monitor**: System resource monitoring (GPU, CPU, memory)\n- **Database Manager**: Persistent storage for detections and configurations\n\n### Callback System\n\n#### Event Types\n\n- **`ppe_detection`**: Personal Protective Equipment violations\n- **`area_violation`**: Restricted area violations\n- **`general_detection`**: All detection events\n\n#### Callback Function Signature\n\n```python\ndef detection_callback(detection_data: dict):\n \"\"\"\n Handle detection events.\n\n Args:\n detection_data: Dictionary containing:\n - person_id: Unique identifier for detected person\n - pipeline_id: Pipeline that generated the detection\n - attributes: List of violation attributes\n - confidence: Detection confidence score\n - image_path: Path to detection image\n - timestamp: Detection timestamp\n - event_type: Type of detection event\n \"\"\"\n pass\n```\n\n#### Convenience Functions\n\n```python\nfrom nedo_vision_worker_core import (\n register_ppe_detection_callback,\n register_area_violation_callback,\n register_general_detection_callback\n)\n\n# Register specific callbacks\nregister_ppe_detection_callback(my_ppe_handler)\nregister_area_violation_callback(my_area_handler)\nregister_general_detection_callback(my_general_handler)\n```\n\n### Dependencies\n\nThe service relies on several key technologies:\n\n- **PyTorch**: Deep learning framework with CUDA support\n- **OpenCV**: Computer vision and video processing\n- **SQLAlchemy**: Database ORM and management\n- **FFmpeg**: Video streaming and processing\n- **Ultralytics**: YOLO model implementations\n\n## Development Setup\n\nFor development and testing:\n\n```bash\n# Clone and setup development environment\ngit clone <repository-url>\ncd nedo-vision-worker-core-v2\n\n# Create virtual environment\npython -m venv .venv\nsource .venv/bin/activate # Linux/Mac\n# or\n.venv\\Scripts\\activate # Windows\n\n# Install in development mode\npip install -e .\n\n# Run tests\npython test.py\n\n# Check system health\nnedo-core doctor\n```\n\n## Troubleshooting\n\n### Common Issues\n\n1. **CUDA not detected**: Ensure NVIDIA drivers and CUDA toolkit are installed\n2. **FFmpeg not found**: Install FFmpeg for video processing capabilities\n3. **Permission errors**: Check storage directory permissions\n4. **Model loading issues**: Verify model files and network connectivity\n\n### Support\n\nFor issues and questions:\n\n- Check the logs for detailed error information\n- Run `nedo-core doctor` for system diagnostics\n- Verify all dependencies are properly installed\n",
"bugtrack_url": null,
"license": null,
"summary": "Nedo Vision Worker Core Library for AI Vision Processing",
"version": "0.2.0",
"project_urls": {
"Bug Reports": "https://gitlab.com/sindika/research/nedo-vision/nedo-vision-worker-core-v2/-/issues",
"Documentation": "https://gitlab.com/sindika/research/nedo-vision/nedo-vision-worker-core-v2/-/blob/main/README.md",
"Homepage": "https://gitlab.com/sindika/research/nedo-vision/nedo-vision-worker-core-v2",
"Repository": "https://gitlab.com/sindika/research/nedo-vision/nedo-vision-worker-core-v2"
},
"split_keywords": [
"computer-vision",
" machine-learning",
" ai",
" worker-core",
" deep-learning",
" object-detection",
" neural-networks",
" video-processing",
" pytorch",
" yolo"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "55ffc5713819b974e254a0bc10a7ae743a08961349415373ca1221ce006b8356",
"md5": "b12f436bcc3b65a2d18712d9aa754d47",
"sha256": "be7c33a25bc55640f6a583c031a2922cdfb02adb4bae2dc8f4b9fb3e268ed6b0"
},
"downloads": -1,
"filename": "nedo_vision_worker_core-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b12f436bcc3b65a2d18712d9aa754d47",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 181111,
"upload_time": "2025-08-04T07:20:44",
"upload_time_iso_8601": "2025-08-04T07:20:44.861664Z",
"url": "https://files.pythonhosted.org/packages/55/ff/c5713819b974e254a0bc10a7ae743a08961349415373ca1221ce006b8356/nedo_vision_worker_core-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-04 07:20:44",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "sindika",
"gitlab_project": "research",
"lcname": "nedo-vision-worker-core"
}