YOLO-v5 기반 단안 카메라의 영상을 활용해 차간 거리를 일정하게 유지하며 주행하는 Adaptive Cruise Control 기능 구현

Overview

자율 주행차의 영상 기반 차간거리 유지 개발

Table of Contents


프로젝트 소개


YOLO-v5 기반으로 단안 카메라의 영상을 활용해 차간 거리를 일정하게 유지하며 주행하는 Adaptive Cruise Control 기능을 제공한다.


주요 기능

객체 인식

  • 복도에서의 차량 카트 이미지를 촬영하여 커스텀 데이터셋을 제작
  • YOLO-v5 모델 중 가장 초당 프레임 수 가 높은 YOLO-v5s에 커스텀 데이터셋을 학습
  • 라즈베리파이에 부착된 웹캠을 통해 실시간으로 전방 차량 인식

거리 측정

  • 객체 인식 시 나타나는 Bounding box의 좌표값을 추출하여 대상과의 거리가 1m 일 때 Bounding box의 높이와 너비값을 측정
  • 이후 인식된 객체의 Bounding box 높이와 너비값과 1m 일 때의 Bounding box 높이와 너비값의 비례식을 통해 거리를 측정

거리 유지

  • 측정된 거리 기반으로 동작을 나누어 시리얼 통신을 통해 동작 신호를 cart 조작하는 STM보드에 전달
  • STM보드에서 전달받은 신호를 기반으로 PWM 제어를 통해 차간 거리가 유지되도록 속도 조절

시스템 구조

객체 인식 및 거리측정 시스템 구조

거리유지 시스템 구조

거리측정 알고리즘

  • 카메라의 해상도에 따라 1m에서 기준이 되는 Bounding box의 width와 height의 크기가 달라진다

디렉토리 구조

adaptive-cruise-control
├── cart
│   ├── main_arm.c
│   ├── main_cart.c
│   └── README.md
│
├── dataset
│   └── ...
│
├── yolov5
│   ├── detect_custom.py
│   ├── cart_model.pt
│   └── ...
│
└── README.md

결과

실시간 객체 인식 및 거리측정

  • 학습된 가중치 모델을 바탕으로 단안 카메라를 이용하여 전방 차량 키트를 인식하였다.

  • 인식된 차량 키트에 대한 Bounding box에서 왼쪽부터 클래스명, 예측 정확도, 단안 카메라 기준 예측 거리(cm) 를 나타낸다.

  • 인식 결과, 이미지 크기 128*128 기준 평균적으로 초당 약 3 프레임의 속도로 동작하였으며, 최대 5m까지 높은 정확도로 인식됨을 확인할 수 있었다.

  • 거리 예측 오차율 측정 결과

실제 거리 측정 최소 거리 측정 최대 거리 최대 오차율
0.5m 0.47m 0.53m 6%
1m 0.96m 1.02m 3%
2m 1.98m 2.02m 1%
3m 2.85m 2.94m 5%
5m 4.65m 5.05m 7%

거리유지

동작 설정

  1. 전방 차량과의 거리가 70cm보다 가까워진 경우 차량 정지
  2. 전방 차량과의 거리가 70cm ~ 120cm인 경우 큰 폭으로 속도 감소
  3. 전방 차량과의 거리가 120cm ~ 150cm 인 경우 작은 폭으로 속도 감소
  4. 전방 차량이 없거나 거리가 150cm 보다 먼 경우 원래 주행 속도로 복구

거리유지 기능 실험 결과

  • 기준 주행 속도는 차량 키트가 스스로 움직일 수 있는 최저 속도로 설정하였다.
  • 테스트 결과, 거리가 1m에 가까워 지면 상당히 속도가 줄어들었고 0.7m에 이르면 차량 키트가 완전히 정지하였으며, 전방에 가까운 차량이 없으면 원래의 주행 속도로 돌아오는 기능 또한 정상적으로 동작함을 확인할 수 있었다.

실행 방법

YOLO v5를 활용한 실시간 객체 인식 및 거리 예측

  1. https://github.com/sungjuGit/Pytorch-and-Vision-for-Raspberry-Pi-4B 에서 Pytorch, Pytorch Vision 설치에 필요한 wheel 파일을 라즈베리파이에 다운로드한다.

  2. sudo pip3 install torch-1.8.0a0+56b43f4-cp37-cp37m-linux_armv7l.whl
    sudo pip3 install torchvision-0.9.0a0+8fb5838-cp37-cp37m-linux_armv7l.whl

  3. adative-cruise-control/yolov5를 라즈베리파이에 클론한다.

  4. pip3 install -r requirements.txt으로 필요한 종속 라이브러리를 설치한다.

  5. python3 detect_custom.py --weights cart_model.pt --img 128 --conf 0.4 --source 0 으로 실시간 객체 인식 및 거리 예측을 한다.

detect_custom.py : 객체인식 및 거리 예측을 위한 파이썬 파일
cart_model.pt : 커스텀 이미지로 학습된 yolo-v5s 가중치 모델


거리 예측을 바탕으로 카트 구동

  1. https://github.com/icns-distributed-cloud/Self-driving-project 을 노트북에 클론한다.

  2. Self-driving-project/2021_self_driving_cart/robot_arm_basic/Src/main.cadaptive-cruise-control/cart/main_arm.c으로 대치시킨다.

  3. Self-driving-project/2021_self_driving_cart/cart/Src/main.cadaptive-cruise-control/cart/main_cart.c으로 대치시킨다.

  4. ICNS Lab에서 제작한 카트에 있는 STM-Arm Board, STM-Cart Board에 각 코드를 디버깅한다.


