Spaces:
Sleeping
A newer version of the Gradio SDK is available:
6.5.1
title: OpenCVLaneDetectionDemo
emoji: ๐
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false
license: gpl-3.0
OpenCVLaneDetectionDemo
OpenCV Lane Detection Demo with Gradio
๊ฐ์ (Overview)
์ด ํ๋ก์ ํธ๋ OpenCV๋ฅผ ์ฌ์ฉํ์ฌ ๋น๋์ค์์ ์ฐจ์ ์ ๊ฐ์งํ๊ณ , Gradio UI๋ฅผ ํตํด ๊ฒฐ๊ณผ๋ฅผ ์๊ฐํํ๋ ๋ฐ๋ชจ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋๋ค.
This project is a demo application that detects lane lines in videos using OpenCV and visualizes the results through a Gradio UI.
๊ธฐ๋ฅ (Features)
- ๐ฅ Gradio๋ฅผ ํตํ ๋น๋์ค ์ ๋ก๋ (Video upload via Gradio)
- ๐ฃ๏ธ 6๊ฐ์ง ์ฐจ์ ๊ฒ์ถ ๋ฐฉ๋ฒ ์ ๊ณต (6 lane detection methods available)
- ๐ ์๋ณธ/์ฒ๋ฆฌ ๋น๋์ค ์ฌ์ด๋๋ฐ์ด์ฌ์ด๋ ๋น๊ต (Side-by-side comparison of original and processed videos)
- ๐ ์ค์๊ฐ ์งํ ์ํฉ ํ์ (Real-time progress tracking with progress bar)
- ๐ป CLI ๋๊ตฌ ์ ๊ณต (Command-line interface available)
- ๐งช ํฌ๊ด์ ์ธ ํ ์คํธ ์ค์ํธ (Comprehensive test suite)
- โก GPU ๊ฐ์ ์ง์ (GPU acceleration support when available)
์ค์น (Installation)
- ์ ์ฅ์ ํด๋ก (Clone the repository):
git clone https://github.com/kr4phy/OpenCVLaneDetectionDemo.git
cd OpenCVLaneDetectionDemo
- ํ์ํ ํจํค์ง ์ค์น (Install required packages):
pip install -r requirements.txt
์ฌ์ฉ๋ฒ (Usage)
๋ฐฉ๋ฒ 1: Gradio UI ์ฌ์ฉ (Using Gradio UI)
- ์ ํ๋ฆฌ์ผ์ด์ ์คํ (Run the application):
python app.py
๋ธ๋ผ์ฐ์ ์์ ์๋์ผ๋ก ์ด๋ฆฌ๋ Gradio UI์ ์ ์ํฉ๋๋ค. (The Gradio UI will automatically open in your browser)
๋น๋์ค ํ์ผ์ ์ ๋ก๋ํ๊ณ "Process Video" ๋ฒํผ์ ํด๋ฆญํฉ๋๋ค. (Upload a video file and click the "Process Video" button)
์ฒ๋ฆฌ๋ ๊ฒฐ๊ณผ๋ฅผ ํ์ธํฉ๋๋ค (์ผ์ชฝ: ์๋ณธ, ์ค๋ฅธ์ชฝ: ์ฐจ์ ๊ฐ์ง ๊ฒฐ๊ณผ). (View the processed result - left: original, right: lane detection result)
๋ฐฉ๋ฒ 2: CLI ์ฌ์ฉ (Using Command Line)
python cli.py input_video.mp4 output_video.mp4 [method]
์์ (Example):
# ํ
์คํธ ๋น๋์ค ์์ฑ (Create test video)
python create_test_video.py
# ๋ค์ํ ๋ฐฉ๋ฒ์ผ๋ก ์ฐจ์ ๊ฐ์ง ์ฒ๋ฆฌ (Process with different methods)
python cli.py /tmp/test_road_video.mp4 result_advanced.mp4 advanced
python cli.py /tmp/test_road_video.mp4 result_yolop.mp4 yolop
python cli.py /tmp/test_road_video.mp4 result_ufld.mp4 ufld
python cli.py /tmp/test_road_video.mp4 result_scnn.mp4 scnn
python cli.py /tmp/test_road_video.mp4 result_basic.mp4 basic_standard
python cli.py /tmp/test_road_video.mp4 result_segmented.mp4 basic_segmented
์ฐจ์ ๊ฐ์ง ์๊ณ ๋ฆฌ์ฆ (Lane Detection Algorithm)
๋ณธ ํ๋ก์ ํธ๋ ๋ค์๊ณผ ๊ฐ์ 6๊ฐ์ง ์ฐจ์ ๊ฐ์ง ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค: (This project provides 6 lane detection methods:)
1. Basic Standard (Hough Transform)
- Grayscale ๋ณํ ๋ฐ ๊ฐ์ฐ์์ ๋ธ๋ฌ
- Canny ์์ง ๊ฒ์ถ
- Hough ๋ณํ์ ํตํ ์ง์ ๊ฒ์ถ
- ๋จ์ผ ํ๊ท ํ๋ ์ฐจ์ ํ์
- ์ฅ์ : ๊ฐ์ฅ ๋น ๋ฅธ ์ฒ๋ฆฌ ์๋
- ๋จ์ : ๊ณก์ ๋๋ก์์ ์ ํ๋ ๋ฎ์
2. Basic Segmented (Hough Transform)
- Basic Standard์ ๋์ผํ ๊ธฐ๋ณธ ์ฒ๋ฆฌ
- ์ฌ๋ฌ ์ ๋ถ์ผ๋ก ์ฐจ์ ํํ
- ์ฅ์ : ๊ณก์ ํํ ๊ฐ์ , ๋น ๋ฅธ ์ฒ๋ฆฌ
- ๋จ์ : ๋ณต์กํ ์ฐจ์ ์์๋ ํ๊ณ
3. Advanced (Perspective Transform + Polynomial)
- ์๊ทผ ๋ณํ์ผ๋ก bird's eye view ์์ฑ
- CLAHE๋ฅผ ์ด์ฉํ ํฅ์๋ ๋๋น ๊ฐ์
- ์ฌ๋ผ์ด๋ฉ ์๋์ฐ๋ฅผ ํตํ ๋คํญ์ ํผํ
- ๊ทธ๋๋์ธํธ ๋ฐฉํฅ ํํฐ๋ง
- ์ฅ์ : ๋์ ์ ํ๋, ๊ณก์ ๋ฐ ์ ์ ์ฐจ์ ์ฐ์
- ๋จ์ : ์ฒ๋ฆฌ ์๋๊ฐ ๋๋ฆผ
4. YOLOP (Multi-task Learning)
- YOLOP (You Only Look Once for Panoptic Driving) ์๊ฐ
- ๋ค์ค ์์ ์ฐจ์ ๊ฒ์ถ (ํฐ์, ๋ ธ๋์)
- ์ปจํฌ์ด ๊ธฐ๋ฐ ์ธ๊ทธ๋ฉํ ์ด์
- ์ฅ์ : ๋ค์ํ ์ฐจ์ ์์ ์ธ์, ๋น ๋ฅธ ์ฒ๋ฆฌ
- ๋จ์ : ๋ณต์กํ ๋๋ก ํ๊ฒฝ์์ ์ ํ๋ ์ ํ
5. UFLD (Ultra Fast Lane Detection)
- Ultra Fast Structure-aware Deep Lane Detection ์๊ฐ
- ํ๋ณ ๋ถ๋ฅ ์ ๊ทผ ๋ฐฉ์
- ์ ์ํ ์๊ณ๊ฐ ์ฒ๋ฆฌ
- ์ฅ์ : ์๋์ ์ ํ๋์ ๊ท ํ, ์ค์๊ฐ ๊ฐ๋ฅ
- ๋จ์ : ๋งค์ฐ ๋ณต์กํ ํ๊ฒฝ์์๋ SCNN๋ณด๋ค ๋ฎ์ ์ ํ๋
6. SCNN (Spatial CNN)
- Spatial CNN for traffic lane detection ์๊ฐ
- 4๋ฐฉํฅ ๊ณต๊ฐ ๋ฉ์์ง ์ ๋ฌ
- ๋ค์ค ์ค์ผ์ผ ์์ง ๊ฒ์ถ
- ์ฅ์ : ๋ณต์กํ ์๋๋ฆฌ์ค์์ ์ต๊ณ ์ ํ๋
- ๋จ์ : ์ฒ๋ฆฌ ์๊ฐ์ด ๋ค์ ์์๋จ
์๊ณ ๋ฆฌ์ฆ ์ ํ ๊ฐ์ด๋ (Selection Guide)
- ์ต๊ณ ์๋: Basic Standard, YOLOP
- ๊ณก์ ๋๋ก: UFLD, Advanced, Basic Segmented
- ์ต๊ณ ์ ํ๋: SCNN, Advanced (Enhanced)
- ๋ค์ํ ์ฐจ์ ์์: YOLOP
- ๊ท ํ์กํ ์ฑ๋ฅ: UFLD
ํ๋ก์ ํธ ๊ตฌ์กฐ (Project Structure)
OpenCVLaneDetectionDemo/
โโโ app.py # Gradio UI ์ ํ๋ฆฌ์ผ์ด์
โโโ lane_detection.py # ํต์ฌ ์ฐจ์ ๊ฒ์ถ ๋ก์ง
โโโ cli.py # ๋ช
๋ น์ค ์ธํฐํ์ด์ค
โโโ create_test_video.py # ํ
์คํธ ๋น๋์ค ์์ฑ ๋๊ตฌ
โโโ create_sample_images.py # ์ํ ์ด๋ฏธ์ง ์์ฑ ๋๊ตฌ
โโโ test_lane_detection.py # ํ
์คํธ ์ค์ํธ
โโโ requirements.txt # Python ์์กด์ฑ
โโโ README.md # ๋ฌธ์
ํ ์คํธ (Testing)
์ ์ฒด ํ ์คํธ ์ค์ํธ ์คํ: (Run the complete test suite:)
python test_lane_detection.py
์๊ตฌ์ฌํญ (Requirements)
- Python 3.7+
- gradio>=4.0.0
- opencv-python>=4.5.0
- numpy>=1.20.0
๊ธฐ์ ์คํ (Tech Stack)
- OpenCV: ์ปดํจํฐ ๋น์ ์ฒ๋ฆฌ
- NumPy: ์์น ์ฐ์ฐ
- Gradio: ์น UI ํ๋ ์์ํฌ
๋ผ์ด์ ์ค (License)
MIT License
๊ธฐ์ฌ (Contributing)
์ด์์ ํ ๋ฆฌํ์คํธ๋ฅผ ํ์ํฉ๋๋ค! (Issues and pull requests are welcome!)
๋ฌธ์ (Contact)
ํ๋ก์ ํธ์ ๋ํ ์ง๋ฌธ์ด๋ ์ ์์ฌํญ์ด ์์ผ์๋ฉด ์ด์๋ฅผ ์์ฑํด์ฃผ์ธ์. (For questions or suggestions about the project, please create an issue.)