Skip to content

Commit 97daacb

Browse files
committed
feat: Added headlight detection program
1 parent 5c09aa8 commit 97daacb

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from shutil import which
2+
import numpy as np
3+
from matplotlib import pyplot as plt
4+
import cv2, time
5+
6+
def wait(t):
7+
time.sleep()
8+
9+
#List includes path for images representing differenct scenarios
10+
mlist = ['bus_coming.hpg','going.jpg','both.jpg']
11+
12+
#codition: no vehicle
13+
def scenario(condition):
14+
image = cv2.imread(condition)
15+
gray_image = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
16+
cv2.imwrite('gray_image.png',gray_image)
17+
cv2.imshow('color_image',image)
18+
blur_image = cv2.blur(gray_image,(15,15))
19+
cv2.imwrite('blur_image.png',blur_image)
20+
ret , thresh = cv2.threshold(blur_image,150,255,0)
21+
contour_image , contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
22+
cv2.drwaContours(blur_image,contours,-1,(0,255,0),3)
23+
cv2.imshow('blur_image.png',blur_image)
24+
moments = [cv2.moments(cnt) for cnt in contours]
25+
y_centroids = [int(round(m['m01']/m['m00'])) for m in moments]
26+
x = len(y_centroids)
27+
i=0
28+
while i<x:
29+
y_centroids[i] = y_centroids[i]//10

0 commit comments

Comments
 (0)