File tree 1 file changed +16
-4
lines changed
1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -154,13 +154,25 @@ def enroll_finger(location):
154
154
155
155
def save_fingerprint_image (filename ):
156
156
"""Scan fingerprint then save image to filename."""
157
- while finger .get_image ():
158
- pass
157
+ print ("Place finger on sensor..." , end = "" , flush = True )
158
+ while True :
159
+ i = finger .get_image ()
160
+ if i == adafruit_fingerprint .OK :
161
+ print ("Image taken" )
162
+ break
163
+ if i == adafruit_fingerprint .NOFINGER :
164
+ print ("." , end = "" , flush = True )
165
+ elif i == adafruit_fingerprint .IMAGEFAIL :
166
+ print ("Imaging error" )
167
+ return False
168
+ else :
169
+ print ("Other error" )
170
+ return False
159
171
160
172
# let PIL take care of the image headers and file structure
161
173
from PIL import Image # pylint: disable=import-outside-toplevel
162
174
163
- img = Image .new ("L" , (256 , 288 ), "white" )
175
+ img = Image .new ("L" , (192 , 192 ), "white" )
164
176
pixeldata = img .load ()
165
177
mask = 0b00001111
166
178
result = finger .get_fpdata (sensorbuffer = "image" )
@@ -178,7 +190,7 @@ def save_fingerprint_image(filename):
178
190
pixeldata [x , y ] = (int (result [i ]) >> 4 ) * 17
179
191
x += 1
180
192
pixeldata [x , y ] = (int (result [i ]) & mask ) * 17
181
- if x == 255 :
193
+ if x == 191 :
182
194
x = 0
183
195
y += 1
184
196
else :
You can’t perform that action at this time.
0 commit comments