How do I store the object detection classes to a list

Ask Questions Forum: ask Machine Learning Questions to our readersCategory: Deep LearningHow do I store the object detection classes to a list
Siddarth dayasagar asked 1 month ago

I have detected my object :

indexes = cv2.dnn.NMSBoxes(boxes, confidences, 0.7, 0.4)
font = cv2.FONT_HERSHEY_PLAIN
colors = np.random.uniform(0, 255, size=(len(boxes)))
results = []
# drawing
if(len(indexes))>0:
    for i in indexes.flatten():
        (x, y) = (boxes[i][0], boxes[i][1])
        (w, h) = (boxes[i][2], boxes[i][3])
        label = str(classes[class_ids[i]])
        confidence = str(round(confidences[i], 2))
        color = colors[i]
        cv2.rectangle(img, (x, y), (x + w, y + h), color, 2)
        cv2.putText(img, label + "  " + confidence, (x, y -5), font, 1, (0, 0, 0), 2)
        results.insert(i,label)

the label detected is getting stored in result but its storing one object

1 Answers
Chris Staff answered 1 month ago

Try the following instead of results.insert:

results.append(label)

Your Answer

4 + 3 =