net.semanticmetadata.lire
Class DocumentBuilderFactory

java.lang.Object
  extended by net.semanticmetadata.lire.DocumentBuilderFactory

public class DocumentBuilderFactory
extends java.lang.Object

Creating an Index

Use DocumentBuilderFactory to create a DocumentBuilder, which will create Lucene Documents from images. Add this documents to an index like this:

 System.out.println(">> Indexing " + images.size() + " files.");
 DocumentBuilder builder = DocumentBuilderFactory.getExtensiveDocumentBuilder();
 IndexWriter iw = new IndexWriter(indexPath, new SimpleAnalyzer(), true);
 int count = 0;
 long time = System.currentTimeMillis();
 for (String identifier : images) {
 Document doc = builder.createDocument(new FileInputStream(identifier), identifier);
 iw.addDocument(doc);
 count ++;
 if (count % 25 == 0) System.out.println(count + " files indexed.");
 }
 long timeTaken = (System.currentTimeMillis() - time);
 float sec = ((float) timeTaken) / 1000f;
 

System.out.println(sec + " seconds taken, " + (timeTaken / count) + " ms per image."); iw.optimize(); iw.close();

This file is part of the Caliph and Emir project: http://www.SemanticMetadata.net
Date: 31.01.2006
Time: 23:00:32

Author:
Mathias Lux, mathias@juggle.at

Constructor Summary
DocumentBuilderFactory()
           
 
Method Summary
static DocumentBuilder getColorOnlyDocumentBuilder()
          Creates a simple version of a DocumentBuilder.
static DocumentBuilder getDefaultAutoColorCorrelationDocumentBuilder()
          Creates a DocumentBuilder for the AutoColorCorrelation feature.
static DocumentBuilder getDefaultDocumentBuilder()
          Creates a simple version of a DocumentBuilder.
static DocumentBuilder getExtensiveDocumentBuilder()
          Creates a simple version of a DocumentBuilder.
static DocumentBuilder getFastAutoColorCorrelationDocumentBuilder()
          Creates a DocumentBuilder for the AutoColorCorrelation feature.
static DocumentBuilder getFastDocumentBuilder()
          Creates a simple version of a DocumentBuilder.
static DocumentBuilder getFullDocumentBuilder()
          Creates and returns a DocumentBuilder, which contains all available features.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentBuilderFactory

public DocumentBuilderFactory()
Method Detail

getDefaultDocumentBuilder

public static DocumentBuilder getDefaultDocumentBuilder()
Creates a simple version of a DocumentBuilder. In this case the SimpleDocumentBuilder is used, only ColorLayout and ScalableColor are used to index the images. Note that the color histogram weight in ImageSearcherFactory.createWeightedSearcher(int,float,float,float) won't have any effect on documents created with a DocumentBuilder like this. Only the color distribution weight and the texture weight are used in such a case.

Returns:
a simple and efficient DocumentBuilder.
See Also:
SimpleDocumentBuilder

getExtensiveDocumentBuilder

public static DocumentBuilder getExtensiveDocumentBuilder()
Creates a simple version of a DocumentBuilder. In this case the SimpleDocumentBuilder is used, all available descriptors are used.

Returns:
a fully featured DocumentBuilder.
See Also:
SimpleDocumentBuilder

getColorOnlyDocumentBuilder

public static DocumentBuilder getColorOnlyDocumentBuilder()
Creates a simple version of a DocumentBuilder. In this case the SimpleDocumentBuilder is used, only ColorLayout is used. So this can be taken for color only images.

Returns:
a fully featured DocumentBuilder.
See Also:
SimpleDocumentBuilder

getFastDocumentBuilder

public static DocumentBuilder getFastDocumentBuilder()
Creates a simple version of a DocumentBuilder. In this case the SimpleDocumentBuilder is used, only ColorLayout is used to index the images. Note that the weights in ImageSearcherFactory.createWeightedSearcher(int,float,float,float) won't have any effect on documents created with a DocumentBuilder like this, as only color distribution is used.

Returns:
a simple and fast DocumentBuilder.
See Also:
SimpleDocumentBuilder

getDefaultAutoColorCorrelationDocumentBuilder

public static DocumentBuilder getDefaultAutoColorCorrelationDocumentBuilder()
Creates a DocumentBuilder for the AutoColorCorrelation feature. Note that the extraction of this feature is especially slow! So use it only on small images! Images that do not fit in a 200x200 pixel box are resized by the document builder to ensure shorter processing time. See AutoColorCorrelogram for more information on the image feature. Be sure to use the same options for the ImageSearcher as you used for the DocumentBuilder.

Returns:
the created AutoCorrelation feature DocumentBuilder.

getFastAutoColorCorrelationDocumentBuilder

public static DocumentBuilder getFastAutoColorCorrelationDocumentBuilder()
Creates a DocumentBuilder for the AutoColorCorrelation feature. Note that the extraction of this feature is especially slow, but this is a more fast, but löess accurate settings version! Images that do not fit in a defined bounding box they are resized by the document builder to ensure shorter processing time. See AutoColorCorrelogram for more information on the image feature. Be sure to use the same options for the ImageSearcher as you used for the DocumentBuilder.

Returns:
the created AutoCorrelation feature DocumentBuilder.

getFullDocumentBuilder

public static DocumentBuilder getFullDocumentBuilder()
Creates and returns a DocumentBuilder, which contains all available features. For AutoColorCorrelogram the getDefaultAutoColorCorrelationDocumentBuilder() is used. Therefore it is compatible with the respective Searcher.

Returns:
a combination of all available features.