Report Raspberry Pi Project With References
Report Raspberry Pi Project With References
Raspberry Pi OpenCV Car Counter is a project to count vehicles or moving objects based on video
feed from the road. Red dots will be used to count the cars, Green line will be used to as the
trajectory and will be the counter, while the Blue writings will be the counter.
We will use OpenCV and Imutils and here are the codings :
Python car-counter.py
import
cv2
backsub = cv2.BackgroundSubtractorMOG() #background subtraction to isolate moving
cars
capture = cv2.VideoCapture("/home/pi/Downloads/video.mp4")
counter = 0
x = 0
y = 0
sen = 0
minArea=1
lineCount = 50
if capture.isOpened():
ret, frame = capture.read()
else:
ret = False
while ret:
ret, frame = capture.read()
if ret==False:
break
if moments['m00'] >=minArea:
x=int(moments['m10']/moments['m00'])
y=int (moments['m01']/moments['m00'])
if x<lineCount:
sen=sen<<1
else:
sen=(sen<<1)|1
sen=sen&0x03
if sen==1:
counter=counter+1
cv2.line(frame,(lineCount,0),(lineCount,200),(0,255,0),2)
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(frame,'counter='+str(counter), (10,30),font,1, (255, 0, 0), 2)
#cv2.putText(frame,'x='+str(x)+' y='+str(y), (10,60),font,1, (255, 0, 0), 2)
cv2.imshow("counter", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
http://shahrulnizam.com/raspberry-pi-lesson-opencv-car-counter/
Raspberry Pi Traffic Analyzer
Hardwares Needed :
other references :
https://www.instructables.com/id/Image-Recognition-With-TensorFlow-on-Raspberry-Pi/
https://www.youtube.com/watch?v=npZ-8Nj1YwY
https://towardsdatascience.com/real-time-car-pedestrian-lane-detection-using-tensorflow-object-
detection-api-and-an-ios-fbb1b7cbb157
https://towardsdatascience.com/track-vehicles-and-people-using-yolov3-and-tensorflow-
4f3d0e5b1b5f
https://www.pyimagesearch.com/2019/12/02/opencv-vehicle-detection-tracking-and-speed-
estimation/
http://shahrulnizam.com/raspberry-pi-lesson-opencv-car-counter/
https://www.mathworks.com/matlabcentral/fileexchange/52456-analyzing-traffic-using-a-webcam-
a-raspberry-pi-and-thingspeak
https://www.mathworks.com/videos/programming-raspberry-pi-with-simulink-87003.html?
type=shadow