Distribution
The following items are included:
imago.jarcontainingcom.gga.imago.Imagowrapper classlibdirectory containing binaries for all supported platforms:lib/Linux/x86/libimagojni.so— 32-bit Linux binarylib/Linux/x64/libimagojni.so— 64-bit Linux binarylib/Win/x86/imagojni.dll— 32-bit Windows binarylib/Win/x64/imagojni.dll— 64-bit Windows binarylib/Mac/10.5/libimagojni.dylib— Mac OS 10.5 binarylib/Mac/10.6/libimagojni.dylib— Mac OS 10.6 binary
Depending on the OS and architecture, proper binaries are loaded automatically.
Workflow
The Imago class object represents a library instance. All operations are represented by methods of this object.
Several library instances may be created within one thread to act simultaneously and independently. However,
each instance requires a certain amount of memory, and thus it is recommended to have as few instances as
possible.
The procedure for rendering workflow is the following:
- Create a library instance.
- Load a PNG image from the file or in-memory buffer.
- Set the optional parameters.
- Set the log callback, if needed.
- Call
recognize(). - Get the resulting molfile via
getResult().
Any method of the Imago class can throw an Exception if something went wrong. The recognize() method
can throw an Imago.NoResultException in the event that the image has failed to be recognized as a molecule.
Imago Class Public Methods
Constructor
Imago (String path);
Receives the path to Win and Linux directories containing binary modules (see distribution section above for details). E.g., if the libraries are stored in lib/Win/ and
lib/Linux directories, call new Imago(“lib”). You can specify absolute paths as well.
Imago ();
Same as Imago(“lib”).
Instances are independent and are safe to be used in parallel.
Loading the Image
void loadPNG (byte[] buf);
Loads a PNG image from the memory buffer.
void loadPNG (String filename);
Loads a PNG image from file.
Setting the Options
void setFilter (String filter);
void setBinarizationLevel (int level);
void setConfig (int n);
Sets one of the pre-loaded configuration parameter sets. n is the index of the set, which must be nonnegative
and less than the number of parameter sets, which you can know from Imago.configsCount public variable. The
index of the parameter set is saved to currentConfigId public member.
Setting the Log Callback
void setLogCallback (ImagoLogCallback callback);
ImagoLogCallback is an interface that is defined within the Imago class and that has only one method:
public interface ImagoLogCallback {
public void log (String str);
}
Performing the Recognition
void recognize ();
Getting the Result
string getResult ();
Returns a string with the recognized molecule in Molfile format.
Example
com.gga.imago.Imago imago = new com.gga.imago.Imago();
imago.setLogCallback(new Imago.ImagoLogCallback() {
public void log(String str) {
System.out.print(str);
}
});
imago.setFilter("blur");
imago.setBinarizationLevel(150);
imago.loadPNG("my-image.png");
imago.recognize();
System.out.println(imago.getResult());