本文整理汇总了Java中net.semanticmetadata.lire.indexing.parallel.ParallelIndexer类的典型用法代码示例。如果您正苦于以下问题:Java ParallelIndexer类的具体用法?Java ParallelIndexer怎么用?Java ParallelIndexer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParallelIndexer类属于net.semanticmetadata.lire.indexing.parallel包,在下文中一共展示了ParallelIndexer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSearchSpeed
import net.semanticmetadata.lire.indexing.parallel.ParallelIndexer; //导入依赖的package包/类
private void testSearchSpeed(ArrayList<String> images, final Class featureClass) throws IOException {
parallelIndexer = new ParallelIndexer(8, indexPath, testExtensive, true) {
@Override
public void addBuilders(ChainedDocumentBuilder builder) {
builder.addBuilder(new GenericDocumentBuilder(featureClass, "feature"));
}
};
parallelIndexer.run();
IndexReader reader = DirectoryReader.open(new RAMDirectory(FSDirectory.open(new File(indexPath)), IOContext.READONCE));
Bits liveDocs = MultiFields.getLiveDocs(reader);
double queryCount = 0d;
ImageSearcher searcher = new GenericFastImageSearcher(100, featureClass, "feature");
long ms = System.currentTimeMillis();
for (int i = 0; i < reader.maxDoc(); i++) {
if (reader.hasDeletions() && !liveDocs.get(i)) continue; // if it is deleted, just ignore it.
String fileName = getIDfromFileName(reader.document(i).getValues(DocumentBuilder.FIELD_NAME_IDENTIFIER)[0]);
if (queries.keySet().contains(fileName)) {
queryCount += 1d;
// ok, we've got a query here for a document ...
Document queryDoc = reader.document(i);
ImageSearchHits hits = searcher.search(queryDoc, reader);
}
}
ms = System.currentTimeMillis() - ms;
System.out.printf("%s \t %3.1f \n", featureClass.getName().substring(featureClass.getName().lastIndexOf('.')+1), (double) ms / queryCount);
}
示例2: main
import net.semanticmetadata.lire.indexing.parallel.ParallelIndexer; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
// Checking if arg[0] is there and if it is a directory.
boolean passed = false;
if (args.length > 0) {
File f = new File(args[0]);
System.out.println("Indexing images in " + args[0]);
if (f.exists() && f.isDirectory()) passed = true;
}
if (!passed) {
System.out.println("No directory given as first argument.");
System.out.println("Run \"ParallelIndexing <directory>\" to index files of a directory.");
System.exit(1);
}
// use ParallelIndexer to index all photos from args[0] into "index" ... use 6 threads (actually 7 with the I/O thread).
ParallelIndexer indexer = new ParallelIndexer(6, "index", args[0]) {
// use this to add you preferred builders. For now we go for CEDD, FCTH and AutoColorCorrelogram
public void addBuilders(ChainedDocumentBuilder builder) {
builder.addBuilder(DocumentBuilderFactory.getCEDDDocumentBuilder());
builder.addBuilder(DocumentBuilderFactory.getFCTHDocumentBuilder());
builder.addBuilder(DocumentBuilderFactory.getAutoColorCorrelogramDocumentBuilder());
}
};
indexer.run();
System.out.println("Finished indexing.");
}
示例3: testIndexingAndSearchSurf
import net.semanticmetadata.lire.indexing.parallel.ParallelIndexer; //导入依赖的package包/类
public void testIndexingAndSearchSurf() throws IOException {
ParallelIndexer pin = new ParallelIndexer(8, pathName, "wang-1000") {
@Override
public void addBuilders(ChainedDocumentBuilder builder) {
builder.addBuilder(new SurfDocumentBuilder());
}
};
pin.run();
IndexReader ir = DirectoryReader.open(FSDirectory.open(indexPath));
SurfFeatureHistogramBuilder sfh = new SurfFeatureHistogramBuilder(ir, 1000, 50);
sfh.index();
}
示例4: testParallelIndexMSER
import net.semanticmetadata.lire.indexing.parallel.ParallelIndexer; //导入依赖的package包/类
public void testParallelIndexMSER() throws IOException {
ParallelIndexer pin = new ParallelIndexer(1, "mser-idx", "D:\\DataSets\\WIPO\\CA\\sample") {
@Override
public void addBuilders(ChainedDocumentBuilder builder) {
builder.addBuilder(new MSERDocumentBuilder());
}
};
pin.run();
}
示例5: testFastSearch
import net.semanticmetadata.lire.indexing.parallel.ParallelIndexer; //导入依赖的package包/类
public void testFastSearch() throws IOException {
Codec.forName("LireCustomCodec");
// ParallelIndexer pin = new ParallelIndexer(7, "./index-fast-3", "testdata/wang-1000") {
ParallelIndexer pin = new ParallelIndexer(7, "./index-fast-3", "D:\\DataSets\\Flickrphotos\\01", true) {
@Override
public void addBuilders(ChainedDocumentBuilder builder) {
builder.addBuilder(DocumentBuilderFactory.getOpponentHistogramDocumentBuilder());
}
};
pin.run();
IndexReader ir = DirectoryReader.open(MMapDirectory.open(new File("./index-fast-3")));
System.out.println("ir.maxDoc() = " + ir.maxDoc());
long ms = System.currentTimeMillis();
ImageSearcher is = new FastOpponentImageSearcher(50);
ms = System.currentTimeMillis() - ms;
System.out.println("init ms = " + ms);
ms = System.currentTimeMillis();
for (int i = 0; i < 100; i++) is.search(ir.document(i), ir);
ms = System.currentTimeMillis() - ms;
System.out.println("cached ms = " + ms);
is = ImageSearcherFactory.createOpponentHistogramSearcher(50);
ms = System.currentTimeMillis();
for (int i = 0; i < 100; i++) is.search(ir.document(i), ir);
ms = System.currentTimeMillis() - ms;
System.out.println("read from Lucene ms = " + ms);
}
示例6: setUp
import net.semanticmetadata.lire.indexing.parallel.ParallelIndexer; //导入依赖的package包/类
protected void setUp() throws Exception {
super.setUp();
// set to all queries ... approach "leave one out"
sampleQueries = new int[1100];
for (int i = 0; i < sampleQueries.length; i++) {
sampleQueries[i] = i;
}
indexPath += "-" + System.currentTimeMillis() % (1000 * 60 * 60 * 24 * 7);
// Setting up DocumentBuilder:
// parallelIndexer = new ParallelIndexer(8, indexPath, testExtensive);
parallelIndexer = new ParallelIndexer(8, indexPath, testExtensive, true) {
@Override
public void addBuilders(ChainedDocumentBuilder builder) {
// builder.addBuilder(DocumentBuilderFactory.getCEDDDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getAutoColorCorrelogramDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getColorLayoutBuilder());
// builder.addBuilder(DocumentBuilderFactory.getEdgeHistogramBuilder());
// builder.addBuilder(DocumentBuilderFactory.getFCTHDocumentBuilder());
builder.addBuilder(DocumentBuilderFactory.getJCDDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getJointHistogramDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getOpponentHistogramDocumentBuilder());
builder.addBuilder(DocumentBuilderFactory.getPHOGDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getColorHistogramDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getScalableColorBuilder());
// builder.addBuilder(DocumentBuilderFactory.getLuminanceLayoutDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getJpegCoefficientHistogramDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getColorHistogramDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getGaborDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getTamuraDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getScalableColorBuilder());
// builder.addBuilder(new GenericDocumentBuilder(RankAndOpponent.class, "jop"));
// builder.addBuilder(new GenericFastDocumentBuilder(FuzzyOpponentHistogram.class, "opHist"));
// builder.addBuilder(new SurfDocumentBuilder());
// builder.addBuilder(new MSERDocumentBuilder());
// builder.addBuilder(new SiftDocumentBuilder());
// builder.addBuilder(new GenericDocumentBuilder(SPCEDD.class));
// builder.addBuilder(new GenericDocumentBuilder(SPFCTH.class));
// builder.addBuilder(new GenericDocumentBuilder(SPJCD.class));
// builder.addBuilder(new GenericDocumentBuilder(SPACC.class));
// builder.addBuilder(new GenericDocumentBuilder(LocalBinaryPatterns.class));
// builder.addBuilder(new GenericDocumentBuilder(BinaryPatternsPyramid.class, "whog"));
// builder.addBuilder(new GenericDocumentBuilder(LocalBinaryPatternsAndOpponent.class));
// builder.addBuilder(new GenericDocumentBuilder(RotationInvariantLocalBinaryPatterns.class));
// builder.addBuilder(new GenericDocumentBuilder(SPLBP.class));
}
};
}
示例7: setUp
import net.semanticmetadata.lire.indexing.parallel.ParallelIndexer; //导入依赖的package包/类
protected void setUp() throws Exception {
super.setUp();
indexPath += "-" + System.currentTimeMillis() % (1000 * 60 * 60 * 24 * 7);
// Setting up DocumentBuilder:
parallelIndexer = new ParallelIndexer(16, indexPath, testExtensive, true) {
@Override
public void addBuilders(ChainedDocumentBuilder builder) {
// builder.addBuilder(DocumentBuilderFactory.getCEDDDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getAutoColorCorrelogramDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getColorLayoutBuilder());
// builder.addBuilder(DocumentBuilderFactory.getEdgeHistogramBuilder());
// builder.addBuilder(DocumentBuilderFactory.getFCTHDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getJCDDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getJointHistogramDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getOpponentHistogramDocumentBuilder());
builder.addBuilder(DocumentBuilderFactory.getPHOGDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getColorHistogramDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getScalableColorBuilder());
// builder.addBuilder(DocumentBuilderFactory.getTamuraDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getGaborDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getLuminanceLayoutDocumentBuilder());
// builder.addBuilder(DocumentBuilderFactory.getJpegCoefficientHistogramDocumentBuilder());
// builder.addBuilder(new GenericDocumentBuilder(RankAndOpponent.class, "jop"));
// builder.addBuilder(new GenericFastDocumentBuilder(FuzzyOpponentHistogram.class, "opHist"));
// builder.addBuilder(new SurfDocumentBuilder());
// builder.addBuilder(new MSERDocumentBuilder());
// builder.addBuilder(new SiftDocumentBuilder());
// builder.addBuilder(new GenericDocumentBuilder(SPCEDD.class));
// builder.addBuilder(new GenericDocumentBuilder(SPJCD.class));
// builder.addBuilder(new GenericDocumentBuilder(SPFCTH.class));
// builder.addBuilder(new GenericDocumentBuilder(SPACC.class));
// builder.addBuilder(new GenericDocumentBuilder(LocalBinaryPatterns.class, "lbp"));
// builder.addBuilder(new GenericDocumentBuilder(LocalBinaryPatternsAndOpponent.class, "jhl"));
// builder.addBuilder(new GenericDocumentBuilder(RotationInvariantLocalBinaryPatterns.class, "rlbp"));
// builder.addBuilder(new GenericDocumentBuilder(SPLBP.class));
}
};
// Getting the queries:
BufferedReader br = new BufferedReader(new FileReader(groundTruth));
String line;
queries = new HashMap<String, List<String>>(260);
String currentQuery = null;
LinkedList<String> results = null;
while ((line = br.readLine()) != null) {
line = line.trim();
if (line.startsWith("#") || line.length() < 4)
continue;
else {
if (line.endsWith(":")) {
if (currentQuery != null) {
queries.put(currentQuery, results);
}
currentQuery = line.replace(':', ' ').trim();
results = new LinkedList<String>();
} else {
results.add(line);
}
}
}
queries.put(currentQuery, results);
}