Project - Mask R-CNN with OpenCV for Object Detection

6 / 8

Getting the Masks and Bounding Boxes

Let us perform the forward pass of the image through net.

Remember, we have already set the input for the network net using net.setInput in the previous slide.

Now, we shall use net.forward to get the masks and the co-ordinates of the bounding boxes.

Note:

  • Remember,

    • Detection refers to identifying a bounding box
    • instance segmentation means identifying the pixels that can belong to the object.
  • net.forward : Perform a forward pass of the Mask R-CNN. It returns

    (1) the bounding box coordinates of the objects in the image along with classID, confidence scores from the output layer named 'detection_out_final' (2) the pixel-wise segmentation for each specific object from the output layer named ‘detection_masks‘.

INSTRUCTIONS
  • Use net.forward to get the masks and bounding boxes of the detected objects in the input image.

    (boxes, masks_polygons) = << your code comes here >>(["detection_out_final",
    "detection_masks"])
    

    The boxes have classID, confidence scores and 4 points identifying the bounding box. This bounding box is normalized and has to be multiplied by the actual size of the image to get actual values.

  • Let us print the shape of boxes.

    boxes.shape
    

    The boxes have classID, confidence scores and 4 points identifying the bounding box. This bounding box is normalized and has to be multiplied by the actual size of the image to get actual values.

  • Let us also print the shape of masks_polygons using shape.

    masks_polygons.<< your code comes here>>
    

    The masks_polygons have

    • masks corresponding to the 100 detections
    • each detection has 90 classes. (We would be considering the classID whose confidence is greater than threshold).
    • a matrix denoted as a 15 x 15 mask polygon of the detected object
Get Hint See Answer


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...