1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package org.openimaj.image.model.asm.datasets;
31
32 import java.io.File;
33 import java.io.IOException;
34 import java.net.URL;
35
36 import org.apache.commons.io.FileUtils;
37 import org.openimaj.citation.annotation.Reference;
38 import org.openimaj.citation.annotation.ReferenceType;
39 import org.openimaj.data.DataUtils;
40 import org.openimaj.experiment.annotations.DatasetDescription;
41 import org.openimaj.image.Image;
42 import org.openimaj.io.InputStreamObjectReader;
43
44
45
46
47
48
49 @DatasetDescription(
50 name = "The IMM Face Database",
51 description = "A dataset consisting of 240 annotated monocular " +
52 "images of 40 different human faces. Points of correspondence are placed " +
53 "on each image so the dataset can be readily used for building statistical " +
54 "models of shape.",
55 creator = "Michael M. Nordstrom, Mads Larsen, Janusz Sierakowski, and Mikkel B. Stegmann",
56 url = "http://www2.imm.dtu.dk/~aam/datasets/datasets.html",
57 downloadUrls = {
58 "http://datasets.openimaj.org/imm_face_db.zip"
59 })
60 @Reference(
61 type = ReferenceType.Article,
62 author = { "M. B. Stegmann", "B. K. Ersb{\\o}ll", "R. Larsen" },
63 title = "{FAME} -- A Flexible Appearance Modelling Environment",
64 year = "2003",
65 journal = "IEEE Trans. on Medical Imaging",
66 pages = { "1319", "1331" },
67 number = "10",
68 publisher = "IEEE",
69 volume = "22")
70 public class IMMFaceDatabase {
71 private static final String DATA_ZIP = "imm_face_db.zip";
72 private static final String DATA_DOWNLOAD_URL = "http://datasets.openimaj.org/imm_face_db.zip";
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 public static <IMAGE extends Image<?, IMAGE>> ShapeModelDataset<IMAGE> load(InputStreamObjectReader<IMAGE> reader)
89 throws IOException
90 {
91 return ShapeModelDatasets.loadASFDataset(downloadAndGetPath(), reader);
92 }
93
94 private static String downloadAndGetPath() throws IOException {
95 final File dataset = DataUtils.getDataLocation(DATA_ZIP);
96
97 if (!(dataset.exists())) {
98 dataset.getParentFile().mkdirs();
99 FileUtils.copyURLToFile(new URL(DATA_DOWNLOAD_URL), dataset);
100 }
101
102 return "zip:file:" + dataset.toString();
103 }
104
105 }