Class ClarifaiPluginMain

java.lang.Object
de.swa.fuh.clarifai.ClarifaiPluginMain

public class ClarifaiPluginMain
extends java.lang.Object
Application for object detection in image files through the standard ClarifAI API.
Images can be submitted as URL objects, as image files or as byte arrays.
Legal image formats: JPG, PNG, TIFF, BMP, WEBP
Application needs exactly one argument, containing one of the following:
  • Image url as a string
  • Image file path
  • Directory path containing image files
The application will send either the single image given as an argument to the API or every image contained in the directory in seperate API calls. Results of API calls are being saved as XML files in the image file or directory file or in current user directory if the application argument was an image url. The following parameters for the API call can be edited through clarifaiPlugin.config
  • API key: This needs to be generated through clarifai.com in order for this application to work!
  • Model ID: The model id to be used for making API calls. For more information see ClarifAI pre trained models
  • maximumConcepts: Defines the maximum amount of objects returned by the API. Default is 0 for no limitation.
  • minConfidece: Defines the minimal confidence for objects to be returned by the API. Default is 0 for no limitation.
  • Constructor Summary

    Constructors 
    Constructor Description
    ClarifaiPluginMain()  
  • Method Summary

    Modifier and Type Method Description
    static void generateJSON​(long startTimeGeneral, long timeDetection, java.lang.String filepath)
    Generates a JSON file in image directory which contains the times needed for the whole application as well as for the image procession via the API.
    static void generateXML​(java.util.List<com.clarifai.grpc.api.Region> results, java.lang.String filepath, java.awt.Dimension dimension)
    Generates an XML file containing the results of the API call.
    static java.awt.Dimension getImageDimension​(java.io.File imgFile)
    Gets image dimensions for given file
    static void main​(java.lang.String[] args)  

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • main

      public static void main​(java.lang.String[] args) throws java.io.IOException, java.net.URISyntaxException
      Throws:
      java.io.IOException
      java.net.URISyntaxException
    • generateXML

      public static void generateXML​(java.util.List<com.clarifai.grpc.api.Region> results, java.lang.String filepath, java.awt.Dimension dimension)
      Generates an XML file containing the results of the API call.
      Parameters:
      results - Bounding boxes gotten from the API call
      filepath - Path of the XML file to be generated
      dimension - Image dimensions needed for calculating scaled bounding boxes
    • generateJSON

      public static void generateJSON​(long startTimeGeneral, long timeDetection, java.lang.String filepath) throws java.io.IOException
      Generates a JSON file in image directory which contains the times needed for the whole application as well as for the image procession via the API.
      Parameters:
      startTimeGeneral - Start time generated at the start of the application
      timeDetection - Time needed for image processing through API
      filepath - Path of the current image or directory being processed
      Throws:
      java.io.IOException - if file cannot be created
    • getImageDimension

      public static java.awt.Dimension getImageDimension​(java.io.File imgFile) throws java.io.IOException
      Gets image dimensions for given file
      Parameters:
      imgFile - image file
      Returns:
      dimensions of image
      Throws:
      java.io.IOException - if the file is not a known image