(Homework Solution): [Python] [OpenCV] Fingerprint Verification System Implement the fingerprint verification system from

[Python] [OpenCV] Fingerprint Verification System

Implement the fingerprint verification system from skeleton code: drive.google.com/drive/folders/1TsFGjeIbrZ0p4x7unJD6okz4RODctTdf?usp=sharing

FpSegmentator FpMatcher MnMatcher - segment FpSegmentator - enhance: FpEnhancer - extractor MnExtractor - marcher MnMatcher + segment() segmentedlmg, masklmg + match() similarity + match() similarity FpEnhancer MnExtractor - binlmg: Binarizer - skeletonlmg Skeletonizer + enhance enhlmg + extract() MnSet GaborFilterbank - gaborFilters list + filter): filteredlmg OfDetector Binarizer Skeletonizer + detect(): ofMat, oflmg + binarize() binlmg + skeletonize) skeletonlmg GaborFilter

FpSegmentator FpMatcher MnMatcher – segment FpSegmentator – enhance: FpEnhancer – extractor MnExtractor – marcher MnMatcher + segment() segmentedlmg, masklmg + match() similarity + match() similarity FpEnhancer MnExtractor – binlmg: Binarizer – skeletonlmg Skeletonizer + enhance enhlmg + extract() MnSet GaborFilterbank – gaborFilters list + filter): filteredlmg OfDetector Binarizer Skeletonizer + detect(): ofMat, oflmg + binarize() binlmg + skeletonize) skeletonlmg GaborFilter

Expert Answer

answers

Code below uploads finger template to database:

import serial, time, datetime

import struct           #Convert between strings and binary data

import sys

import os

import binascii

import mysql.connector

cnx=mysql.connector.connect(user=’root’,password=”,host=’localhost’,database=’fingerdb’)       # connect to MySql database

cur=cnx.cursor()

#ser = serial.Serial(‘/dev/ttyUSB0’,57600)      # serial communication in Linux

ser = serial.Serial(“COM6”, baudrate=9600, timeout=1)   #serial communication in Windows

pack = [0xef01, 0xffffffff, 0x1]        # Header, Address and Package Identifier

def readPacket():       # Function to read the Acknowledge packet

time.sleep(1)

w = ser.inWaiting()

ret = []

if w >= 9:

s = ser.read(9)         # Partial read to get length

ret.extend(struct.unpack(‘!HIBH’, s))

ln = ret[-1]

time.sleep(1)

w = ser.inWaiting()

if w >= ln:

s = ser.read(ln)

form = ‘!’ + ‘B’ * (ln – 2) + ‘H’       # Specifying byte size

ret.extend(struct.unpack(form, s))

return ret

def readPacket1():      # Function to read the Acknowledge packet

time.sleep(1)

w = ser.inWaiting()

ret = []

form = ‘B’ * 700

s = ser.read(700)

t=binascii.hexlify(s)   # convert to hex

u=t[24:]

cur.execute(“insert into fingertb(name,finger) values(‘%s’,’%s’)” %(name,u) )     # upadate database

cnx.commit()

v=binascii.unhexlify(u)

form1=’B’*688

ret1=[]

ret1.extend(struct.unpack(form1, v))

ret.extend(struct.unpack(form, s))

def writePacket(data):          # Function to write the Command Packet

pack2 = pack + [(len(data) + 2)]

a = sum(pack2[-2:] + data)

pack_str = ‘!HIBH’ + ‘B’ * len(data) + ‘H’

l = pack2 + data + [a]

s = struct.pack(pack_str, *l)

ser.write(s)

def verifyFinger():     # Verify Module?s handshaking password

data = [0x13, 0x0, 0, 0, 0]

writePacket(data)

s = readPacket()

return s[4]

def genImg():   # Detecting finger and store the detected finger image in ImageBuffer

data = [0x1]

writePacket(data)

s = readPacket()

return s[4]

def img2Tz(buf):        # Generate character file from the original finger image in ImageBuffer and store the file in CharBuffer1 or CharBuffer2.

data = [0x2, buf]

writePacket(data)

s = readPacket()

return s[4]

def regModel():         # Combine information of character files from CharBuffer1 and CharBuffer2 and generate a template which is stroed back in both CharBuffer1 and CharBuffer2.

data = [0x5]

writePacket(data)

s = readPacket()

return s[4]

def UpChar(buf):        # Upload the character file or template of CharBuffer1/CharBuffer2 to upper computer

data = [0x8,buf]

writePacket(data)

s = readPacket1()

print (“Type done to exit”)

name=raw_input(“Enter name : “)

while (name!=’done’):

if verifyFinger():

print ‘Verification Error’

sys.exit(0)

print ‘Put finger’,

sys.stdout.flush()

time.sleep(1)

while genImg():

time.sleep(0.1)

print ‘.’,

sys.stdout.flush()

print ”

sys.stdout.flush()

if img2Tz(1):

print ‘Conversion Error’

sys.exit(0)

print ‘Put finger again’,

sys.stdout.flush()

time.sleep(1)

while genImg():

time.sleep(0.1)

print ‘.’,

sys.stdout.flush()

print ”

sys.stdout.flush()

if img2Tz(2):

print ‘Conversion Error’

sys.exit(0)

if regModel():

print ‘Template Error’