Custom Dataset을 통한 YOLO-v5 Model 학습 방법

  • 데이터셋 수정을 통해 발전된 학습모델 제작을 원할 시 링크 참조

참조


팀원


👆 Back To The Top

PyTorch reimplementation of hand-biomechanical-constraints (ECCV2020)

Hand Biomechanical Constraints Pytorch Unofficial PyTorch reimplementation of Hand-Biomechanical-Constraints (ECCV2020). This project reimplement foll

Hao Meng 59 Dec 20, 2022
Pytorch Implementation of Value Retrieval with Arbitrary Queries for Form-like Documents.

Value Retrieval with Arbitrary Queries for Form-like Documents Introduction Pytorch Implementation of Value Retrieval with Arbitrary Queries for Form-

Salesforce 13 Sep 15, 2022
The implemetation of Dynamic Nerual Garments proposed in Siggraph Asia 2021

DynamicNeuralGarments Introduction This repository contains the implemetation of Dynamic Nerual Garments proposed in Siggraph Asia 2021. ./GarmentMoti

42 Dec 27, 2022
Estimating Example Difficulty using Variance of Gradients

Estimating Example Difficulty using Variance of Gradients This repository contains source code necessary to reproduce some of the main results in the

Chirag Agarwal 48 Dec 26, 2022
Code for Towards Streaming Perception (ECCV 2020) :car:

sAP — Code for Towards Streaming Perception ECCV Best Paper Honorable Mention Award Feb 2021: Announcing the Streaming Perception Challenge (CVPR 2021

Martin Li 85 Dec 22, 2022
DockStream: A Docking Wrapper to Enhance De Novo Molecular Design

DockStream Description DockStream is a docking wrapper providing access to a collection of ligand embedders and docking backends. Docking execution an

AstraZeneca - Molecular AI 72 Jan 02, 2023
Re-implementation of 'Grokking: Generalization beyond overfitting on small algorithmic datasets'

Re-implementation of the paper 'Grokking: Generalization beyond overfitting on small algorithmic datasets' Paper Original paper can be found here Data

Tom Lieberum 38 Aug 09, 2022
Simple Python project using Opencv and datetime package to recognise faces and log attendance data in a csv file.

Attendance-System-based-on-Facial-recognition-Attendance-data-stored-in-csv-file- Simple Python project using Opencv and datetime package to recognise

3 Aug 09, 2022
Liquid Warping GAN with Attention: A Unified Framework for Human Image Synthesis

Liquid Warping GAN with Attention: A Unified Framework for Human Image Synthesis, including human motion imitation, appearance transfer, and novel view synthesis. Currently the paper is under review

2.3k Jan 05, 2023
Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy" (ICLR 2022 Spotlight)

About Code release for Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy (ICLR 2022 Spotlight)

THUML @ Tsinghua University 221 Dec 31, 2022
Pytorch Implementation of "Diagonal Attention and Style-based GAN for Content-Style disentanglement in image generation and translation" (ICCV 2021)

DiagonalGAN Official Pytorch Implementation of "Diagonal Attention and Style-based GAN for Content-Style Disentanglement in Image Generation and Trans

32 Dec 06, 2022
Offical implementation for "Trash or Treasure? An Interactive Dual-Stream Strategy for Single Image Reflection Separation".

Trash or Treasure? An Interactive Dual-Stream Strategy for Single Image Reflection Separation (NeurIPS 2021) by Qiming Hu, Xiaojie Guo. Dependencies P

Qiming Hu 31 Dec 20, 2022
A pre-trained language model for social media text in Spanish

RoBERTuito A pre-trained language model for social media text in Spanish READ THE FULL PAPER Github Repository RoBERTuito is a pre-trained language mo

25 Dec 29, 2022
Official PyTorch implementation of Data-free Knowledge Distillation for Object Detection, WACV 2021.

Introduction This repository is the official PyTorch implementation of Data-free Knowledge Distillation for Object Detection, WACV 2021. Data-free Kno

NVIDIA Research Projects 50 Jan 05, 2023
Hcaptcha-challenger - Gracefully face hCaptcha challenge with Yolov5(ONNX) embedded solution

hCaptcha Challenger 🚀 Gracefully face hCaptcha challenge with Yolov5(ONNX) embe

593 Jan 03, 2023
The official code for paper "R2D2: Recursive Transformer based on Differentiable Tree for Interpretable Hierarchical Language Modeling".

R2D2 This is the official code for paper titled "R2D2: Recursive Transformer based on Differentiable Tree for Interpretable Hierarchical Language Mode

Alipay 49 Dec 17, 2022
Unofficial implementation of Perceiver IO: A General Architecture for Structured Inputs & Outputs

Perceiver IO Unofficial implementation of Perceiver IO: A General Architecture for Structured Inputs & Outputs Usage import torch from src.perceiver.

Timur Ganiev 111 Nov 15, 2022
PyTorch implementation for paper StARformer: Transformer with State-Action-Reward Representations.

StARformer This repository contains the PyTorch implementation for our paper titled StARformer: Transformer with State-Action-Reward Representations.

Jinghuan Shang 14 Dec 09, 2022
Fake-user-agent-traffic-geneator - Python CLI Tool to generate fake traffic against URLs with configurable user-agents

Fake traffic generator for Gartner Demo Generate fake traffic to URLs with custo

New Relic Experimental 3 Oct 31, 2022