本文整理汇总了Java中net.semanticmetadata.lire.ImageSearcherFactory.createCEDDImageSearcher方法的典型用法代码示例。如果您正苦于以下问题:Java ImageSearcherFactory.createCEDDImageSearcher方法的具体用法?Java ImageSearcherFactory.createCEDDImageSearcher怎么用?Java ImageSearcherFactory.createCEDDImageSearcher使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.semanticmetadata.lire.ImageSearcherFactory
的用法示例。
在下文中一共展示了ImageSearcherFactory.createCEDDImageSearcher方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPerformance
import net.semanticmetadata.lire.ImageSearcherFactory; //导入方法依赖的package包/类
public void testPerformance() throws IOException {
MetricSpacesInvertedListIndexing mes = MetricSpacesInvertedListIndexing.getDefaultInstance();
int numSearches = 10;
IndexReader reader = mes.getIndexReader(indexPath);
System.out.println(reader.maxDoc() + " documents");
TopDocs docs;
long ms = System.currentTimeMillis();
for (int i = 0; i < numSearches; i++) {
docs = mes.search(reader.document(i), indexPath);
}
ms = System.currentTimeMillis() - ms;
System.out.println("ms = " + ms);
ImageSearcher ceddSearcher = ImageSearcherFactory.createCEDDImageSearcher(100);
ms = System.currentTimeMillis();
for (int i = 0; i < numSearches; i++) {
ceddSearcher.search(reader.document(i), reader);
}
ms = System.currentTimeMillis() - ms;
System.out.println("ms = " + ms);
}
示例2: main
import net.semanticmetadata.lire.ImageSearcherFactory; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
// Checking if arg[0] is there and if it is an image.
BufferedImage img = null;
boolean passed = false;
if (args.length > 0) {
File f = new File(args[0]);
if (f.exists()) {
try {
img = ImageIO.read(f);
passed = true;
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
}
if (!passed) {
System.out.println("No image given as first argument.");
System.out.println("Run \"Searcher <query image>\" to search for <query image>.");
System.exit(1);
}
IndexReader ir = DirectoryReader.open(FSDirectory.open(new File("index")));
ImageSearcher searcher = ImageSearcherFactory.createCEDDImageSearcher(10);
ImageSearchHits hits = searcher.search(img, ir);
for (int i = 0; i < hits.length(); i++) {
String fileName = hits.doc(i).getValues(DocumentBuilder.FIELD_NAME_IDENTIFIER)[0];
System.out.println(hits.score(i) + ": \t" + fileName);
}
}