Example #1
0
 def add_LQMetric_data( self, lst, idc = -1 ):
     """
         Add the ULW LQMetric for each Annotation passed in parameter.
         The LQMetric is evaluated from the quality map stored in the
         NIST object (in the field 9.308). 
     """
     if len( lst ) != 0:
         # Add the LQMetric quality 
         qmap = self.get_field( "9.308" )
         
         if qmap != None:
             qmap = map( list, split( RS, qmap ) )
             
             h = self.get_height( idc )
             res = self.get_resolution( idc )
             
             for m in lst:
                 coo = cooNIST2PIL( ( m.x, m.y ), h, res )
                 x, y = map_r( lambda x: int( x / ( 4 * res / 500.0 ) ), coo )
                 try:
                     m.LQM = int( qmap[ y ][ x ] )
                 except:
                     m.LQM = None
             
             newformat = list( lst[ 0 ]._format )
             if "LQM" not in newformat:
                 newformat.append( "LQM" )
             
             lst.set_format( newformat )
         
     return lst
Example #2
0
    def process_fileContent(self, data):
        """
            Function to process the 1.003 field passed in parameter.
            
            :param data: Content of the field 1.003.
            :type data: str
            
            :return: List of ntypes present in the NIST file, except the Type01.
            :rtype: lst
            
            Usage:
            
                >>> fileContent = n.get_field( "1.003" )
                >>> n.process_fileContent( fileContent )
                [2]
        """
        try:
            data = map(lambda x: map(int, x.split(US)), data.split(RS))
        except:
            data = replace_r(split_r([RS, US], data), '', '1')
            data = map_r(int, data)

        self.nbLogicalRecords = data[0][1]

        return [ntype for ntype, idc in data[1:]]
Example #3
0
 def add_LQMetric_data( self, lst, idc = -1 ):
     """
         Add the ULW LQMetric for each Annotation passed in parameter.
         The LQMetric is evaluated from the quality map stored in the
         NIST object (in the field 9.308). 
     """
     if len( lst ) != 0:
         # Add the LQMetric quality 
         qmap = self.get_field( "9.308" )
         
         if qmap != None:
             try:
                 gridSize, compression = self.get_field( "9.309", idc ).split( US )
             except:
                 gridSize, compression = 20, "UNC"
             
             qmap = split( RS, qmap )
             if compression == 'RLE':
                 qmap = RLE_decode( qmap )
             
             qmap = map( list, qmap )
             
             h = self.get_height( idc )
             res = self.get_resolution( idc )
             fac = int( round( int( gridSize ) / 100 * self.get_resolution( idc ) / 25.4 ) )
             
             for m in lst:
                 coo = cooNIST2PIL( ( m.x, m.y ), h, res )
                 x, y = map_r( lambda x: int( x / fac ), coo )
                 try:
                     m.LQM = int( qmap[ y ][ x ] )
                 except:
                     m.LQM = None
             
             newformat = list( lst[ 0 ]._format )
             if "LQM" not in newformat:
                 newformat.append( "LQM" )
             
             lst.set_format( newformat )
         
     return lst
Example #4
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 )