Drowsiness driving detection system with OpenCV & KNN


: In this repository, a program was developed to identify the driver's drowsiness based on real-time camera image and image processing techniques, and this program makes warning alarms go off for each level of drowsiness when it detects drowsiness driving.

: 실시간 영상과 영상 처리 기술을 기반으로 운전자의 졸음 상태를 판별하고 졸음운전 중이라면 특정 수준에 따라 경고 알람이 울리게 하는 프로그램을 제작하였습니다. 실시간 Vision System에 운전자의 얼굴 및 안구 검출 기법, 조명 영향 제거에 따른 안구 오검출 제거 방법, 졸음 감지 기법, 지도 학습 알고리즘을 사용한 졸음 단계 판별법 등을 구현하였습니다.

Description

: Based on the real-time Vision System, drivers' face and eye detection techniques were added, as well as removing lighting effects due to the eye detection false positives, drowsiness detection techniques, and supervised learning algorithms to identify drowsiness level.

The Histogram of Oriented Gradients technology and the learned Face Landmark estimation techniques were used to detect faces and eyes.

In order to eliminate the effects of lighting, the light channels of the original images were separated and reversed, and then composed with the grayscale images of original images.

Furthermore the concept of Eye Aspect Ratio was used to detect drivers' drowsiness.

Finally, the KNN algorithm was used to divide the drivers' level of drowsiness into three stages, and differential alarms go off for each stages.

Through these works, we could research and make technology of intelligent vehicle systems and vision computing, which is gaining much attention recently.

: 얼굴 및 안구 검출을 하기 위해 Histogram of Oriented Gradients 기술과 학습된 Face landmark estimation 기법을 사용하였습니다. 조명 영향을 제거하기 위해선 원본 영상의 조명 채널을 분리해 역 조명을 쏘아 Grayscale 된 이미지와 합쳐주었고, 졸음 상태를 감지하기 위해선 Eye Aspect Ratio라는 개념을 사용하였습니다. 마지막으로 운전자의 졸음 위험 수준을 세 단계로 나눠 단계별로 차등 알람이 울리게 하였고, 단계를 나누는 과정에서 KNN 알고리즘을 사용했다.

This code is in Python 3.6

System diagram

Get face images from the camera -> Grayscaling -> Light processing -> HOG & find face -> Face Landmark Estimation -> Detect drowsiness driving.

0 : The filming.

10 : Lightness preprocessing.

100 : Detecting drowsiness.

110 : Getting face's image.

120 : Finding eyes region.

130 : Determining the value of the EAR normally.

140 : Determining drowsiness driving.

141 : Calculating the value of the EAR.

142 : Calculating the amount of time eyes are closed.

143 : Calculating the amount of time eyes are opened.

144 : Determining the level of the drowsiness.

Extracting face and eye region

Preprocessing

Drowsiness detection method

Drowsiness level selection

. 1. Create arrays with random (x, y)-coordinates.

  1. Labeling

  2. Define K value.

  3. Test KNN algorithm.

Synthesis

Test

Execution

References