-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetector.py
141 lines (108 loc) · 3.86 KB
/
detector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env python
from cv2 import *
import numpy as np
import cgi
import cgitb;cgitb.enable()
import cherrypy
import webbrowser
import os
import subprocess,sys
def cherry():
f = open('face.php','w')
message = '''<html>
<head>
<title> Payment Gateway </title>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="style.css" rel="stylesheet">
<script type="text/javascript">
var auto_refresh = setInterval(function() { submitform(); }, 5000);
function submitform(){
document.getElementById("faceform").submit();
}
</script>
<style>
.amt
{
display:none;
}
.btn {
border-radius:35px;
font-size: 20px;
}
</style>
</head>
<body>
<?php
$txt = 'cardno.txt';
$fh = fopen($txt, 'r');
$cardno = fgets($fh);
fclose($fh);
$txt = 'amount.txt';
$fh = fopen($txt, 'r');
$amount = fgets($fh);
fclose($fh);
$db = mysqli_connect("localhost","root","","project");
$res=mysqli_query($db,"select * from card where cardno = '$cardno'");
while($arr=mysqli_fetch_row($res))
echo "<h1> Hey $arr[1],<br>Wait while we match Face ID...</h1>";
?>
<br>
<form id = "faceform" action="../done.php" method="POST">
<input type="integer" name="amt" class="amt" value="<?php echo "$amount"; ?>" >
<input type="integer" name="cardno" class="amt" value="<?php echo "$cardno"; ?>" >
<div class="col-xs-4 col-md-4">
<div class="form-group">
<input type="password" class="amt" name="pin" id="pin" value="'''+ str(Id) + '''" required />
</div>
</div><br><br><br>
<img type="submit" height="100px" width="100px" src="../loading.gif">
</form>
</body>
</html>'''
f.write(message)
f.close()
url = "http://localhost"
webbrowser.open(url + "/Project/cgi-bin/face.php", new=0)
recognizer = cv2.face.LBPHFaceRecognizer_create()
recognizer.read('trainner/trainer.yml')
cascadePath = "haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(cascadePath);
cam = cv2.VideoCapture(0)
while(cam.isOpened()):
ret, im =cam.read()
if ret:
gray=cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
faces=faceCascade.detectMultiScale(gray, 1.2,5)
for(x,y,w,h) in faces:
Id, conf = recognizer.predict(gray[y:y+h,x:x+w])
if(conf<50):
cam.release()
destroyWindow("im")
cherry()
break;
"""elif(Id==1111):
Id="Kamal"
cam.release()
destroyWindow("im")
cherry()
break;
elif(Id==4444):
Id="Soumya"
cam.release()
destroyWindow("im")
cherry()
break;"""
else:
Id="Unknown"
cam.release()
destroyWindow("im")
cherry()
break;
cv2.imshow('im',im)
if cv2.waitKey(10) & 0xFF==ord('q'):
break
cam.release()
cv2.destroyAllWindows()