0

I am new to ML, and OpenCV and was trying to perform object detection of a car using the pre-trained model on Coco Dataset, DNN. I am receiving multiple bounding boxes around the car.

The code and image are attached for reference.

cap = cv2.imread(r'D:\car.jpg')

while True:
    (classIds, scores, bboxes) = model.detect(cap)
    for classId, score, bbox in zip(classIds, scores, bboxes):
        (x, y, w, h) = bbox
        className = classes[classId]

        if className == 'car':
            cv2.putText(cap, className, (x, y-10), cv2.FONT_HERSHEY_PLAIN, 2, (200,0,50), 2)
            cv2.rectangle(cap, (x, y), (x+w, y+h), (33, 191, 130),3)

    cv2.imshow('abc', cap)
    if cv2.waitKey(33) == 27:
        break

Output image

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36

0 Answers0