Skip to main content

No project description provided

Project description

Python driver for fingerprint sensors by Zhiantec - ZFM-20 series

PyPI version PDD status

Is your scanner can be managed by this library?

If your scanner is ZFM-20 or his cheap clone then it possible. I made this library inspired by pyfingerprint, so it may also work with ZFM-60, ZFM-70, ZFM-100, R303 and R305.

Origin manuals

Fingerprint protocol specs are taken from original ZHM-20 user manual.

Terminology

Image

Image is a Fingerprint scanned grayscale image. Image can be scanned and stored in volatile image buffer.

Characteristic

Characteristic is a fingerprint characteristic. It represented by a bytearray. Characteristic can be created from fingerprint image and stored in volatile characteristic buffer.

Template

Template is a registered fingerprint model stored in scanner nonvolatile memory. We can not see or feel the template, we only can ask scanner if characteristic look like some template in scanner memory.

Working with sensor

Handshake

First of all you need make a handshake to verify connection:

with SerialPort(Serial(port='<COM1 or /dev/ttyUSB0>', baudrate=9600 * 6, timeout=2)) as port:
   rq = RqCommand(port)
   rs = RsSimple(port)
   Handshake(rq, rs).make()

As you see you will need to know serial port name of your scanner device. For windows users it may looks like COM1, for unix users it may looks like /dev/ttyUSB0.

Fingerprint image

More complex task - make an image of your fingerprint:

with SerialPort(Serial(port='...', baudrate=9600 * 6, timeout=2)) as port:
    rq = RqCommand(port)
    rs = RsSimple(port)
    print 'Waiting for finger...'
    while not Scan(rq, rs).is_scanned():
        pass
    print 'Finger has been scanned! Downloading the finger image...'
    image = UpImage(rq, rs).image()
    image.show()

Matching characteristics

Another more complex task - match characteristics of two fingerprints. Fingerprint scanner can matching only two fingerprints and it has two buffers for that operation - RqCharBuffer1 and RqCharBuffer2.

with SerialPort(Serial(port='...', baudrate=9600 * 6, timeout=2)) as port:
    rq = RqCommand(port)
    rs = RsSimple(port)
    print 'Wait for finger...'
    while not Scan(rq, rs).is_scanned():
        pass
    Img2Tz(rq, rs, RqCharBuffer1()).execute()

    print 'Once again...'
    while not Scan(rq, rs).is_scanned():
        pass
    Img2Tz(rq, rs, RqCharBuffer2()).execute()

    print 'Score {0}'.format(Match(rq, rs).score())

Enroll fingerprint

Another complex task is enroll a finger.

with SerialPort(Serial(port='...', baudrate=9600 * 6, timeout=2)) as port:
    rq = RqCommand(port)
    rs = RsSimple(port)
    print 'Wait for finger...'
    while not Scan(rq, rs).is_scanned():
        pass

    Img2Tz(rq, rs, RqCharBuffer1()).execute()
    searchResult = Search(rq, rs, start=0, count=TemplateCount(rq, rs).as_int()).execute()

    if searchResult.code() == 0:
        print 'Template already exist'
        exit(1)

    print 'Once again...'
    while not Scan(rq, rs).is_scanned():
        pass

    Img2Tz(rq, rs, RqCharBuffer2()).execute()
    score = Match(rq, rs).score()
    RegModel(rq, rs).execute()
    Store(rq, rs, RqCharBuffer1(), 1).execute()
    print 'Stored success!'

Match fingerprint with it db saved version

with SerialPort(Serial(port='...', baudrate=9600 * 6, timeout=2)) as port:
    rq = RqCommand(port)
    rs = RsSimple(port)
    while not Scan(rq, rs).is_scanned():
        pass
    Img2Tz(rq, rs, RqCharBuffer1()).execute()  # save scanned finger to the buffer 1

    templatesCount = TemplateCount(rq, rs).as_int()  # get all templates count
    searchResult = Search(rq, rs, start=0, count=templatesCount).execute()  # find finger in the db

    if searchResult.code() != 0:
        print('Finger has not been saved!')
    else:
        number = searchResult.number()  # finger index in the db
        print('Finger found in index {0}'.format(number))
        LoadChar(rq, rs, RqCharBuffer2(), number).execute()  # extract original template to the buffer 2

        print('Score {0}'.format(Match(rq, rs).score()))  # Match it!

@todo #1:30m Add deletion enrolled fingers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fpscanner-0.1.1-py2-none-any.whl (55.9 kB view details)

Uploaded Python 2

File details

Details for the file fpscanner-0.1.1-py2-none-any.whl.

File metadata

  • Download URL: fpscanner-0.1.1-py2-none-any.whl
  • Upload date:
  • Size: 55.9 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.3.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.15

File hashes

Hashes for fpscanner-0.1.1-py2-none-any.whl
Algorithm Hash digest
SHA256 325d8aa0570058aa7cdc1bf7fc2764d0aee017146b094ff10e54efd4ee9b212a
MD5 86eb03315339ad2502f34e4485d255a4
BLAKE2b-256 c230f5ca6e6300d13d0f0d970977a086461e42b66ed96c7468f4e9b7ab94cd39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page