本文整理汇总了Java中net.semanticmetadata.lire.utils.FileUtils.getAllImageFiles方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.getAllImageFiles方法的具体用法?Java FileUtils.getAllImageFiles怎么用?Java FileUtils.getAllImageFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.semanticmetadata.lire.utils.FileUtils
的用法示例。
在下文中一共展示了FileUtils.getAllImageFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testIndexingAndSearchSift
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的package包/类
public void testIndexingAndSearchSift() throws IOException {
// Creating an Lucene IndexWriter
IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_40, new WhitespaceAnalyzer(Version.LUCENE_40));
IndexWriter iw = new IndexWriter(FSDirectory.open(indexPath), conf);
long ms = System.currentTimeMillis();
int count = 0;
ArrayList<File> files = FileUtils.getAllImageFiles(new File("testdata\\ferrari"), true);
for (Iterator<File> i = files.iterator(); i.hasNext(); ) {
File imgFile = i.next();
iw.addDocument(siftBuilder.createDocument(
ImageIO.read(imgFile), imgFile.getPath()));
count++;
if (count > 100 && count % 500 == 0) {
System.out.println(count + " files indexed. " + (System.currentTimeMillis() - ms) / (count) + " ms per file");
}
}
iw.close();
IndexReader ir = DirectoryReader.open(FSDirectory.open(indexPath));
SiftFeatureHistogramBuilder sfh = new SiftFeatureHistogramBuilder(ir, 1000, 500);
sfh.index();
}
示例2: testExtendedIndexMSER
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的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();
}
示例3: testSerialization
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的package包/类
public void testSerialization() throws IOException {
int bytes = 0;
int sum = 0;
ArrayList<File> files = FileUtils.getAllImageFiles(new File("testdata/ferrari"), true);
for (Iterator<File> iterator = files.iterator(); iterator.hasNext(); ) {
File next = iterator.next();
BufferedImage image = ImageIO.read(next);
AutoColorCorrelogram f1 = new AutoColorCorrelogram();
AutoColorCorrelogram f2 = new AutoColorCorrelogram();
f1.extract(image);
System.out.println("f1.getDoubleHistogram().length = " + f1.getDoubleHistogram().length);
System.out.println(Arrays.toString(f1.getDoubleHistogram()));
f2.setByteArrayRepresentation(f1.getByteArrayRepresentation());
// System.out.println(Arrays.toString(f2.getDoubleHistogram()));
assertTrue(f2.getDistance(f1) == 0);
// boolean isSame = true;
// for (int i = 0; i < f2..length; i++) {
// if (f1.data[i] != f2.data[i]) isSame=false;
// }
// assertTrue(isSame);
}
double save = 1d - (double) bytes / (double) sum;
System.out.println(save * 100 + "% saved");
}
示例4: testExtraction
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的package包/类
public void testExtraction() throws IOException {
ArrayList<File> files = FileUtils.getAllImageFiles(new File("testdata/ferrari"), true);
for (Iterator<File> iterator = files.iterator(); iterator.hasNext(); ) {
File next = iterator.next();
BufferedImage image = ImageIO.read(next);
JCD f1 = new JCD();
JCD f2 = new JCD();
f1.extract(image);
System.out.println(Arrays.toString(f1.getByteArrayRepresentation()));
bytes += f1.getByteArrayRepresentation().length;
sum += 168;
f2.setByteArrayRepresentation(f1.getByteArrayRepresentation());
assertTrue(f2.getDistance(f1) == 0);
}
double save = 1d - (double) bytes / (double) sum;
System.out.println(save * 100 + "% saved");
}
示例5: main
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
ArrayList<File> files = FileUtils.getAllImageFiles(new File("D:\\Temp\\tmp"), false);
int count = 10;
for (Iterator<File> iterator = files.iterator(); iterator.hasNext(); ) {
File next = iterator.next();
BufferedImage img = ImageIO.read(next);
BufferedImage toWrite = new BufferedImage(img.getWidth()*2, img.getHeight(), BufferedImage.TYPE_INT_RGB);
toWrite.getGraphics().drawImage(img, 0, 0, null);
BufferedImage bufferedImage = clusterPixels(img);
toWrite.getGraphics().drawImage(bufferedImage, img.getWidth(), 0, null);
ImageIO.write(toWrite, "png", new File("out_test_"+count+".png"));
count++;
}
}
示例6: testIndexing
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的package包/类
public void testIndexing() throws IOException, ParserConfigurationException, SAXException {
IndexWriterConfig iwConf = new IndexWriterConfig(Version.LUCENE_42, new SimpleAnalyzer(Version.LUCENE_42));
IndexWriter iw = new IndexWriter(FSDirectory.open(testIndex), iwConf);
// if you want to append the index to a pre-existing one use the next line.
// iwConf.setOpenMode(IndexWriterConfig.OpenMode.APPEND);
// create a LIRE DocumentBuilder for extracting FCTH (just an example, every other feature will do).
DocumentBuilder builder = DocumentBuilderFactory.getFCTHDocumentBuilder();
ArrayList<File> files = FileUtils.getAllImageFiles(new File("testdata/ferrari"), true);
// for handling the XML of the test data set
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
SAXParser saxParser = spf.newSAXParser();
XMLReader xmlReader = saxParser.getXMLReader();
for (Iterator<File> iterator = files.iterator(); iterator.hasNext(); ) {
File img = iterator.next();
String path = img.getCanonicalPath();
// create the document with the LIRE DocumentBuilder, this adds the image features to the document.
Document d = builder.createDocument(new FileInputStream(img), path);
// handling the XML of the test data set
path = path.substring(0,path.lastIndexOf('.')) + ".xml";
TagHandler handler = new TagHandler();
xmlReader.setContentHandler(handler);
xmlReader.parse(new InputSource(new File(path).toURI().toString()));
// add the text to the document ...
d.add(new TextField("tags", handler.getTags(), Field.Store.YES));
// don't forget to add the document to the index.
iw.addDocument(d);
}
iw.close();
}
示例7: testSerialization
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的package包/类
public void testSerialization() throws IOException {
int bytes = 0;
int sum = 0;
ArrayList<File> files = FileUtils.getAllImageFiles(new File("testdata/ferrari"), true);
for (Iterator<File> iterator = files.iterator(); iterator.hasNext(); ) {
File next = iterator.next();
BufferedImage image = ImageIO.read(next);
CEDD f1 = new CEDD();
CEDD f2 = new CEDD();
f1.extract(image);
// System.out.println(Arrays.toString(f1.getDoubleHistogram()));
bytes += f1.getByteArrayRepresentation().length;
sum += 144 / 2;
f2.setByteArrayRepresentation(f1.getByteArrayRepresentation());
// System.out.println(Arrays.toString(f2.getDoubleHistogram()));
double[] h = f2.getDoubleHistogram();
int pos = -1;
for (int i = 0; i < h.length; i++) {
double v = h[i];
if (pos == -1) {
if (v == 0) pos = i;
} else if (pos > -1) {
if (v != 0) pos = -1;
}
}
System.out.println("save = " + (144 - pos));
// bytes += (168 - pos);
assertTrue(f2.getDistance(f1) == 0);
boolean isSame = true;
// for (int i = 0; i < f2.getFieldName().length; i++) {
// if (f1.data[i] != f2.data[i]) isSame = false;
// }
assertTrue(isSame);
}
double save = 1d - (double) bytes / (double) sum;
System.out.println(save * 100 + "% saved");
}
示例8: testExtraction
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的package包/类
public void testExtraction() throws IOException {
ArrayList<File> files = FileUtils.getAllImageFiles(new File("testdata/ferrari"), true);
for (Iterator<File> iterator = files.iterator(); iterator.hasNext(); ) {
BufferedImage img = ImageIO.read(iterator.next());
LuminanceLayout p = new LuminanceLayout();
p.extract(img);
System.out.println(Arrays.toString(p.getDoubleHistogram()));
byte[] bytes = p.getByteArrayRepresentation();
LuminanceLayout g = new LuminanceLayout();
g.setByteArrayRepresentation(bytes, 0, bytes.length);
float distance = p.getDistance(p);
System.out.println("distance = " + distance);
}
}
示例9: testSerialization
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的package包/类
public void testSerialization() throws IOException {
ArrayList<File> files = FileUtils.getAllImageFiles(new File("testdata/ferrari"), true);
for (Iterator<File> iterator = files.iterator(); iterator.hasNext(); ) {
File next = iterator.next();
BufferedImage image = ImageIO.read(next);
PHOG p1 = new PHOG();
PHOG p2 = new PHOG();
p1.extract(image);
System.out.println(Arrays.toString(p1.getDoubleHistogram()));
p2.setByteArrayRepresentation(p1.getByteArrayRepresentation());
System.out.println(Arrays.toString(p2.getDoubleHistogram()));
assertTrue(p2.getDistance(p1) == 0);
}
}
示例10: testSerialization
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的package包/类
public void testSerialization() throws IOException {
int bytes = 0;
int sum = 0;
ArrayList<File> files = FileUtils.getAllImageFiles(new File("testdata/ferrari"), true);
for (Iterator<File> iterator = files.iterator(); iterator.hasNext(); ) {
File next = iterator.next();
BufferedImage image = ImageIO.read(next);
BinaryPatternsPyramid f1 = new BinaryPatternsPyramid();
BinaryPatternsPyramid f2 = new BinaryPatternsPyramid();
f1.extract(image);
// System.out.println(Arrays.toString(f1.getDoubleHistogram()));
bytes += f1.getByteArrayRepresentation().length;
sum += 144 / 2;
f2.setByteArrayRepresentation(f1.getByteArrayRepresentation());
// System.out.println(Arrays.toString(f2.getDoubleHistogram()));
double[] h = f2.getDoubleHistogram();
int pos = -1;
for (int i = 0; i < h.length; i++) {
double v = h[i];
if (pos == -1) {
if (v == 0) pos = i;
} else if (pos > -1) {
if (v != 0) pos = -1;
}
}
System.out.println("save = " + (144 - pos));
// bytes += (168 - pos);
assertTrue(f2.getDistance(f1) == 0);
boolean isSame = true;
for (int i = 0; i < f2.getDoubleHistogram().length; i++) {
if (f1.getDoubleHistogram()[i] != f2.getDoubleHistogram()[i]) isSame = false;
}
assertTrue(isSame);
}
double save = 1d - (double) bytes / (double) sum;
System.out.println(save * 100 + "% saved");
}
示例11: testExtraction
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的package包/类
public void testExtraction() throws IOException {
ArrayList<File> files = FileUtils.getAllImageFiles(new File("testdata/ferrari"), true);
for (Iterator<File> iterator = files.iterator(); iterator.hasNext(); ) {
File next = iterator.next();
BufferedImage image = ImageIO.read(next);
ColorLayout p1 = new ColorLayout();
ColorLayout p2 = new ColorLayout();
p1.extract(image);
System.out.println(Arrays.toString(p1.getDoubleHistogram()));
p2.setByteArrayRepresentation(p1.getByteArrayRepresentation());
System.out.println(Arrays.toString(p2.getDoubleHistogram()));
assertTrue(p2.getDistance(p1) == 0);
}
}
示例12: testExtraction
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的package包/类
public void testExtraction() throws IOException {
int bytes = 0, sum = 0;
ArrayList<File> files = FileUtils.getAllImageFiles(new File("testdata/ferrari"), true);
for (Iterator<File> iterator = files.iterator(); iterator.hasNext(); ) {
File next = iterator.next();
BufferedImage image = ImageIO.read(next);
FCTH f1 = new FCTH();
FCTH f2 = new FCTH();
f1.extract(image);
System.out.println(Arrays.toString(f1.getDoubleHistogram()));
bytes += f1.getByteArrayRepresentation().length;
sum += 192/2;
f2.setByteArrayRepresentation(f1.getByteArrayRepresentation());
// System.out.println(Arrays.toString(f2.getDoubleHistogram()));
double[] h = f2.getDoubleHistogram();
int pos = -1;
for (int i = 0; i < h.length; i++) {
double v = h[i];
if (pos == -1) {
if (v == 0) pos = i;
}
else if (pos > -1) {
if (v!=0) pos = -1;
}
}
System.out.println("save = " + (192-pos));
assertTrue(f2.getDistance(f1) == 0);
}
double save = 1d - (double) bytes / (double) sum;
System.out.println(save*100 + "% saved");
}
示例13: testExtraction
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的package包/类
public void testExtraction() throws IOException {
ArrayList<File> files = FileUtils.getAllImageFiles(new File("testdata/ferrari"), true);
for (Iterator<File> iterator = files.iterator(); iterator.hasNext(); ) {
File next = iterator.next();
BufferedImage image = ImageIO.read(next);
EdgeHistogram eh1 = new EdgeHistogram();
EdgeHistogram eh2 = new EdgeHistogram();
eh1.extract(image);
System.out.println(" = " + eh1.getStringRepresentation());
eh2.setByteArrayRepresentation(eh1.getByteArrayRepresentation());
assertTrue(eh2.getDistance(eh1) == 0);
}
}
示例14: testGenFile
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的package包/类
public void testGenFile() throws IOException {
ArrayList<File> images = FileUtils.getAllImageFiles(new File("W:\\Forschung\\Intention_Test_Data\\data\\images"), true);
// print header
System.out.println("% generated automatically by LIRe\n" +
"@relation content_based_features\n" +
"\n" +
"@attribute image_filename String");
System.out.println("@attribute faces numeric");
System.out.println("@attribute cedd relational");
for (int i = 0; i < 144; i++) {
System.out.println("\[email protected] c" + i + " numeric");
}
System.out.println("@end cedd");
System.out.println("@attribute rgb_hist relational");
for (int i = 0; i < 64; i++) {
System.out.println("\[email protected] rh" + i + " numeric");
}
System.out.println("@end rgb_hist");
System.out.println("@data");
// print data
for (Iterator<File> iterator = images.iterator(); iterator.hasNext(); ) {
File nextFile = iterator.next();
try {
BufferedImage img = ImageIO.read(nextFile);
// filename
System.out.print(nextFile.getName() + ",");
// cedd
CEDD cedd = new CEDD();
cedd.extract(img);
double[] histogram = cedd.getDoubleHistogram();
for (int i = 0; i < histogram.length; i++) {
System.out.print((int) histogram[i]);
System.out.print(',');
}
// System.out.println();
// rgb histogram
SimpleColorHistogram.DEFAULT_NUMBER_OF_BINS = 64;
SimpleColorHistogram rgb = new SimpleColorHistogram();
rgb.extract(img);
histogram = rgb.getDoubleHistogram();
for (int i = 0; i < histogram.length; i++) {
System.out.print((int) histogram[i]);
System.out.print(',');
}
System.out.println();
} catch (Exception e) {
System.out.println("-- ERROR -- " + nextFile.getName() + ", " + e.getMessage());
}
}
}
示例15: testRLE
import net.semanticmetadata.lire.utils.FileUtils; //导入方法依赖的package包/类
/**
* Storing zeros run length coded: one zero is "8", two zeros are "9", ... etc.
* @throws IOException
*/
public void testRLE() throws IOException {
ArrayList<File> files = FileUtils.getAllImageFiles(new File("testdata/ferrari"), true);
int sum = 0, saved = 0;
for (Iterator<File> iterator = files.iterator(); iterator.hasNext(); ) {
File next = iterator.next();
BufferedImage image = ImageIO.read(next);
CEDD f1 = new CEDD();
f1.extract(image);
double[] hist = f1.getDoubleHistogram();
int[] rep = new int[hist.length];
int actualLength = 0;
for (int i = 0; i < hist.length; i++) {
// hist[i];
if (hist[i] == 0) {
int count = 0;
while (i + count < hist.length && hist[i + count] == 0 && count < 8) count++;
if (count == 0) rep[actualLength] = 0;
else {
rep[actualLength] = 7 + count;
i += count-1;
}
} else {
rep[actualLength] = (int) hist[i];
}
actualLength++;
}
for (int i = 0; i < actualLength; i++) {
System.out.print(rep[i] + " ");
}
System.out.println();
// decoding ...
double[] hist2 = new double[144];
int pos = 0;
for (int i = 0; i < actualLength; i++) {
if (rep[i] < 8) {
hist2[pos] = rep[i];
pos++;
} else {
for (int j = 7; j < rep[i]; j++) {
hist2[pos] = 0;
pos++;
}
}
}
sum += 144;
saved += actualLength;
assertTrue(Arrays.equals(hist2, f1.getDoubleHistogram()));
}
System.out.println("sum of dimensions = " + sum);
System.out.println("actual dimensions = " + saved);
}