本文整理汇总了Java中net.semanticmetadata.lire.DocumentBuilder.FIELD_NAME_SURF_VISUAL_WORDS属性的典型用法代码示例。如果您正苦于以下问题:Java DocumentBuilder.FIELD_NAME_SURF_VISUAL_WORDS属性的具体用法?Java DocumentBuilder.FIELD_NAME_SURF_VISUAL_WORDS怎么用?Java DocumentBuilder.FIELD_NAME_SURF_VISUAL_WORDS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.semanticmetadata.lire.DocumentBuilder
的用法示例。
在下文中一共展示了DocumentBuilder.FIELD_NAME_SURF_VISUAL_WORDS属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateQuery
public void testCreateQuery() throws IOException {
IndexReader reader = DirectoryReader.open(FSDirectory.open(new File("./index-mirflickr")));
BufferedImage image = ImageIO.read(new File("./wang-1000/0.jpg"));
SurfDocumentBuilder sb = new SurfDocumentBuilder();
Document d = sb.createDocument(image, "query");
SurfFeatureHistogramBuilder sfb = new SurfFeatureHistogramBuilder(reader);
d = sfb.getVisualWords(d);
VisualWordsImageSearcher searcher = new VisualWordsImageSearcher(3, DocumentBuilder.FIELD_NAME_SURF_VISUAL_WORDS);
ImageSearchHits hits = searcher.search(d, reader);
for (int i = 0; i < hits.length(); i++) {
hits.doc(i);
}
}
示例2: init
private void init() {
localFeatureFieldName = DocumentBuilder.FIELD_NAME_SURF;
visualWordsFieldName = DocumentBuilder.FIELD_NAME_SURF_VISUAL_WORDS;
localFeatureHistFieldName = DocumentBuilder.FIELD_NAME_SURF_LOCAL_FEATURE_HISTOGRAM;
clusterFile = "./clusters-surf.dat";
}
示例3: computePrecision
public void computePrecision(String pathName, Similarity similarity, String label) throws IOException {
// ImageSearcher vis = new GenericImageSearcher(4, SimpleFeature.class, "featureSURFHistogram");
// ImageSearcher vis = new GenericFastImageSearcher(4, CEDD.class, DocumentBuilder.FIELD_NAME_CEDD);
// VisualWordsImageSearcher vis = new VisualWordsImageSearcher(4, similarity, DocumentBuilder.FIELD_NAME_SIFT_VISUAL_WORDS);
VisualWordsImageSearcher vis = new VisualWordsImageSearcher(4, similarity, DocumentBuilder.FIELD_NAME_SURF_VISUAL_WORDS);
IndexReader reader = DirectoryReader.open(FSDirectory.open(new File(pathName)));
int queryID, resultID;
int countSearches = 0, countTruePositives = 0;
float avgPrecision = 0f;
Set<Integer> test = StatsUtils.drawSample(100, 10200);
// Needed for check whether the document is deleted.
Bits liveDocs = MultiFields.getLiveDocs(reader);
for (int i : test) {
// for (int j = 0; j < tests.length; j++) {
// int i = tests[j];
// for (int i =0; i < 1000; i++) {
// for (int i =0; i < reader.numDocs(); i++) {
if (!((reader.hasDeletions() && !liveDocs.get(i)))) {
ImageSearchHits hits = vis.search(reader.document(i), reader);
String s = reader.document(i).getValues(DocumentBuilder.FIELD_NAME_IDENTIFIER)[0];
s = s.replaceAll("\\D", "");
queryID = Integer.parseInt(s);
countTruePositives = 0;
for (int k = 0; k < hits.length(); k++) {
String name = hits.doc(k).getValues(DocumentBuilder.FIELD_NAME_IDENTIFIER)[0];
name = name.replaceAll("\\D", "");
resultID = Integer.parseInt(name);
if (queryID / 4 == resultID / 4) {
//System.out.print("X");
countTruePositives++;
}
//else System.out.print("O");
}
countSearches++;
avgPrecision += (float) countTruePositives / 4f;
// progress:
// if (countSearches%100==0) System.out.print('.');
// if (countSearches%1000==0) System.out.print(':');
//System.out.println();
}
}
avgPrecision = avgPrecision / (float) countSearches;
FileWriter fw = new FileWriter(new File("precision_results.txt"), true);
System.out.println(label + " [email protected]= " + avgPrecision);
fw.write(label + " [email protected]= " + avgPrecision + "\n");
fw.close();
}