Class CocoUtils


  • public class CocoUtils
    extends java.lang.Object
    A utility class that assists in loading and parsing the annotations in Coco.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      CocoMetadata.Annotation getAnnotationById​(long annotationId)
      Returns an CocoMetadata.Annotation that corresponds to a given annotation id.
      java.util.List<java.lang.Long> getAnnotationIdByImageId​(long imageId)
      Returns all ids of the annotation that correspond to a given image id.
      java.util.List<java.lang.Long> getImageIds()
      Returns all image ids in the annotation file.
      java.nio.file.Path getRelativeImagePath​(long imageId)
      Returns the relative path of an image given an image id.
      int mapCategoryId​(long originalCategoryId)
      Returns the continuous category id given an original category id.
      void prepare()
      Prepares and indexes the annotation file in memory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • prepare

        public void prepare()
                     throws java.io.IOException
        Prepares and indexes the annotation file in memory.
        Throws:
        java.io.IOException - if reading the annotation file fails
      • getImageIds

        public java.util.List<java.lang.Long> getImageIds()
        Returns all image ids in the annotation file.
        Returns:
        all image ids in the annotation file
      • getRelativeImagePath

        public java.nio.file.Path getRelativeImagePath​(long imageId)
        Returns the relative path of an image given an image id.
        Parameters:
        imageId - the image id to retrieve the path for
        Returns:
        the relative path of an image
      • getAnnotationIdByImageId

        public java.util.List<java.lang.Long> getAnnotationIdByImageId​(long imageId)
        Returns all ids of the annotation that correspond to a given image id.
        Parameters:
        imageId - the image id to retrieve annotations for
        Returns:
        all ids of the annotation
      • mapCategoryId

        public int mapCategoryId​(long originalCategoryId)
        Returns the continuous category id given an original category id.
        Parameters:
        originalCategoryId - the original category id to retrieve the continuous category id for
        Returns:
        the continuous category id