Skip to content

Jminu/RubikPi-Detection

 
 

Repository files navigation

Rubik Pi Object Detection

실시간 과속 차량 감지 시스템 on Rubik Pi

A real-time speeding vehicle detection system on Rubik Pi

Overview

이 프로젝트는 Qualcomm 기반 Rubik Pi 하드웨어에서 YOLO 객체 탐지와 GStreamer를 활용해, 실시간으로 과속 차량을 감지하는 완전한 엣지 기반 시스템입니다. 카메라 입력부터 추론, 트래킹, 속도 측정, 과속 차량 촬영까지 모든 과정을 로컬에서 처리하므로 클라우드 연산이 전혀 필요하지 않습니다.

This project is a fully edge-based system that detects speeding vehicles in real time using YOLO object detection + GStreamer on Qualcomm-based Rubik Pi hardware. It avoids the need for cloud computation by processing everything locally — from camera input to inference, tracking, speed calculation, and violation capture.

Tech Stack

Category Technologies
Hardware Rubik Pi 3, IMX477 image sensor, 10MP HQ Lens(16mm)
Object Detection YOLOv5m
Acceleration Qualcomm SNPE + TFLite delegate
Pipeline GStreamer
Programming Python
Features On-device tracking, speed measurement, snapshot, multithreading

Table of Contents

  • 실행 방법 How to Run
  • 파이프라인 구성 GStreamer + YOLO Pipeline
  • 객체 트래킹 Object Tracking
  • 속도 측정 Speed Measurement
  • 멀티 스레딩 Multithreading

How to Run

root 디렉토리 밑에 run.sh를 실행한다.

Execute the run.sh script from the root directory.

/run.sh 소스

export PYTHONPATH=$(pwd)
python main.py 2>/dev/null

./run.sh로 실행.

내부 디버깅 출력문을 전부, 생략한다(터미널 IO최소화)

Run with ./run.sh.

All internal debug print statements are suppressed to minimize terminal I/O.


GStreamer, Media pipeline 구조

[영상 소스]
 qtiqmmfsrc (카메라 입력)
     └── qtivtransform (영상 뒤집기)
         └── video/x-raw (영상 포맷 설정: NV12, 1920x1080)
             └── queue (버퍼)
                 └── tee name=split (1차 데이터 분기점)
                     │
                     ├─BRANCH 1: 화면 출력용 (Display)─────> waylandsink (모니터 출력)
                     │    │
                     │    └── qtimetamux (영상 + AI 데이터 결합)
                     │        └── qtioverlay (AI 결과를 영상 위에 그리기)
                     │
                     ├─BRANCH 2: AI 추론용 (Inference)──────> AI 모델 (YOLOv5) 실행
                     │    │
                     │    └── qtimltflite (퀄컴 AI 엔진으로 모델 실행)
                     │        └── qtimlvdetection (AI 결과 후처리)
                     │            └── tee name=mt (2차 데이터 분기점: AI 결과 분기)
                     │                │
                     │                ├─ (AI 결과) ──> BRANCH 1의 qtimetamux로 전달
                     │                │
                     │                └─ (AI 결과) ──> appsink name=meta_sink (애플리케이션으로 '결과' 전달)
                     │
                     └─BRANCH 3: 데이터 추출용 (Frame Capture)──> appsink name=frame_sink (애플리케이션으로 '영상' 전달)
                          │
                          └── videoconvert (영상 포맷 변환: RGB)


Object Tracking (IoU)

IoU를 계산하여, 다음프레임의 객체가 같은 객체인지 판단한다.

Speed Measurement

Method 1 (Not Used)

프레임간 중심 좌표의 이동거리 변화로 속도를 측정

Speed is calculated based on the change in the object's center coordinates across frames.

Method 2 (✅Selected)

가상의 두 선을 그어놓고, 두 선을 동과하는데 걸리는 시간을 측정한다.

하지만, 이 방법은 가상의 두 선 사이의 실제 도로 거리를 알아야 정확히 측정 할 수 있다.

Two virtual lines are drawn on the screen,

and the time taken for the object to pass between these lines is measured.

However, to calculate the speed accurately, the real-world distance between the two lines must be known.

Multi Threading

병목 현상을 최소화 하기 위해서 멀티 스레딩을 사용했다.

Multithreading is used to minimize bottlenecks and enhance performance.

  • 메인 스레드 Main Thread
  • 트래킹, 속도 측정 스레드 Tracking & Speed Measurement Thread
  • 사진촬영 및 전송 스레드 Screenshot & Upload Thread

About

Qualcomm / Thundercomm Rubik Pi object detection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.8%
  • Shell 0.2%