This is a Solr plugin for the LIRE content based image retrieval library, so basically it's for indexing images and then finding similar (looking) ones. The original library can be found at https://code.google.com/p/lire/
The LIRE Solr plugin includes a RequestHandler for searching, an EntityProcessor for indexing, a ValeSource Parser for content based re-ranking and a parallel indexing application.
A demo can be found at http://demo-itec.uni-klu.ac.at/liredemo/
The request handler supports four different types of queries
Supported values for feature field parameters, e.g. lireq?field=cl_ha:
Returns randomly chosen images from the index.
Parameters:
Returns images that look like the one with the given ID.
Parameters:
Returns images that look like the one found at the given URL.
Parameters:
Returns an image that looks like the one the given features were extracted. This method is used if the client extracts the features from the image, which makes sense if the image should not be submitted.
Parameters:
Extracts the histogram of an image for use with the lire sorting function.
Parameters:
First run the dist task to create a single jar. This should be integrated in the Solr class-path. Then add the new request handler has to be registered in the solrconfig.xml file:
<requestHandler name="/lireq" class="net.semanticmetadata.lire.solr.LireRequestHandler">
<lst name="defaults">
<str name="echoParams">explicit</str>
<str name="wt">json</str>
<str name="indent">true</str>
</lst>
</requestHandler>
Use of the request handler is detailed above.
You'll also need the respective fields in the schema.xml file:
<fields>
<!-- file path for ID -->
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<!-- the sole file name -->
<field name="title" type="text_general" indexed="true" stored="true" multiValued="true"/>
<!-- Edge Histogram -->
<field name="eh_ha" type="text_ws" indexed="true" stored="false" required="false"/>
<field name="eh_hi" type="binaryDV" indexed="false" stored="true" required="false"/>
<!-- ColorLayout -->
<field name="cl_ha" type="text_ws" indexed="true" stored="false" required="false"/>
<field name="cl_hi" type="binaryDV" indexed="false" stored="true" required="false"/>
<!-- PHOG -->
<field name="ph_ha" type="text_ws" indexed="true" stored="false" required="false"/>
<field name="ph_hi" type="binaryDV" indexed="false" stored="true" required="false"/>
<!-- JCD -->
<field name="jc_ha" type="text_ws" indexed="true" stored="false" required="false"/>
<field name="jc_hi" type="binaryDV" indexed="false" stored="true" required="false"/>
<!-- OpponentHistogram -->
<!--field name="oh_ha" type="text_ws" indexed="true" stored="false" required="false"/-->
<!--field name="oh_hi" type="binary" indexed="false" stored="true" required="false"/-->
<!-- Needed for SOLR -->
<field name="_version_" type="long" indexed="true" stored="true"/>
</fields>
Do not forget to add the custom field at the very same file:
<fieldtype name="binaryDV" class="net.semanticmetadata.lire.solr.BinaryDocValuesField"/>
There is also a sort function based on LIRE. The function parser needs to be added to the solarconfig.xml file like this:
<valueSourceParser name="lirefunc"
class="net.semanticmetadata.lire.solr.LireValueSourceParser" />
Then the function lirefunc(arg1,arg2) is available for function queries. Two arguments are necessary and are defined as:
Note that if you send the parameters using an URL you might take extra care of the URL encoding, ie. white space, the "=" sign, etc.
Examples:
If you extract the features yourself, use code like his one:
// ColorLayout
ColorLayout cl = new ColorLayout();
cl.extract(ImageIO.read(new File("...")));
String arg1 = "cl";
String arg2 = Base64.encode(cl.getByteArrayRepresentation());
// PHOG
PHOG ph = new PHOG();
ph.extract(ImageIO.read(new File("...")));
String arg1 = "ph";
String arg2 = Base64.encode(ph.getByteArrayRepresentation());
Check ParallelSolrIndexer.java for indexing. It creates XML documents (either one per image or one single large file) to be sent to the Solr Server.
Another way is to use the LireEntityProcessor. Then you have to reference the solr-data-config.xml file in the solrconfig.xml, and then give the configuration for the EntityProcessor like this:
<dataConfig>
<dataSource name ="bin" type="BinFileDataSource" />
<document>
<entity name="f"
processor="FileListEntityProcessor"
transformer="TemplateTransformer"
baseDir="D:\Java\Projects\Lire\testdata\wang-1000\"
fileName=".*jpg"
recursive="true"
rootEntity="false" dataSource="null" onError="skip">
<entity name="lire-test" processor="net.semanticmetadata.lire.solr.LireEntityProcessor" url="${f.fileAbsolutePath}" dataSource="bin" onError="skip">
<field column="id"/>
<field column="cl_ha"/>
<field column="cl_hi"/>
<field column="ph_ha"/>
<field column="ph_hi"/>
<field column="oh_ha"/>
<field column="oh_hi"/>
<field column="jc_ha"/>
<field column="jc_hi"/>
<field column="eh_ha"/>
<field column="eh_hi"/>
</entity>
</entity>
</document>
</dataConfig>
Mathias Lux, 2013-12-19