net.semanticmetadata.lire
Interface DocumentBuilder

All Known Implementing Classes:
AbstractDocumentBuilder, ChainedDocumentBuilder, CorrelogramDocumentBuilder, SimpleDocumentBuilder

public interface DocumentBuilder

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:02:00

Author:
Mathias Lux, mathias@juggle.at

Field Summary
static java.lang.String FIELD_NAME_AUTOCOLORCORRELOGRAM
           
static java.lang.String FIELD_NAME_COLORLAYOUT
           
static java.lang.String FIELD_NAME_EDGEHISTOGRAM
           
static java.lang.String FIELD_NAME_IDENTIFIER
           
static java.lang.String FIELD_NAME_SCALABLECOLOR
           
static int MAX_IMAGE_SIDE_LENGTH
           
 
Method Summary
 org.apache.lucene.document.Document createDocument(java.awt.image.BufferedImage image, java.lang.String identifier)
          Creates a new Lucene document from a BufferedImage.
 org.apache.lucene.document.Document createDocument(java.io.InputStream image, java.lang.String identifier)
          Creates a new Lucene document from an InputStream.
 

Field Detail

MAX_IMAGE_SIDE_LENGTH

static final int MAX_IMAGE_SIDE_LENGTH
See Also:
Constant Field Values

FIELD_NAME_SCALABLECOLOR

static final java.lang.String FIELD_NAME_SCALABLECOLOR
See Also:
Constant Field Values

FIELD_NAME_COLORLAYOUT

static final java.lang.String FIELD_NAME_COLORLAYOUT
See Also:
Constant Field Values

FIELD_NAME_EDGEHISTOGRAM

static final java.lang.String FIELD_NAME_EDGEHISTOGRAM
See Also:
Constant Field Values

FIELD_NAME_AUTOCOLORCORRELOGRAM

static final java.lang.String FIELD_NAME_AUTOCOLORCORRELOGRAM
See Also:
Constant Field Values

FIELD_NAME_IDENTIFIER

static final java.lang.String FIELD_NAME_IDENTIFIER
See Also:
Constant Field Values
Method Detail

createDocument

org.apache.lucene.document.Document createDocument(java.awt.image.BufferedImage image,
                                                   java.lang.String identifier)
Creates a new Lucene document from a BufferedImage. The identifier can be used like an id (e.g. the file name or the url of the image)

Parameters:
image - the image to index. Cannot be NULL.
identifier - an id for the image, for instance the filename or an URL. Can be NULL.
Returns:
a Lucene Document containing the indexed image.

createDocument

org.apache.lucene.document.Document createDocument(java.io.InputStream image,
                                                   java.lang.String identifier)
                                                   throws java.io.IOException
Creates a new Lucene document from an InputStream. The identifier can be used like an id (e.g. the file name or the url of the image)

Parameters:
image - the image to index. Cannot be NULL.
identifier - an id for the image, for instance the filename or an URL. Can be NULL.
Returns:
a Lucene Document containing the indexed image.
Throws:
java.io.IOException - in case the image cannot be retrieved from the InputStream