Analyzing a File

In this sample, we:

 

create a MediaObject to contain the image

add the image to the MediaObject

analyze the image

save the MediaObject to a file

 

Note: Image files must be in one of the following formats before you run them through analysis: JPEG, GIF, or PNG. For information about how to prepare images for analysis, see the Additional Configuration section.

 

try

{

    // create a MediaObject and load the image

    MediaObject mo = (MediaObject) Eve.newMediaObject();

    mo.loadImage(path);

    // keep track of where the image came from

    mo.setProperty("originalPath",path);

    // create an instance of the Analyze class to perform the analysis

    Analyze analyze = (Analyze) Eve.newAnalyze();

    try

    {

      // do the analysis

      analyze.analyze(mo,Eve.maxRegions,Eve.maxIterations);

 

    }

    catch (Exception e)

    {

      System.out.println("Error During Analyze: " + e);

      System.exit(0);

 

    }

    // add some dummy metadata

    mo.addMetadata("testMetadata","testMetadata");

    // take out everything we can't serialize

    mo.purge();

    // serialize the MediaObject and send it out to disk

    mo.saveTo(path + ".edf");

}

catch (Exception e)

{

    // handle the exception here

}