Skip to content

About

OpenCV/YOLO live camera detection plus a drone telemetry bridge

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Computer Vision & Drone Telemetry Lab

OpenCV / YOLO scripts for live-camera detection, plus the Pygame drone simulator and Unity telemetry bridge they were developed against.

Four small, self-contained programs, each of which does one thing on a live camera feed:

Script What it does
src/person_detection.py YOLOv8 person detection, crops each detected person to a timestamped JPEG with the confidence score in the filename
src/face_recognition_camera.py pulls frames from an IP camera and runs face_recognition over them
src/face_recognition_known.py builds encodings from a known_faces/ gallery and labels matching faces by name
src/phone_detection_yolo.py YOLOv8 phone detection on a camera stream

Plus the simulation side, which is what the detections were meant to feed:

Script What it does
drone/drone_simulator.py Pygame quadcopter simulator: altitude, speed, climb/descent dynamics, flight log
drone/telemetry_server.py TCP socket server on localhost:65432 streaming JSON telemetry to a Unity client, one thread per connection

University coursework project, cleaned up for publication. Code comments are in Russian (original), README in English.

How the camera scripts work

The IP-camera scripts deliberately avoid cv2.VideoCapture and instead poll a still-frame endpoint (http://<ip>:8080/shot.jpg, the classic ESP32-CAM / IP Webcam URL) with requests + imutils. That is more robust on cheap hardware than a half-broken MJPEG stream, and it degrades gracefully: a dropped frame is just a dropped request.

frame = imutils.resize(cv2.imdecode(np.frombuffer(requests.get(url).content, np.uint8), cv2.IMREAD_COLOR), width=600)

The camera address is a constant at the top of each script — a placeholder in the published version, set it to your own.

src/face_recognition_known.py follows the standard face_recognition flow: encode every image in known_faces/, then compare 128-d encodings against the incoming frame with a distance tolerance and draw a name label on each match.

Telemetry bridge

drone/telemetry_server.py opens a TCP listening socket and, per client, pushes telemetry frames as newline-delimited JSON:

{"timestamp": 1717070000.0, "altitude": 12.4, "speed": 3.1, "status": "flying"}

It is intentionally transport-level rather than HTTP: Unity's TcpClient consumes it with a few lines of C#, and the threading model keeps multiple observers independent. drone_simulator.py in the same folder is the state source it is designed to read from.

Layout

cv-detection-lab/
├─ src/
│  ├─ person_detection.py        # YOLOv8 person crops
│  ├─ face_recognition_camera.py # face_recognition on an IP stream
│  ├─ face_recognition_known.py  # known_faces gallery matching
│  └─ phone_detection_yolo.py    # YOLOv8 phone detection
├─ drone/
│  ├─ drone_simulator.py         # Pygame flight simulator
│  └─ telemetry_server.py        # TCP JSON telemetry server
└─ requirements.txt

Quick start

python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt

face_recognition pulls in dlib, which needs CMake and a C++ toolchain:

pip install cmake dlib
pip install -r requirements.txt

Run any script from the directory it expects its data in:

cd src
python person_detection.py          # YOLOv8n is downloaded automatically by ultralytics
python face_recognition_known.py    # needs a known_faces/ folder next to it

Telemetry server:

cd drone
python telemetry_server.py

Privacy and data handling

The original project ran against photographs of real people and stored captured frames on disk. Those are not in this repository, and .gitignore keeps known_faces/, detected_persons/, *.jpg and *.pt out of version control. If you reuse the face-recognition script, treat the gallery images as personal data: get consent, keep them local, and do not commit them.

Notes and limitations

  • Model weights are not committed; Ultralytics downloads the pretrained checkpoint on first run.
  • Detection thresholds and frame width are constants in each script, not CLI options.
  • The drone simulator is kinematic (altitude/speed integration), not a 6-DOF flight model — it exists to produce plausible telemetry for the Unity side.
  • telemetry_server.py expects drone_simulator.py in the same folder; run it from drone/.

Stack

Python 3.10+ · OpenCV · Ultralytics YOLOv8 · face_recognition · imutils · Pygame · NumPy

About

OpenCV/YOLO live camera detection plus a drone telemetry bridge

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages