Perform the following steps to implement object detection with the Mask R-CNN pretrained model using opencv-python functions:
- Initialize the parameters (for example, thresholds for Confidence and Mask), using the following code snippet:
conf_threshold = 0.5 # Confidence thresholdmask_threshold = 0.3 # Mask threshold
- Define the following function to plot the predicted bounding box for the detected object, colorize it as per the object's class predicted, and overlay the mask computed on top of the input image:
def draw_box(img, class_id, conf, left, top, right, bottom, class_mask): cv2.rectangle(img, (left, top), (right, bottom), \ (255, 178, 50), 3) label = '%.2f' % conf if classes: assert(class_id < len(classes)) label ...