def set_pairing( self, pairing = None, idc = -1, **options ):
"""
Function to set the pairing information in the User-defined field
9.255. 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.255", join_r( [ US, RS ], lst ), idc )
评论列表
文章目录