This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
施工现场安全行为智能识别系统 v2.0.0 - Construction site safety behavior intelligent recognition system.
A dual-camera coordinated capture system that:
cd dual_camera_system
python main.py --panorama-ip 192.168.1.100 --ptz-ip 192.168.1.101
python main.py --interactive # Interactive mode
python main.py --skip-calibration # Skip auto-calibration
cd dual_camera_system
python safety_main.py --panorama-ip 192.168.1.100 --ptz-ip 192.168.1.101
--model-size {n,s,m,l,x} # YOLO11 model size
--no-gpu # Disable GPU
--ocr-host localhost --ocr-port 8111 # OCR API endpoint
pip install opencv-python opencv-contrib-python ultralytics
# OCR requires llama-server running on localhost:8111
dual_camera_system/
├── main.py # OCR mode entry point
├── safety_main.py # Safety mode entry point
├── config.py # Config aggregation (imports from config/)
├── config/ # Modular configuration
│ ├── system.py # Feature toggles and working mode
│ ├── camera.py # Camera IPs, credentials, SDK paths
│ ├── detection.py # YOLO detection config
│ └── ... # Other module configs
├── dahua_sdk.py # Dahua SDK ctypes wrapper
├── panorama_camera.py # Panoramic camera + YOLO detection
├── ptz_camera.py # PTZ dome camera control
├── calibration.py # Visual calibration (motion detection + feature matching)
├── coordinator.py # Camera coordination logic (AsyncCoordinator, SequentialCoordinator)
├── safety_detector.py # Safety detection (hard hat/reflective vest)
├── safety_coordinator.py # Safety mode coordinator
├── ocr_recognizer.py # OCR number recognition
├── event_pusher.py # Event push to platform
├── voice_announcer.py # TTS voice announcement
└── llm_service.py # LLM service wrapper (Qwen2.5-VL)
In main.py, YOLO/PyTorch MUST load before Dahua SDK. The SDK's CLIENT_Init modifies process memory mapping; if loaded before PyTorch, it causes segfault. The current code handles this correctly - do not change the order.
config/camera.py auto-selects SDK path by CPU architecture:
aarch64 → /home/admin/dsh/dh/arm/Bin (Orange Pi)x86_64 → /home/wen/dsh/dh/Bin (x86 Linux server)../dh/Bin (development reference)CALIBRATION_CONFIG.daily_calibration_timeControlled by config/system.py:
mode: 'safety' - Safety detection mode (safety_main.py)mode: 'ocr' - Number recognition mode (main.py)Feature toggles control enabled modules:
enable_detection, enable_safety_detectionenable_calibration, enable_ptz_trackingenable_ocr, enable_llmenable_event_push, enable_voice_announcessh admin@192.168.20.84
conda activate rknn
cd /home/admin/dsh/dual_camera_system
/home/wen/dsh/yolo/yolo11m_safety.ptrtsp://username:password@ip:554/cam/realmonitor?channel=0&subtype=0
Note: subtype=0 for main stream, subtype=1 for sub stream.