Computer Science, asked by keshika1, 1 year ago

write a python code for face recgonization

Answers

Answered by ramesh87901
1
main.py

from itertools import izip
from PIL import Image
def compare(self,pic):
i1 = Image.open("pic1.jpg")
i2 = Image.open(pic)
size = i1.size
i2 = i2.resize(size)
assert i1.mode == i2.mode, "Different kinds of images."
assert i1.size == i2.size, "Different sizes."

pairs = izip(i1.getdata(), i2.getdata())
if len(i1.getbands()) == 1:
# for gray-scale jpegs
dif = sum(abs(p1-p2) for p1,p2 in pairs)
else:
dif = sum(abs(c1-c2) for p1,p2 in pairs for c1,c2 in zip(p1,p2))
ncomponents = i1.size[0] * i1.size[1] * 3
print ((dif / 255.0 * 100) / ncomponents)
return (dif / 255.0 * 100) / ncomponents

def password(self):
import passw
y=str(self.password_input.text)
x=passw.verify(y)
if x == True:
try:
os.startfile("recog.py")
import time
time.sleep(6)
x = self.compare("security.jpg")
if x <= 30:
os.remove("pic1.jpg")
os.rename("security.jpg","pic1.jpg")
return True
else:
raise ValueError
except ValueError, e:
print(e)
sf=open('secure.txt','w')
sf.write("")
sf.close()
if os.path.exists("securitylog.jpg"):
from datetime import datetime, date, time
dt = datetime.today()
t=dt.strftime("%A, %d. %B %Y %H:%M %p")
t='{0:%H:%M }'.format(dt)
f='{0:%A}, {0:%d} of {0:%B}, {0:%Y}.'.format(dt)
timed=(("Date: ",f,"\nTime: ",t))
timed=''.join(timed)
sf=open('secure.txt','a')
sf.write(timed)
sf.close()
kl=Thread(target=self.say, args="You are not authorized to access this program.")
kl.start()
p = Wrong()
p.open()
else:
os.rename("security.jpg","securitylog.jpg")

else:
sf=open('secure.txt','w')
sf.write("")
sf.close()
if os.path.exists("securitylog.jpg"):
from datetime import datetime, date, time
dt = datetime.today()
t=dt.strftime("%A, %d. %B %Y %H:%M %p")
t='{0:%H:%M }'.format(dt)
f='{0:%A}, {0:%d} of {0:%B}, {0:%Y}.'.format(dt)
timed=(("Date: ",f,"\nTime: ",t))
timed=''.join(timed)
sf=open('secure.txt','a')
sf.write(timed)
sf.close()
kl=Thread(target=self.say, args="You are not authorized to access this program.")
kl.start()
p = Wrong()
p.open()
else:
os.rename("security.jpg","securitylog.jpg")


passw.py:

from passlib.hash import sha256_crypt
import onetimepad
def verify(string):
y=string
key=y[-2:]
enc=onetimepad.encrypt(y,key)
x=sha256_crypt.verify(enc,'')
return x
def main():
x=raw_input("Enter Password: ")
print verify(x)

if __name__ =="__main__":
main()

keshika1: thank you
Answered by pjgaikar06
0

Answer:

The following code and attached file is python code for "Human Face Detector".

Attachments:
Similar questions