matterport / Mask_RCNN

Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
24.75k stars 11.71k forks source link

counting obejects #856

Open uday1994 opened 6 years ago

uday1994 commented 6 years ago

how to count objects that detected and print it on image or video

VinniaKemala commented 6 years ago

You can add some simple lines like this:

 # Run object detection
 results = model.detect([image], verbose=0)
 r = results[0]

print("Objects found: {}".format(len(r['class_ids'])) )``
andreasalamanos commented 5 years ago

You can add some simple lines like this:

 # Run object detection
 results = model.detect([image], verbose=0)
 r = results[0]

print("Objects found: {}".format(len(r['class_ids'])) )``

I think it only returns the number of classes. I always get 1, no matter how many detections I have. Instead I used print("Objects found: {}".format(len(r["rois"])) )