Commit 3d9546b
Leandro
Skip the temp-file/JPEG round trip when UseGray is set
AddImageToDataset, RecognizeSingle, and RecognizeMultiples used to
write a grayscale JPEG to a temp file just so go-face could immediately
decode that same JPEG back into pixels. With go-face v1.0.7's
RecognizeRaw (Kagami/go-face#69), the already-decoded, already-grayed
pixels go straight to goFace -- no temp file, no JPEG encode, no JPEG
decode. UseGray=false is unchanged: the file is still handed straight
to go-face, which still requires JPEG (see #45's boundary, already
documented/tested).
createTempGrayFile/tempFileName are gone, replaced by loadPixels
(decode + grayscale + pack into an RGB byte buffer) in image.go, and a
new detect() helper in recognizer.go shared by AddImageToDataset and
RecognizeMultiples (RecognizeSingle keeps its own branch, using
goFace's Single variants directly rather than detecting all faces and
discarding extras, matching its prior performance characteristics).
Verified: full test suite passes under -race, and it got noticeably
faster (~50s -> ~26s) with the temp-file I/O and JPEG round trip gone.
Also re-ran all three examples end-to-end -- faces.jpg/faces2.jpg came
out byte-identical (annotation draws over the original color image, not
the internal recognition path), landmarks.jpg shifted by ordinary
decoder-rounding differences only.1 parent 5f2db5d commit 3d9546b
4 files changed
Lines changed: 65 additions & 77 deletions
Loading
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | 4 | | |
7 | 5 | | |
8 | 6 | | |
| |||
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
14 | | - | |
15 | 12 | | |
16 | 13 | | |
17 | 14 | | |
| |||
79 | 76 | | |
80 | 77 | | |
81 | 78 | | |
82 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
83 | 82 | | |
84 | | - | |
85 | | - | |
86 | | - | |
| 83 | + | |
87 | 84 | | |
88 | 85 | | |
89 | 86 | | |
90 | 87 | | |
91 | | - | |
| 88 | + | |
92 | 89 | | |
93 | 90 | | |
94 | 91 | | |
95 | | - | |
96 | 92 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
101 | 96 | | |
102 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
103 | 107 | | |
104 | | - | |
| 108 | + | |
105 | 109 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | 110 | | |
112 | 111 | | |
113 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
121 | 119 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 120 | + | |
126 | 121 | | |
127 | 122 | | |
128 | 123 | | |
129 | | - | |
130 | | - | |
| 124 | + | |
131 | 125 | | |
132 | | - | |
| 126 | + | |
133 | 127 | | |
134 | 128 | | |
135 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
136 | 133 | | |
137 | 134 | | |
138 | 135 | | |
139 | | - | |
140 | | - | |
141 | 136 | | |
142 | | - | |
143 | | - | |
144 | | - | |
| 137 | + | |
145 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
146 | 155 | | |
147 | 156 | | |
148 | 157 | | |
| |||
199 | 208 | | |
200 | 209 | | |
201 | 210 | | |
202 | | - | |
203 | 211 | | |
204 | 212 | | |
205 | 213 | | |
206 | | - | |
| 214 | + | |
207 | 215 | | |
208 | 216 | | |
209 | 217 | | |
210 | 218 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
215 | 222 | | |
216 | 223 | | |
217 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
218 | 229 | | |
219 | | - | |
| 230 | + | |
220 | 231 | | |
221 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
222 | 237 | | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | 238 | | |
228 | 239 | | |
229 | 240 | | |
| |||
242 | 253 | | |
243 | 254 | | |
244 | 255 | | |
245 | | - | |
246 | 256 | | |
247 | 257 | | |
248 | 258 | | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
| 259 | + | |
271 | 260 | | |
272 | 261 | | |
273 | 262 | | |
| |||
0 commit comments