Computer-vision security and behavior analytics prototype built with YOLOv8, OpenCV, and Re-ID matching.
- Runs person detection and tracking on a live video source, webcam, RTSP stream, or local file.
- Detects loitering and suspicious behavior using pose-based analytics.
- Supports a multi-camera mode that matches the same person across different feeds with Re-ID.
- Uses configurable thresholds and source settings in
config.py.
security_ai.py- single-camera behavior analytics pipeline.multi_cam.py- multi-camera tracker with shared Re-ID.reid.py- cross-camera identity matching engine.behavior_analytics.py- behavior scoring and suspicion logic.config.py- source, model, and threshold settings.
- Python 3.10 or newer is recommended.
- A working installation of OpenCV and PyTorch.
- YOLO weights in the project folder:
yolov8n.ptyolov8n-pose.pt
- For multi-camera Re-ID, the upstream
deep-person-reidpackage from GitHub is required.
Install dependencies with:
pip install -r requirements.txt- Clone or open the project folder.
- Install the dependencies listed in
requirements.txt. - Update
config.pyto point at your preferred video source. - Make sure the YOLO weight files are present in the repository root.
Edit config.py to choose the source and tune detection behavior.
SOURCE_TYPEcontrols the input type:file,webcam,youtube, orrtsp.VIDEO_FILE_PATH,WEBCAM_INDEX,YOUTUBE_URL, andRTSP_URLhold the source values.MODEL_WEIGHTSandPOSE_WEIGHTSselect the YOLO models.LOITER_MIN_FRAMES,LOITER_PIXEL_THRESHOLD, and theREID_*values control behavior and matching sensitivity.
Single-camera behavior analytics:
python security_ai.pyMulti-camera tracking with Re-ID:
python multi_cam.py- Press
qto quit the viewer windows. - In the single-camera flow, click a person in the video window to lock on or reset the target, depending on the active pipeline behavior.
- The project is tuned for testing and prototyping, not production deployment.
- If YouTube playback is used,
cap-from-youtubemust be installed and the network must be reachable. - If the Re-ID package is unavailable,
multi_cam.pywill fall back to the single-camera path instructions.