示例#1
0
def lstTo137( lst, res = None ):
    """
        Convert the entire minutiae-table to the 9.137 field format.
        
        :param lst: List of minutiae
        :type lst: list of lists
        
        :param format: Format of the minutiae
        :type format: str
        
        :return: 9.012 field
        :rtype: str
        
        Usage:
            
            >>> from NIST.fingerprint.functions import lstTo137
            >>> lstTo137(
            ...    [[  1,  7.85,  7.05, 290, 0, 100 ], 
            ...     [  2, 13.80, 15.30, 155, 0, 100 ], 
            ...     [  3, 11.46, 22.32, 224, 0, 100 ], 
            ...     [  4, 22.61, 25.17, 194, 0, 100 ], 
            ...     [  5,  6.97,  8.48, 153, 0, 100 ], 
            ...     [  6, 12.58, 19.88, 346, 0, 100 ], 
            ...     [  7, 19.69, 19.80, 111, 0, 100 ], 
            ...     [  8, 12.31,  3.87, 147, 0, 100 ], 
            ...     [  9, 13.88, 14.29, 330, 0, 100 ], 
            ...     [ 10, 15.47, 22.49, 271, 0, 100 ]],
            ...    500
            ... )
            '1\\x1f154\\x1f138\\x1f290\\x1f0\\x1f100\\x1e2\\x1f271\\x1f301\\x1f155\\x1f0\\x1f100\\x1e3\\x1f225\\x1f439\\x1f224\\x1f0\\x1f100\\x1e4\\x1f445\\x1f495\\x1f194\\x1f0\\x1f100\\x1e5\\x1f137\\x1f166\\x1f153\\x1f0\\x1f100\\x1e6\\x1f247\\x1f391\\x1f346\\x1f0\\x1f100\\x1e7\\x1f387\\x1f389\\x1f111\\x1f0\\x1f100\\x1e8\\x1f242\\x1f76\\x1f147\\x1f0\\x1f100\\x1e9\\x1f273\\x1f281\\x1f330\\x1f0\\x1f100\\x1e10\\x1f304\\x1f442\\x1f271\\x1f0\\x1f100'
    """
    
    if float in map( type, flatten( lst ) ) or res:
        lst = [
            [ id, mm2px( x , res ), mm2px( y, res ), theta, q, d ]
            for id, x, y, theta, q, d in lst
        ]
    
    lst = map_r( int, lst )
    
    return join_r( [ US, RS ], lst )
