Package de.swa.fuh.clarifai
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
- 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 filestatic void
main(java.lang.String[] args)
-
Constructor Details
-
ClarifaiPluginMain
public ClarifaiPluginMain()
-
-
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 callfilepath
- Path of the XML file to be generateddimension
- Image dimensions needed for calculating scaled bounding boxes
-
generateJSON
public static void generateJSON(long startTimeGeneral, long timeDetection, java.lang.String filepath) throws java.io.IOExceptionGenerates 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 applicationtimeDetection
- Time needed for image processing through APIfilepath
- 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.IOExceptionGets 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
-