本文整理汇总了Java中net.semanticmetadata.lire.impl.MSERDocumentBuilder类的典型用法代码示例。如果您正苦于以下问题:Java MSERDocumentBuilder类的具体用法?Java MSERDocumentBuilder怎么用?Java MSERDocumentBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MSERDocumentBuilder类属于net.semanticmetadata.lire.impl包,在下文中一共展示了MSERDocumentBuilder类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExtendedIndexMSER
import net.semanticmetadata.lire.impl.MSERDocumentBuilder; //导入依赖的package包/类
public void testExtendedIndexMSER() throws IOException {
MSERDocumentBuilder builder = new MSERDocumentBuilder();
IndexWriterConfig conf = new IndexWriterConfig(LuceneUtils.LUCENE_VERSION,
new WhitespaceAnalyzer(LuceneUtils.LUCENE_VERSION));
IndexWriter iw = new IndexWriter(FSDirectory.open(indexPath), conf);
long ms = System.currentTimeMillis();
int count = 0;
ArrayList<File> files = FileUtils.getAllImageFiles(new File("D:\\DataSets\\WIPO\\CA\\sample"), true);
for (Iterator<File> i = files.iterator(); i.hasNext(); ) {
File imgFile = i.next();
BufferedImage img = ImageIO.read(imgFile);
if (Math.max(img.getWidth(), img.getHeight()) < 800) {
// scale image ...
img = ImageUtils.scaleImage(img, 800);
}
iw.addDocument(builder.createDocument(img, imgFile.getPath()));
count++;
if (count > 2 && count % 25 == 0) {
System.out.println(count + " files indexed. " + (System.currentTimeMillis() - ms) / (count) + " ms per file");
}
}
iw.close();
}
示例2: testMSERExtraction
import net.semanticmetadata.lire.impl.MSERDocumentBuilder; //导入依赖的package包/类
public void testMSERExtraction() throws IOException {
MSERDocumentBuilder db = new MSERDocumentBuilder();
String file = "./wang-1000/199.jpg";
Document document = db.createDocument(ImageIO.read(new FileInputStream(file)), file);
// byte[][] binaryValues = document.getBinaryValues(DocumentBuilder.FIELD_NAME_MSER);
// System.out.println("binaryValues.length = " + binaryValues.length);
//
// for (int i = 0; i < binaryValues.length; i++) {
// byte[] binaryValue = binaryValues[i];
// MSERFeature feat = new MSERFeature();
// feat.setByteArrayRepresentation(binaryValues[i]);
// for (int j = 0; j < feat.descriptor.length; j++) {
// if (!Float.isNaN(feat.descriptor[j])) System.out.println("feat " + i + " = " + feat);
// break;
// }
// }
}
示例3: testParallelIndexMSER
import net.semanticmetadata.lire.impl.MSERDocumentBuilder; //导入依赖的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();
}
示例4: testFaulty
import net.semanticmetadata.lire.impl.MSERDocumentBuilder; //导入依赖的package包/类
public void testFaulty() throws IOException {
MSERDocumentBuilder builder = new MSERDocumentBuilder();
// String file = "C:\\Temp\\testImagelogos\\xml\\00\\00\\72330000.gif";
String file = "C:\\Temp\\test.png";
BufferedImage image = ImageUtils.createWorkingCopy(ImageIO.read(new FileInputStream(file)));
BufferedImage image1 = ImageUtils.getGrayscaleImage(image);
// extract features from image:
MSER extractor = new MSER();
List<MSERFeature> features = extractor.computeMSERFeatures(image1);
ImageUtils.invertImage(image1);
// invert grey
features.addAll(extractor.computeMSERFeatures(image1));
System.out.println(features.size());
}
示例5: testSimpleIndexMSER
import net.semanticmetadata.lire.impl.MSERDocumentBuilder; //导入依赖的package包/类
public void testSimpleIndexMSER() throws IOException {
MSERDocumentBuilder builder = new MSERDocumentBuilder();
for (String file : testFiles) {
builder.createDocument(new FileInputStream(testFilesPath + file), testFilesPath + file);
}
}