コード例 #1
0
ファイル: test_main.py プロジェクト: twfxjjbw/FingerMatch
    def test_trainData(self):
        """
        Tests data loading process.

        """

        fm = FingerMatch('bf')
        fm.loadData(PATH, limit=3)

        fm.trainData()

        for i, img in enumerate(fm.images):
            self.assertIsNotNone(
                img.descriptors,
                msg=
                f'ERROR: Profile not built for the {i}-th image in the class.')
            self.assertNotEqual(
                len(img.descriptors),
                0,
                msg=
                f'ERROR: Profile not built for the {i}-th image in the class.')

        # Test
        path_test = '../data/Fingerprints - Set B/101_1.tif'

        # Image loading
        img_test = load_image(path_test, True)

        scores = fm.matchFingerprint(img_test, verbose=False)
コード例 #2
0
ファイル: test_minutiae.py プロジェクト: twfxjjbw/FingerMatch
    def test_process_minutiae(self):
        # Tests minutiae creation output.

        path = '../../data/Fingerprints - Set A/101_1.tif'
        img = load_image(path, True)
        img = enhance_image(img, padding=5)

        minutiae = process_minutiae(img)

        self.assertIsNotNone(minutiae, msg='ERROR: Wrong output.')
コード例 #3
0
    def test_enhance_image(self):
        # Tests image enhancing output and data loss.

        # Revert gray colour levels. Match scale with the raw image for comparison.
        path = '../../data/Fingerprints - Set A/101_1.tif'

        # Image loading
        img = load_image(path, True)

        img = enhance_image(img, padding=5)
コード例 #4
0
ファイル: test_main.py プロジェクト: twfxjjbw/FingerMatch
    def test_matchFingerprintTree(self):
        """

        """

        path_base = '/Users/Orchestrator/Desktop/Toptal/Fingerprints/dragos-iliuta/data/Others/base'
        path_test = '/Users/Orchestrator/Desktop/Toptal/Fingerprints/dragos-iliuta/data/Others/test'

        fmt = FingerMatch('tree')
        fmt.loadData(path_base, limit=3)
        fmt.trainData()

        # Image loading
        path_test = f'{path_test}/102_2.tif'
        img_test = load_image(path_test, True)

        fmt.matchFingerprint(img_test, verbose=False)
コード例 #5
0
ファイル: test_main.py プロジェクト: twfxjjbw/FingerMatch
    def test_matchFingerprintBF(self):
        """

        """

        path_base = '/Users/Orchestrator/Desktop/Toptal/Fingerprints/dragos-iliuta/data/Others/base'
        path_test = '/Users/Orchestrator/Desktop/Toptal/Fingerprints/dragos-iliuta/data/Others/test'

        fm = FingerMatch('bf')

        fm.loadData(path_base, limit=3)
        fm.trainData()

        # Image loading
        img_test = load_image(f'{path_test}/101_2.tif', True)

        fm.matchFingerprint(img_test, verbose=False)
コード例 #6
0
ファイル: api.py プロジェクト: twfxjjbw/FingerMatch
    def loadData(self,
                 path: str,
                 image_format: str = 'tif',
                 limit: int = None) -> None:
        """
        Load data that matches the image_format, from the given path. Each image is processed and stored.

        """

        img_paths = [glob.glob(f'{path}/*.tif', recursive=True)][0]

        try:
            assert len(img_paths) > 0
        except:
            raise FileNotFoundError(
                f'ERROR: No image files available to extract from the path {path}'
            )

        if limit is not None:
            # Restrict sample size.
            img_paths = img_paths[:limit]

        start = time.time()

        for p in tqdm(img_paths, desc='Loading data.'):
            # Image loading
            image = load_image(p, True)
            image = (image_enhance(image) * 255).astype('uint8')

            try:
                # Image properties definition.
                img_id = re.search(f'(.+?).{image_format}',
                                   os.path.basename(p)).group(1)
            except AttributeError:
                raise Exception(f'ERROR: Unknown image id for {p}')

            # Create new profile for the given image and store it.
            self.images.append(Image(img_id, p, image, None))

        print(
            f'\nINFO: Dataset loaded successfully. Duration: {round(time.time() - start, 2)} sec'
        )
コード例 #7
0
ファイル: test_matching.py プロジェクト: twfxjjbw/FingerMatch
from libs.basics import load_image, display_image
from libs.minutiae import process_minutiae, generate_tuple_profile
from libs.enhancing import enhance_image
from libs.matching import match_tuples, build_edges, edge_matching

import unittest

path_base = '../../data/Fingerprints - Set A/101_2.tif'
path_test = '../../data/Fingerprints - Set A/101_2.tif'

img_base = load_image(path_base, True)
img_base = enhance_image(img_base, padding=5)

img_test = load_image(path_test, True)
img_test = enhance_image(img_test, padding=5)

# Confirmed point matching.
TUPLE_BASE = generate_tuple_profile(process_minutiae(img_base))
TUPLE_TEST = generate_tuple_profile(process_minutiae(img_test))


class TestMatching(unittest.TestCase):
    def test_match_tuples(self):
        # Tests minutiae creation output.

        ccpb_base, ccpb_test = match_tuples(TUPLE_BASE, TUPLE_TEST)

        print('---')

    def test_edge_matching(self):