-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfaint.cfc
138 lines (124 loc) · 4.43 KB
/
faint.cfc
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<cfcomponent output="false">
<cfscript>
variables.tnWidth = 100;
variables.tnHeight = 100;
</cfscript>
<cffunction name="init" output="true">
<cfargument name="tnWidth" type="numeric" required="false" default="#variables.tnWidth#" />
<cfargument name="tnHeight" type="numeric" required="false" default="#variables.tnHeight#" />
<cfscript>
variables.tnWidth = arguments.tnWidth;
variables.tnHeight = arguments.tnHeight;
variables.jTnSize = CreateObject("java", "java.awt.Dimension").init(variables.tnWidth, variables.tnHeight);
variables.jFaint = CreateObject('java', 'de.offis.faint.controller.MainController').getInstance();
variables.dataDir = variables.jFaint.getDataDir();
variables.jDb = jFaint.getFaceDB();
return this;
</cfscript>
</cffunction>
<cffunction name="detectFaces" output="false" returntype="numeric">
<cfargument name="imagePath" type="string" required="true" />
<cfargument name="saveToDb" type="boolean" required="false" default="true" />
<cfscript>
variables.jModel = CreateObject('java', 'de.offis.faint.model.ImageModel').init(arguments.imagePath);
variables.jRegions = variables.jFaint.detectFaces(variables.jModel, JavaCast('boolean', arguments.saveToDb));
if (StructKeyExists(variables, 'jRegions')) {
return ArrayLen(variables.jRegions);
} else {
return 0;
}
</cfscript>
</cffunction>
<cffunction name="getScanWindowSize" output="false" returntype="numeric">
<cfreturn variables.jFaint.getScanWindowSize() />
</cffunction>
<cffunction name="setScanWindowSize" output="false">
<cfargument name="percent" type="numeric" required="true" />
<cfset variables.jFaint.setScanWindowSize(arguments.percent) />
</cffunction>
<cffunction name="saveToDb" output="false">
<cfargument name="faceNum" type="numeric" required="true" />
<cfargument name="faceName" type="string" required="true" />
<cfscript>
variables.jDb.put(variables.jRegions[arguments.faceNum], arguments.faceName);
variables.jDb.writeToDisk();
</cfscript>
</cffunction>
<cffunction name="saveFaceToDb" output="false">
<cfargument name="face" required="true" />
<cfargument name="faceName" type="string" required="true" />
<cfscript>
variables.jDb.put(arguments.face, arguments.faceName);
variables.jDb.writeToDisk();
</cfscript>
</cffunction>
<cffunction name="getFacesFromDb" output="false" returntype="numeric">
<cfargument name="faceName" type="string" required="false" />
<cfscript>
if (StructKeyExists(arguments, 'faceName')) {
variables.jRegions = variables.jDb.getRegionsForFace(arguments.faceName);
} else {
variables.jRegions = variables.jDb.getKnownFaces();
}
if (StructKeyExists(variables, 'jRegions')) {
return ArrayLen(variables.jRegions);
} else {
return 0;
}
</cfscript>
</cffunction>
<cffunction name="getNamesFromDb" output="false">
<cfscript>
var local = {};
local.names = variables.jDb.getExistingAnnotations();
if (StructKeyExists(local, 'names')) {
return local.names;
} else {
return ArrayNew(1);
}
</cfscript>
</cffunction>
<cffunction name="getFace" output="false">
<cfargument name="matchNum" type="numeric" required="false" />
<cfscript>
return variables.jRegions[arguments.matchNum];
</cfscript>
</cffunction>
<cffunction name="getFaces" output="false">
<cfscript>
if (StructKeyExists(variables, 'jRegions')) {
return variables.jRegions;
} else {
return ArrayNew(1);
}
</cfscript>
</cffunction>
<cffunction name="getThumbnail" output="false">
<cfargument name="face" required="true" />
<cfscript>
var local = {};
local.thumbnail = arguments.face.toThumbnail(variables.jTnSize);
return ImageNew(local.thumbnail);
</cfscript>
</cffunction>
<cffunction name="getDataDir" output="false" returntype="string">
<cfreturn variables.dataDir />
</cffunction>
<cffunction name="changeNameInDb" output="false">
<cfargument name="oldName" type="string" required="true" />
<cfargument name="newName" type="string" required="true" />
<cfset variables.jDb.renameAnnotation(arguments.oldName, arguments.newName) />
</cffunction>
<cffunction name="recogniseFace" output="false">
<cfargument name="face" required="true" />
<cfscript>
var local = {};
local.matches = variables.jFaint.recognizeFace(arguments.face);
if (StructKeyExists(local, 'matches')) {
return local.matches;
} else {
return 0;
}
</cfscript>
</cffunction>
</cfcomponent>