Skip to content

Commit

Permalink
Add docstrings to pyfprint.Image
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Sandström <[email protected]>
  • Loading branch information
Lukas Sandström committed Jul 1, 2008
1 parent 0ae6585 commit 564bccd
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions pyfprint/pyfprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ def delete_stored_finger(self, finger):
class Minutia(pyf.fp_minutia):
"""A single point of interest in a fingerprint."""
def __init__(self, minutia_ptr, img):
# We need to keep a reference to the image,
# since the pointer we're referring to might
# be free'd otherwise
self.img = img
self.ptr = minutia_ptr
pyf.fp_minutia.__init__(self, minutia_ptr)
Expand Down Expand Up @@ -341,26 +344,42 @@ def rgb_data(self):
"""
return pyf.pyfp_img_get_rgb_data(self._img)

def save_to_file(self, path):
r = pyf.fp_img_save_to_file(self._img, path)
def save_to_file(self, filename):
"""Save the image as a pgm file."""
r = pyf.fp_img_save_to_file(self._img, filename)
if r != 0:
raise "Save failed"

def standardize(self):
"""Normalize orientation and colors of the image."""
pyf.fp_img_standardize(self._img)
self.std = True
self._std = True

def binarize(self):
"""
Return the image converted to a black/white binary image of the print.
The returned Image is a copy of the original. The old image remains
un-binarized.
This will standardize() the image, if it isn't already so.
"""
if self._bin:
return
if not self._std:
self.standardize()
i = pyf.fp_img_binarize(self._img)
if i == None:
raise "Binarize failed"
return Image(img_ptr = i, bin = True)
i = Image(img_ptr = i, bin = True)
i._minutiae = self._minutiae
return i

def minutiae(self):
"""
Return a list of the minutiae found in the image.
This method will fail on a binarized image.
"""
if self._minutiae:
return self._minutiae
if self._bin:
Expand Down

0 comments on commit 564bccd

Please sign in to comment.