sys.exit(0)

if UpChar(2):

print ‘Template Error’

sys.exit(0)

name=raw_input(“Enter name : “)

Code below downloads the finger template from database to R305 fingerprint module:

import serial, time, datetime, struct

import sys

import os

import mysql.connector

import binascii

cnx=mysql.connector.connect(user=’root’,password=”,host=’localhost’,database=’fingerdb’)

cur=cnx.cursor()

ser = serial.Serial(“COM6”, baudrate=9600, timeout=1)

pack = [0xef01, 0xffffffff, 0x1]

def readPacket():

time.sleep(1)

w = ser.inWaiting()

ret = []

if w >= 9:

s = ser.read(9) #partial read to get length

ret.extend(struct.unpack(‘!HIBH’, s))

ln = ret[-1]

time.sleep(1)

w = ser.inWaiting()

if w >= ln:

s = ser.read(ln)

form = ‘!’ + ‘B’ * (ln – 2) + ‘H’

ret.extend(struct.unpack(form, s))

return ret

def readPacket1():

time.sleep(1)

w = ser.inWaiting()

time.sleep(1)

pack_str=’B’* 688

cur.execute(“select finger from fingertb where name=’%s'”%name)

row=cur.fetchone()

srow = str(row[0])

v=binascii.unhexlify(srow)

form1=’B’*688

ret1=[]

ret1.extend(struct.unpack(form1, v))

x=ret1

s = struct.pack(pack_str, *x)

ser.write(s)

if store(idno):

print ‘store error’

sys.exit(0)

print “Enrolled successfully at id %d”%j

def writePacket(data):

pack2 = pack + [(len(data) + 2)]

a = sum(pack2[-2:] + data)

pack_str = ‘!HIBH’ + ‘B’ * len(data) + ‘H’

l = pack2 + data + [a]

s = struct.pack(pack_str, *l)

ser.write(s)

def verifyFinger():

data = [0x13, 0x0, 0, 0, 0]

writePacket(data)

s = readPacket()

return s[4]

def DownChar(buf):      # download character file or template from upper computer to the specified buffer of Module

data = [0x9,buf]

writePacket(data)

s = readPacket1()

def store(id):          # store the template of specified buffer (Buffer1/Buffer2) at the designated location of Flash library

data = [0x6, 0x1, 0x0, id]

writePacket(data)

s = readPacket()

return s[4]

name=raw_input(‘enter the name please’)

idno=int(raw_input(‘enter the store id’))

if verifyFinger():              # Verify Password

print ‘Verification Error’

sys.exit(0)

if DownChar(1):

print ‘Template Error’

sys.exit(0)

Code below scans the finger and authenticates:

import serial, time, datetime, struct

import sys

ser = serial.Serial(“COM6″, baudrate=9600, timeout=1)

pack = [0xef01, 0xffffffff, 0x1]

def readPacket():

time.sleep(1)

w = ser.inWaiting()

ret = []

if w >= 9:

s = ser.read(9)         #partial read to get length

ret.extend(struct.unpack(‘!HIBH’, s))

ln = ret[-1]

time.sleep(1)

w = ser.inWaiting()

if w >= ln:

s = ser.read(ln)

form = ‘!’ + ‘B’ * (ln – 2) + ‘H’

ret.extend(struct.unpack(form, s))

return ret

def writePacket(data):

pack2 = pack + [(len(data) + 2)]

a = sum(pack2[-2:] + data)

pack_str = ‘!HIBH’ + ‘B’ * len(data) + ‘H’

l = pack2 + data + [a]

s = struct.pack(pack_str, *l)

ser.write(s)

def verifyFinger():

data = [0x13, 0x0, 0, 0, 0]

writePacket(data)

s = readPacket()

return s[4]

def genImg():

data = [0x1]

writePacket(data)

s = readPacket()

return s[4]

def img2Tz(buf):

data = [0x2, buf]

writePacket(data)

s = readPacket()

return s[4]

def search():   # search the whole finger library for the template that matches the one in CharBuffer1 or CharBuffer2

data = [0x4, 0x1, 0x0, 0x0, 0x0, 0x5]

writePacket(data)

s = readPacket()

return s[4:-1]

if verifyFinger():

print ‘Verification Error’

sys.exit(-1)

print ‘Put finger’,

sys.stdout.flush()

time.sleep(1)

for _ in range(5):

g = genImg()

if g == 0:

break

print ‘.’,

sys.stdout.flush()

print ”

sys.stdout.flush()

if g != 0:

sys.exit(-1)

if img2Tz(1):

print ‘Conversion Error’

sys.exit(-1)

r = search()

print ‘Search result’, r

if r[0] == 0 :

print ‘Authentication Successful’

sys.exit(0)

else:

print ‘Authentication fail’

sys.exit(1)

iWriteHomework
Order NOW for a 10% Discount
Pages (550 words)
Approximate price: -

Why Us?

Top Quality and Well-Researched Papers

All ourbpapers are written from scratch. In fact, Clients who ask for paraphrasing services are highly discouraged. We have writers ready to craft any paper from scratch and deliver quality ahead of time.

Professional and Experienced Academic Writers

Our writers keeps you posted on your papers progress - providing you with paper outline/draft. You are also at liberty to communicate directly with your writer.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time, in many cases quite ahead of time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents