Note: This page was translated into English by AI. The original write-up is in Turkish.

Project Purpose and Scope

This project is my senior capstone (Undergraduate, 4th year, Fall 2025) completed at İskenderun Technical University. The thesis was accepted and successfully defended. Because of that, some words in images or diagrams are in Turkish.

You can access the full, more detailed thesis here.

A locally running threat-assessment module was developed to be mounted on urban-security-oriented autonomous/semi-autonomous systems. From the camera stream, it determines in real time whether a person is armed or unarmed, reports status and coordinates to the host PC, and simultaneously tracks the target with a two-axis turret. The system is designed to be integrated into drones or ground robots via a lightweight gimbal structure.


General Operating Principle

  • Perception (Model): Webcam frames are processed with YOLOv8; person/weapon objects and center coordinates are extracted.
  • Decision: The state is classified into three categories: A = Unarmed Person, B = Armed Person, C = None. Time tolerances are applied to handle brief occlusions of the weapon/person.
  • Action (Turret): Horizontal/vertical servos move according to coordinate error; a laser and an RGB LED are used as status indicators.

Prototype – Front view
Prototype – Front view

Prototype – Left and front views
Prototype – Left and front views

Prototype – Top view
Prototype – Top view


Hardware Architecture

  • Microcontroller: Arduino UNO (ample I/O, sufficient processing power, serial communication).
  • Servos:MG90S (metal gears, ~1.5 kg·cm torque class).
  • Indicators: 5V laser module and RGB LED module.
  • Power: Servos powered from a dedicated 5V/1.5A adapter for stability; other modules from the Arduino.
  • Imaging: USB 2 MP webcam (power and data via PC).
  • Mechanics: Gimbal/turret parts 3D-printed in ABS (strength) and PLA (light weight); wood used for base/frame parts.

Circuit schematic
Circuit – Schematic of the prototype

Tinkercad schematic
Circuit – Prototype schematic in Tinkercad


Software Structure

1) PC Application

  • Language / Libraries: Python, YOLOv8, OpenCV, PySide6 (GUI).
  • Workflow: Capture frame → detect person/weapon with YOLOv8 → extract class and coordinates → apply time tolerances → compose serial message → send to Arduino.
  • Time Tolerances: GUN_WAIT = 10 s, MAN_WAIT = 1 s (maintains stability even if the weapon/person is briefly occluded).
  • Serial Protocol:
{center_x:03}{center_y:03}{C3}{C4}\n
C3 ∈ {A, B, C}   # state
C4 ∈ {Y, N}      # laser on/off

Application flowchart
Application software flowchart

Turret firmware flowchart
Turret (firmware) software flowchart

2) Turret (Arduino Firmware)

  • Pins: RGB LED (2–4), Horizontal servo (5), Vertical servo (6), Laser (7), Serial 9600 baud.
  • State Management:
    • A (unarmed): LED = green, target tracking active
    • B (armed): LED = red, target tracking + optional laser
    • C (none): LED = blue, scan mode (sweep left–right)
  • Motion: Screen center (320, 240) as reference; if error > tolerance, increment/decrement per axis; clamp vertical 0–90°, horizontal 0–180°.

Unarmed person response
Prototype response when an UNARMED person is detected

Armed person response
Prototype response when an ARMED person is detected

Idle response
Prototype response when IDLE (scan mode)


Model (YOLOv8) Training

  • Base model: Fine-tuned yolov8l.pt with close-range data.
  • Hyperparameters: epochs = 64, batch = 8; dataset focused on short-distance/altitude scenarios.
  • Outputs: Label/prediction samples and validation with field video frames.

Unarmed detection bounding box
Application – Bounding box when an unarmed person is detected

Armed detection bounding box
Application – Bounding box when an ARMED person is detected


Differences from Other Solutions

  • Fully Local Processing: No cloud dependency — privacy and offline operation advantages.
  • Portable Integrated Design: Easily added to various mobile platforms (drone / UGV).
  • Active Tracking Camera: 2-axis servo tracking unlike static security cameras.
  • Objective: Vehicle/robot situational awareness rather than fixed-infrastructure security.

Comparison examples: commercial systems such as SafePointe and Xtract One.


Challenges and Solutions

  • Insufficient servo current → Added a dedicated 5V/1.5A adapter, separated data lines, reduced noise.
  • Narrow field of view → Extended with an external camera + rotatable turret.
  • Incompatible motion algorithm → Switched from coordinate-based to distance-based control.
  • Image quality / model stability → Balanced temporary losses using time tolerances (10 s).

Conclusion

The perception–decision–action chain was implemented end-to-end: local threat detection with YOLOv8, transfer to the turret via a serial protocol, servo-based target tracking, and visual status indicators — all combined in a single module. The integration-oriented design provides plug-and-play flexibility for real-world platforms (drone, UGV).

Projenin Amacı ve Kapsamı

Bu proje, İskenderun Teknik Üniversitesi’nde tamamladığım lisans bitirme tezimdir (4. sınıf, Güz 2025). Tez kabul edilmiş ve başarıyla savunulmuştur.

Tezin tamamına buradan ulaşabilirsiniz.

Kent güvenliğine yönelik otonom/yarı otonom sistemlere entegre edilmek üzere yerel çalışan bir tehdit değerlendirme modülü geliştirilmiştir. Sistem, kamera görüntüsünden bir kişinin silahlı mı yoksa silahsız mı olduğunu gerçek zamanlı olarak belirler, durum ve koordinat bilgisini ana bilgisayara iletir ve eş zamanlı olarak hedefi iki eksenli bir türetle takip eder. Tasarım, hafif bir gimbal yapısı aracılığıyla insansız hava araçlarına veya kara araçlarına entegre edilebilecek şekilde kurgulanmıştır.


Genel Çalışma Prensibi

  • Algılama (Model): Web kamerası görüntüleri YOLOv8 ile işlenir; kişi/silah nesneleri ve merkez koordinatları çıkarılır.
  • Karar: Durum üç kategoriye ayrılır: A = Silahsız Kişi, B = Silahlı Kişi, C = Yok. Silah/kişinin kısa süreli gizlenmesi durumlarına karşı zaman toleransları uygulanır.
  • Eylem (Türet): Yatay/dikey servolar koordinat hatasına göre hareket eder; durum göstergesi olarak lazer ve RGB LED kullanılır.

Prototip – Ön görünüm
Prototip – Ön görünüm

Prototip – Sol ve ön görünüm
Prototip – Sol ve ön görünüm

Prototip – Üst görünüm
Prototip – Üst görünüm


Donanım Mimarisi

  • Mikrodenetleyici: Arduino UNO (yeterli pin sayısı, seri haberleşme).
  • Servolar:MG90S (metal dişli, ~1,5 kg·cm tork sınıfı).
  • Göstergeler: 5V lazer modülü ve RGB LED modülü.
  • Güç: Stabilite için servolar ayrı bir 5V/1,5A adaptörden beslenir; diğer modüller Arduino’dan beslenir.
  • Görüntüleme: USB 2 MP web kamerası (güç ve veri PC üzerinden).
  • Mekanik: Gimbal/türet parçaları ABS (dayanıklılık) ve PLA (hafiflik) ile 3D baskı; taban/çerçeve parçaları için ahşap kullanılmıştır.

Devre şeması
Devre – Prototip şeması

Tinkercad şeması
Devre – Tinkercad'de prototip şeması


Yazılım Yapısı

1) PC Uygulaması

  • Dil / Kütüphaneler: Python, YOLOv8, OpenCV, PySide6 (GUI).
  • Akış: Kare yakala → YOLOv8 ile kişi/silah tespit et → sınıf ve koordinatları çıkar → zaman toleranslarını uygula → seri mesaj oluştur → Arduino’ya gönder.
  • Zaman Toleransları: GUN_WAIT = 10 s, MAN_WAIT = 1 s (silah/kişi kısa süreliğine gizlendiğinde bile kararlılığı korur).
  • Seri Protokol:
{center_x:03}{center_y:03}{C3}{C4}\n
C3 ∈ {A, B, C}   # durum
C4 ∈ {Y, N}      # lazer açık/kapalı

Uygulama akış şeması
Uygulama yazılımı akış şeması

Türet firmware akış şeması
Türet (firmware) yazılımı akış şeması

2) Türet (Arduino Firmware)

  • Pinler: RGB LED (2–4), Yatay servo (5), Dikey servo (6), Lazer (7), Seri 9600 baud.
  • Durum Yönetimi:
    • A (silahsız): LED = yeşil, hedef takibi aktif
    • B (silahlı): LED = kırmızı, hedef takibi + isteğe bağlı lazer
    • C (yok): LED = mavi, tarama modu (sola–sağa tarama)
  • Hareket: Ekran merkezi (320, 240) referans; hata > tolerans ise her eksende artır/azalt; dikey 0–90°, yatay 0–180° ile sınırlandırılır.

Silahsız kişi tespiti
SİLAHSIZ kişi tespit edildiğinde prototip tepkisi

Silahlı kişi tespiti
SİLAHLI kişi tespit edildiğinde prototip tepkisi

Boşta modu
BOŞ durumda prototip tepkisi (tarama modu)


Model (YOLOv8) Eğitimi

  • Temel model: Yakın mesafe verileriyle ince ayar yapılmış yolov8l.pt.
  • Hiperparametreler: epochs = 64, batch = 8; veri seti kısa mesafe/yükseklik senaryolarına odaklıdır.
  • Çıktılar: Etiket/tahmin örnekleri ve saha video kareleriyle doğrulama.

Silahsız kişi bounding box
Uygulama – Silahsız kişi tespit edildiğinde sınırlayıcı kutu

Silahlı kişi bounding box
Uygulama – SİLAHLI kişi tespit edildiğinde sınırlayıcı kutu


Diğer Çözümlerden Farkları

  • Tamamen Yerel İşleme: Bulut bağımlılığı yok; gizlilik ve çevrimdışı çalışma avantajı.
  • Taşınabilir Entegre Tasarım: Farklı mobil platformlara (drone / KİHA) kolayca eklenebilir.
  • Aktif Takip Kamerası: Statik güvenlik kameralarından farklı olarak 2 eksenli servo takibi.
  • Hedef: Sabit altyapı güvenliği yerine araç/robot durumsal farkındalığı.

Karşılaştırma örnekleri: SafePointe ve Xtract One gibi ticari sistemler.


Karşılaşılan Zorluklar ve Çözümler

  • Yetersiz servo akımı → Ayrı 5V/1,5A adaptör eklendi, veri hatları ayrıldı, gürültü azaltıldı.
  • Dar görüş açısı → Harici kamera + döndürülebilir türet ile genişletildi.
  • Uyumsuz hareket algoritması → Koordinat tabanlıdan mesafe tabanlı kontrole geçildi.
  • Görüntü kalitesi / model kararlılığı → Geçici kayıplar zaman toleranslarıyla (10 s) dengelendi.

Sonuç

Algılama–Karar–Eylem zinciri uçtan uca hayata geçirildi: YOLOv8 ile yerel tehdit tespiti, seri protokol aracılığıyla türete aktarım, servo tabanlı hedef takibi ve görsel durum göstergeleri tek bir modülde birleştirildi. Entegrasyon odaklı tasarım, gerçek dünya platformları (drone, KİHA) için tak-çalıştır esnekliği sağlamaktadır.