October 2018
Intermediate to advanced
472 pages
10h 57m
English
Now let us load the annotation corresponding to the previous picture and plot the annotation on top of the picture. The coco.getAnnIds() function helps load the annotation info of an image using its ID. Then, with the help of the coco.loadAnns() function, we load the annotations and plot it using the coco.showAnns() function. It is important that you first plot the image and then perform the annotation operations as shown in the following code snippet:
# display the imageplt.imshow(I)# extract the annotation id annIds = coco.getAnnIds(imgIds=img['id'], catIds=catIds, iscrowd=None)# load the annotationanns = coco.loadAnns(annIds)# plot the annotation on top of the imagecoco.showAnns(anns)
Following should be the output:
Read now
Unlock full access