Count number of cars using Python step by step
#1 Installing requirements
Then open cmd and type
#1 pip install Opencv-python
#2 pip install cvlib
#3 pip install matplotlib
#4 pip install TensorFlow
#5 pip install Keras
then Enter
#2 Making folder and files
First, make one and give a name to the folder then download any car image then paste it on the same folder
![]() |
| Make a folder and paste photos of cars |
![]() |
| Create a file on the code editor |
#3 Write code and run it
Open the py file and write code or paste
import cv2
import matplotlib.pyplot as plt
import cvlib as cv
from cvlib.object_detection import draw_bbox
im = cv2.imread('car2.jpg')
bbox, label, conf = cv.detect_common_objects(im)
output_image = draw_bbox(im, bbox, label, conf)
plt.imshow(output_image)
plt.show()
print('Number of cars in the image is '+ str(label.count('car')))





0 Comments