Skip to content

Commit 704aff7

Browse files
authored
Merge branch 'crazycodigo:main' into amajaying-changed
2 parents f45f8b8 + 35b8476 commit 704aff7

File tree

15 files changed

+26756
-41
lines changed

15 files changed

+26756
-41
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#importing open computer vision!
2+
import cv2
3+
4+
#Test video
5+
img_file = './assets/car1.avi'
6+
7+
#trained detection algorithm
8+
bus_classifier = cv2.CascadeClassifier('bus.xml')
9+
car_classifier = cv2.CascadeClassifier('cars.xml')
10+
pedestrian_classifier = cv2.CascadeClassifier('pedestrian.xml')
11+
bike_classifier = cv2.CascadeClassifier('bike.xml')
12+
13+
#giving the image to openCV
14+
vid = cv2.VideoCapture(img_file)
15+
16+
#run until the car turns off or crashes and burns to ashes
17+
while True:
18+
#gives a touple
19+
(frame_read,frame) = vid.read()
20+
21+
if frame_read:
22+
#convert the image to garyscale
23+
gimg = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
24+
25+
#Detect the everything with their respective algorithms
26+
pedestrians = pedestrian_classifier.detectMultiScale(gimg)
27+
cars = car_classifier.detectMultiScale(gimg)
28+
bike = bike_classifier.detectMultiScale(gimg)
29+
bus = bus_classifier.detectMultiScale(gimg)
30+
31+
32+
#Display the detection
33+
for(x,y,w,h) in cars:
34+
cv2.rectangle(frame,(x,y),(x+w,y+h),(0,255,0),4)
35+
#Display the detection
36+
for(x,y,w,h) in bus:
37+
cv2.rectangle(frame,(x,y),(x+w,y+h),(0,0,225),4)
38+
for(x,y,w,h) in bike:
39+
cv2.rectangle(frame,(x,y),(x+w,y+h),(255,0,0),4)
40+
#Display the detection
41+
for(x,y,w,h) in pedestrians:
42+
cv2.rectangle(frame,(x,y),(x+w,y+h),(69,125,23),4)
43+
44+
#display image
45+
cv2.imshow("Sasta Tesla Sofware XD",frame)
46+
cv2.waitKey(1)
47+
else:
48+
print("Error in reading the frames")
49+
break
50+
print("Code Completed 👑")
2.15 MB
Binary file not shown.
2.41 MB
Binary file not shown.
Loading

0 commit comments

Comments
 (0)