An AI based system that do detects the cars and the pedestrians from a captured video.
Apart from installing Python, you'll also need to pip and install the OpenCV, and this is pretty much it. Optionally you'll need to install the numpy because some of the OpenCV methods return numpy arrays so that's why.
The trainging datasets are downloaded from the internet you can find the car's dataset also known as car_detector data set, and the pedestrian's dataset known as haarcascade_fullbody.
- First and foremost import the opencv liberary that's gonna do a lot of work for us in this detection system.
- Save the captured video file in variable
video
- Save the car and pedestrian pre-trained classifiers and save it in
car_tracker_file
andpedestrian_tracker_file
respectively - Create the classifiers for the both, by the use of opencv cascade classifiers
- Now utill the video, (our simulated car) didn't stops, the process will continue
- And the process is, to read the video frames
- If it reads successfully convert that frame to the gray-scale or say black and white, because it can be process faster than in the colored form
- Now detect the cars and pedestrian from the frames, which it gives us the an array of 4D arrays, of each and every single car and pedestrian.
- Now for every car and pedestrian draw a rectangle over it
- Show the frames by
cv2.imshow()
method - And at the last release the VideoCapture object we've created