示例#2
0
def lstTo012(lst, format=None):
    """
        Convert the entire minutiae-table to the 9.012 field format.
        
        :param lst: List of minutiae
        :type lst: list of lists
        
        :param format: Format of the minutiae
        :type format: str
        
        :return: 9.012 field
        :rtype: str
        
        Usage:
            
            >>> from NIST.fingerprint.functions import lstTo012
            >>> lstTo012(
            ...    [[  1,  7.85,  7.05, 290, 0, 'A' ],
            ...     [  2, 13.80, 15.30, 155, 0, 'A' ],
            ...     [  3, 11.46, 22.32, 224, 0, 'A' ],
            ...     [  4, 22.61, 25.17, 194, 0, 'A' ],
            ...     [  5,  6.97,  8.48, 153, 0, 'A' ],
            ...     [  6, 12.58, 19.88, 346, 0, 'A' ],
            ...     [  7, 19.69, 19.80, 111, 0, 'A' ],
            ...     [  8, 12.31,  3.87, 147, 0, 'A' ],
            ...     [  9, 13.88, 14.29, 330, 0, 'A' ],
            ...     [ 10, 15.47, 22.49, 271, 0, 'A' ]]
            ... )
            '1\\x1f07850705290\\x1f0\\x1fA\\x1e2\\x1f13801530155\\x1f0\\x1fA\\x1e3\\x1f11462232224\\x1f0\\x1fA\\x1e4\\x1f22612517194\\x1f0\\x1fA\\x1e5\\x1f06970848153\\x1f0\\x1fA\\x1e6\\x1f12581988346\\x1f0\\x1fA\\x1e7\\x1f19691980111\\x1f0\\x1fA\\x1e8\\x1f12310387147\\x1f0\\x1fA\\x1e9\\x1f13881429330\\x1f0\\x1fA\\x1e10\\x1f15472249271\\x1f0\\x1fA'
            
        The conversion can be done with a list of ( x, y, theta ) coordinates.
        The quality will be set to '00' (expert) and the type to 'A' (Ridge
        ending) for compatibility with most of the AFIS (the type 'D' (Type
        undetermined) is not always well supported).
            
            >>> lstTo012(
            ...    [[  7.85,  7.05, 290 ], 
            ...     [ 13.80, 15.30, 155 ], 
            ...     [ 11.46, 22.32, 224 ], 
            ...     [ 22.61, 25.17, 194 ], 
            ...     [  6.97,  8.48, 153 ], 
            ...     [ 12.58, 19.88, 346 ], 
            ...     [ 19.69, 19.80, 111 ], 
            ...     [ 12.31,  3.87, 147 ], 
            ...     [ 13.88, 14.29, 330 ], 
            ...     [ 15.47, 22.49, 271 ]], 
            ...    format = "xyt"
            ... )
            '1\\x1f07850705290\\x1f00\\x1fA\\x1e2\\x1f13801530155\\x1f00\\x1fA\\x1e3\\x1f11462232224\\x1f00\\x1fA\\x1e4\\x1f22612517194\\x1f00\\x1fA\\x1e5\\x1f06970848153\\x1f00\\x1fA\\x1e6\\x1f12581988346\\x1f00\\x1fA\\x1e7\\x1f19691980111\\x1f00\\x1fA\\x1e8\\x1f12310387147\\x1f00\\x1fA\\x1e9\\x1f13881429330\\x1f00\\x1fA\\x1e10\\x1f15472249271\\x1f00\\x1fA'
            
            >>> lstTo012( [] )
            ''
        
        This function can not be called with no parameter:
        
            >>> lstTo012( None )
            Traceback (most recent call last):
            ...
            notImplemented
    """
    if isinstance(lst, list):
        tmp = AnnotationList()
        tmp.from_list(lst, format=format, type='Minutia')
        lst = tmp

    if isinstance(lst, AnnotationList):
        if len(lst) == 0:
            return ""

        else:
            try:
                ret = [[
                    m.i,
                    "%04d%04d%03d" %
                    (round(float(m.x) * 100), round(float(m.y) * 100), m.t),
                    m.q, m.d
                ] for m in lst]

            except:
                ret = []
                i = 1
                for m in lst:
                    ret.append([
                        i,
                        "%04d%04d%03d" % (round(
                            float(m.x) * 100), round(float(m.y) * 100), m.t),
                        '00', 'A'
                    ])
                    i += 1

            return join_r([US, RS], ret)

    else:
        raise notImplemented
示例#3
0
    def set_pairing(self, pairing=None, idc=-1, **options):
        """
            Function to set the pairing information in the User-defined field
            9.225. The pairing information is stored as following:
            
                minutia id <US> minutia name <RS> ...
                
            :param pairing: Pairing information.
            :type pairing: AnnotationList
            
            Let the pairing information be defined as follow:
                
                >>> from NIST.fingerprint.functions import AnnotationList
                >>> data = [
                ...     ( '1', '1' ), # Minutiae '1' nammed '1'
                ...     ( '2', '2' ), # Minutiae '2' nammed '2'
                ...     ( '3', '3' )  # Minutiae '3' nammed '3'
                ... ]
                
            The pairing is set as follow:
            
                >>> mark2 = mark.get()
                >>> mark2.set_pairing( data )
            
            The pairing can also be set with an AnnotationList object:
            
                >>> pairing = AnnotationList()
                >>> pairing.from_list( data, format = "in", type = "Pairing" )
                >>> pairing # doctest: +NORMALIZE_WHITESPACE
                [
                    Pairing( i='1', n='1' ),
                    Pairing( i='2', n='2' ),
                    Pairing( i='3', n='3' )
                ]
            
            The pairing is set as follow:
                
                >>> mark2.set_pairing( pairing )
        """
        if pairing != None:

            def n():
                return None

            pai = defaultdict(n)
            for p in pairing:
                try:
                    if isinstance(p, Annotation):
                        i, n = p.i, p.n
                    else:
                        i, n = p

                    pai[int(i)] = int(n)

                except:
                    continue

            lst = []
            for m in self.get_minutiae():
                lst.append((m.i, pai[int(m.i)]))

            self.set_field("9.225", join_r([US, RS], lst), idc)