├── positive_015.pgm ├── positive_016.pgm ├── positive_017.pgm ├── positive_018.pgm ├── positive_019.pgm ├── positive_020.pgm ├── positive_021.pgm ├── positive_022.pgm ├── positive_023.pgm ├── positive_024.pgm ├── positive_025.pgm ├── positive_026.pgm ├── positive_027.pgm ├── positive_028.pgm ├── positive_029.pgm ├── imgs ├── positive_000.pgm ├── positive_001.pgm ├── positive_002.pgm ├── positive_003.pgm ├── positive_004.pgm ├── positive_005.pgm ├── positive_006.pgm ├── positive_007.pgm ├── positive_008.pgm ├── positive_009.pgm ├── positive_010.pgm ├── positive_011.pgm ├── positive_012.pgm ├── positive_013.pgm ├── positive_014.pgm ├── positive_015.pgm ├── positive_016.pgm ├── positive_017.pgm ├── positive_018.pgm ├── positive_019.pgm ├── positive_020.pgm ├── positive_021.pgm ├── positive_022.pgm ├── positive_023.pgm ├── positive_024.pgm ├── positive_025.pgm ├── positive_026.pgm ├── positive_027.pgm ├── positive_028.pgm ├── positive_029.pgm ├── positive_030.pgm ├── positive_031.pgm ├── positive_032.pgm ├── positive_033.pgm ├── positive_034.pgm ├── positive_035.pgm ├── positive_036.pgm ├── positive_037.pgm ├── positive_038.pgm ├── positive_039.pgm ├── positive_040.pgm ├── positive_041.pgm ├── positive_042.pgm ├── positive_043.pgm ├── positive_044.pgm ├── positive_045.pgm ├── positive_046.pgm ├── positive_047.pgm ├── positive_048.pgm └── positive_049.pgm ├── training ├── positive_000 │ ├── 000.pgm │ ├── 001.pgm │ ├── 002.pgm │ ├── 003.pgm │ ├── 004.pgm │ ├── 005.pgm │ ├── 006.pgm │ ├── 007.pgm │ ├── 008.pgm │ ├── 009.pgm │ └── 010.pgm ├── positive_001 │ ├── 000.pgm │ ├── 001.pgm │ ├── 002.pgm │ ├── 003.pgm │ ├── 004.pgm │ ├── 005.pgm │ ├── 006.pgm │ ├── 007.pgm │ ├── 008.pgm │ ├── 009.pgm │ └── 010.pgm └── positive_002 │ ├── 000.pgm │ ├── 001.pgm │ ├── 002.pgm │ ├── 003.pgm │ ├── 004.pgm │ ├── 005.pgm │ ├── 006.pgm │ ├── 007.pgm │ └── 008.pgm ├── .gitignore ├── abcd.html ├── leaves.py ├── test.py ├── record.py ├── index.html.save ├── LICENSE ├── Database_1.py ├── face.py ├── install_dependencies.sh ├── database.py ├── README.md ├── config.py ├── facerec.py ├── webcam.py ├── train.py └── capture-positives.py /positive_015.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_015.pgm -------------------------------------------------------------------------------- /positive_016.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_016.pgm -------------------------------------------------------------------------------- /positive_017.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_017.pgm -------------------------------------------------------------------------------- /positive_018.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_018.pgm -------------------------------------------------------------------------------- /positive_019.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_019.pgm -------------------------------------------------------------------------------- /positive_020.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_020.pgm -------------------------------------------------------------------------------- /positive_021.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_021.pgm -------------------------------------------------------------------------------- /positive_022.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_022.pgm -------------------------------------------------------------------------------- /positive_023.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_023.pgm -------------------------------------------------------------------------------- /positive_024.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_024.pgm -------------------------------------------------------------------------------- /positive_025.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_025.pgm -------------------------------------------------------------------------------- /positive_026.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_026.pgm -------------------------------------------------------------------------------- /positive_027.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_027.pgm -------------------------------------------------------------------------------- /positive_028.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_028.pgm -------------------------------------------------------------------------------- /positive_029.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/positive_029.pgm -------------------------------------------------------------------------------- /imgs/positive_000.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_000.pgm -------------------------------------------------------------------------------- /imgs/positive_001.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_001.pgm -------------------------------------------------------------------------------- /imgs/positive_002.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_002.pgm -------------------------------------------------------------------------------- /imgs/positive_003.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_003.pgm -------------------------------------------------------------------------------- /imgs/positive_004.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_004.pgm -------------------------------------------------------------------------------- /imgs/positive_005.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_005.pgm -------------------------------------------------------------------------------- /imgs/positive_006.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_006.pgm -------------------------------------------------------------------------------- /imgs/positive_007.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_007.pgm -------------------------------------------------------------------------------- /imgs/positive_008.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_008.pgm -------------------------------------------------------------------------------- /imgs/positive_009.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_009.pgm -------------------------------------------------------------------------------- /imgs/positive_010.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_010.pgm -------------------------------------------------------------------------------- /imgs/positive_011.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_011.pgm -------------------------------------------------------------------------------- /imgs/positive_012.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_012.pgm -------------------------------------------------------------------------------- /imgs/positive_013.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_013.pgm -------------------------------------------------------------------------------- /imgs/positive_014.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_014.pgm -------------------------------------------------------------------------------- /imgs/positive_015.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_015.pgm -------------------------------------------------------------------------------- /imgs/positive_016.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_016.pgm -------------------------------------------------------------------------------- /imgs/positive_017.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_017.pgm -------------------------------------------------------------------------------- /imgs/positive_018.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_018.pgm -------------------------------------------------------------------------------- /imgs/positive_019.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_019.pgm -------------------------------------------------------------------------------- /imgs/positive_020.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_020.pgm -------------------------------------------------------------------------------- /imgs/positive_021.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_021.pgm -------------------------------------------------------------------------------- /imgs/positive_022.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_022.pgm -------------------------------------------------------------------------------- /imgs/positive_023.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_023.pgm -------------------------------------------------------------------------------- /imgs/positive_024.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_024.pgm -------------------------------------------------------------------------------- /imgs/positive_025.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_025.pgm -------------------------------------------------------------------------------- /imgs/positive_026.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_026.pgm -------------------------------------------------------------------------------- /imgs/positive_027.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_027.pgm -------------------------------------------------------------------------------- /imgs/positive_028.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_028.pgm -------------------------------------------------------------------------------- /imgs/positive_029.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_029.pgm -------------------------------------------------------------------------------- /imgs/positive_030.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_030.pgm -------------------------------------------------------------------------------- /imgs/positive_031.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_031.pgm -------------------------------------------------------------------------------- /imgs/positive_032.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_032.pgm -------------------------------------------------------------------------------- /imgs/positive_033.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_033.pgm -------------------------------------------------------------------------------- /imgs/positive_034.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_034.pgm -------------------------------------------------------------------------------- /imgs/positive_035.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_035.pgm -------------------------------------------------------------------------------- /imgs/positive_036.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_036.pgm -------------------------------------------------------------------------------- /imgs/positive_037.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_037.pgm -------------------------------------------------------------------------------- /imgs/positive_038.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_038.pgm -------------------------------------------------------------------------------- /imgs/positive_039.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_039.pgm -------------------------------------------------------------------------------- /imgs/positive_040.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_040.pgm -------------------------------------------------------------------------------- /imgs/positive_041.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_041.pgm -------------------------------------------------------------------------------- /imgs/positive_042.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_042.pgm -------------------------------------------------------------------------------- /imgs/positive_043.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_043.pgm -------------------------------------------------------------------------------- /imgs/positive_044.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_044.pgm -------------------------------------------------------------------------------- /imgs/positive_045.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_045.pgm -------------------------------------------------------------------------------- /imgs/positive_046.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_046.pgm -------------------------------------------------------------------------------- /imgs/positive_047.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_047.pgm -------------------------------------------------------------------------------- /imgs/positive_048.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_048.pgm -------------------------------------------------------------------------------- /imgs/positive_049.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/imgs/positive_049.pgm -------------------------------------------------------------------------------- /training/positive_000/000.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_000/000.pgm -------------------------------------------------------------------------------- /training/positive_000/001.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_000/001.pgm -------------------------------------------------------------------------------- /training/positive_000/002.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_000/002.pgm -------------------------------------------------------------------------------- /training/positive_000/003.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_000/003.pgm -------------------------------------------------------------------------------- /training/positive_000/004.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_000/004.pgm -------------------------------------------------------------------------------- /training/positive_000/005.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_000/005.pgm -------------------------------------------------------------------------------- /training/positive_000/006.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_000/006.pgm -------------------------------------------------------------------------------- /training/positive_000/007.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_000/007.pgm -------------------------------------------------------------------------------- /training/positive_000/008.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_000/008.pgm -------------------------------------------------------------------------------- /training/positive_000/009.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_000/009.pgm -------------------------------------------------------------------------------- /training/positive_000/010.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_000/010.pgm -------------------------------------------------------------------------------- /training/positive_001/000.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_001/000.pgm -------------------------------------------------------------------------------- /training/positive_001/001.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_001/001.pgm -------------------------------------------------------------------------------- /training/positive_001/002.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_001/002.pgm -------------------------------------------------------------------------------- /training/positive_001/003.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_001/003.pgm -------------------------------------------------------------------------------- /training/positive_001/004.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_001/004.pgm -------------------------------------------------------------------------------- /training/positive_001/005.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_001/005.pgm -------------------------------------------------------------------------------- /training/positive_001/006.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_001/006.pgm -------------------------------------------------------------------------------- /training/positive_001/007.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_001/007.pgm -------------------------------------------------------------------------------- /training/positive_001/008.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_001/008.pgm -------------------------------------------------------------------------------- /training/positive_001/009.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_001/009.pgm -------------------------------------------------------------------------------- /training/positive_001/010.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_001/010.pgm -------------------------------------------------------------------------------- /training/positive_002/000.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_002/000.pgm -------------------------------------------------------------------------------- /training/positive_002/001.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_002/001.pgm -------------------------------------------------------------------------------- /training/positive_002/002.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_002/002.pgm -------------------------------------------------------------------------------- /training/positive_002/003.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_002/003.pgm -------------------------------------------------------------------------------- /training/positive_002/004.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_002/004.pgm -------------------------------------------------------------------------------- /training/positive_002/005.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_002/005.pgm -------------------------------------------------------------------------------- /training/positive_002/006.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_002/006.pgm -------------------------------------------------------------------------------- /training/positive_002/007.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_002/007.pgm -------------------------------------------------------------------------------- /training/positive_002/008.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sankaradithyan13/FaceRecognitionPi/HEAD/training/positive_002/008.pgm -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | capture.pgm 3 | training.xml 4 | training/positive 5 | mean.png 6 | negative_eigenface.png 7 | positive_eigenface.png 8 | .DS_Store -------------------------------------------------------------------------------- /abcd.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Processing...

9 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /leaves.py: -------------------------------------------------------------------------------- 1 | import time 2 | import MySQLdb 3 | 4 | result1 = [] 5 | for i in range(6): 6 | result1.append(-1) 7 | db = MySQLdb.connect("localhost", "root", "raspberry", "data") 8 | curs=db.cursor() 9 | curs.execute("CREATE TABLE IF NOT EXISTS leaves (Serial_No INT(5) NOT NULL AUTO_INCREMENT PRIMARY KEY, Id INT(5) NOT NULL , Leaves_assigned INT(5) NOT NULL, Leaves_taken INT(5) NOT NULL, Leaves_Remaining INT(5) NOT NULL)") 10 | curs.execute("SELECT * FROM dates WHERE tdate='%s'" % (time.strftime("%Y-%m-%d"))) 11 | result1=curs.fetchall() 12 | for i in range(len(result1)): 13 | print result1[i][1] 14 | 15 | #if str(result1[len(result1)-1][1]) 16 | db.commit() 17 | print "Data committed" 18 | -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | import time 2 | import MySQLdb 3 | 4 | 5 | if __name__ == '__main__': 6 | label = 0 7 | db = MySQLdb.connect("localhost", "root", "raspberry", "data") 8 | curs=db.cursor() 9 | 10 | curs.execute("CREATE TABLE IF NOT EXISTS dates (Serial_No INT(5) NOT NULL AUTO_INCREMENT PRIMARY KEY, Id INT(5) NOT NULL , Name VARCHAR(20) NOT NULL, tdate DATE NOT NULL , intime TIME NOT NULL, outtime TIME NULL)") 11 | curs.execute("SELECT * FROM record WHERE Id=%s" % (label)) 12 | result=curs.fetchall() 13 | print result 14 | curs.execute("SELECT * FROM dates WHERE Id=%s" % (label)) 15 | result1=curs.fetchall() 16 | print result1 17 | print len(result1) 18 | print result1[1][3] 19 | print result1[0][3] 20 | 21 | -------------------------------------------------------------------------------- /record.py: -------------------------------------------------------------------------------- 1 | import MySQLdb 2 | 3 | db = MySQLdb.connect("localhost", "root", "raspberry", "data") 4 | curs=db.cursor() 5 | try: 6 | curs.execute("CREATE TABLE IF NOT EXISTS record (Serial_No INT(5) NOT NULL AUTO_INCREMENT PRIMARY KEY, Id INT(5) NOT NULL , Name VARCHAR(20) NOT NULL, Folder_Name VARCHAR(20) NOT NULL)") 7 | #curs.execute ("INSERT INTO record (Id,Name) \ 8 | # VALUES ('%d', '%s')"%(0,'Shubham')) 9 | curs.execute ("INSERT INTO record (Id,Name)values(0,'Shubham')") 10 | curs.execute ("INSERT INTO record (Id,Name)values(1,'Sankar')") 11 | curs.execute ("INSERT INTO record (Id,Name)values(2,'Apurv')") 12 | curs.execute ("INSERT INTO record (Id,Name)values(3,'Rahul')") 13 | curs.execute ("INSERT INTO record (Id,Name)values(4,'Kittu')") 14 | print "Data committed" 15 | db.commit() 16 | except: 17 | print "Data Rollback" 18 | db.rollback() 19 | 20 | 21 | -------------------------------------------------------------------------------- /index.html.save: -------------------------------------------------------------------------------- 1 | 2 | 3 | Attendance Record 4 |

Attendance Record

5 |
6 | Employee ID:
7 |
8 | Employee Name:
9 |

10 | 11 |
12 | 13 | 14 | 15 | 16 | Attendance Record 17 |

Attendance Record

18 |
19 | Employee ID:
20 |
21 | Employee Name:
22 |

23 | 24 |
25 | 26 | 27 | 28 | 29 | Attendance Record 30 |

Attendance Record

31 |
32 | Employee ID:
33 |
34 | Employee Name:
35 |

36 | 37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Tony DiCola 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | The negative training data is from the ORL face database. Please see the file 23 | training/negative/README for more information on this data. -------------------------------------------------------------------------------- /Database_1.py: -------------------------------------------------------------------------------- 1 | import time 2 | import MySQLdb 3 | 4 | def data_entry(label): 5 | result1 = [] 6 | for i in range(6): 7 | result1.append(-1) 8 | db = MySQLdb.connect("localhost", "root", "raspberry", "data") 9 | curs=db.cursor() 10 | #try: 11 | curs.execute("CREATE TABLE IF NOT EXISTS dates (Serial_No INT(5) NOT NULL AUTO_INCREMENT PRIMARY KEY, Id INT(5) NOT NULL , Name VARCHAR(20) NOT NULL, tdate DATE NOT NULL , intime TIME NOT NULL, outtime TIME NULL)") 12 | curs.execute("SELECT * FROM record WHERE Id=%s" % (label)) 13 | result=curs.fetchone() 14 | curs.execute("SELECT * FROM dates WHERE Id=%s" % (label)) 15 | result1=curs.fetchall() 16 | if result1 is (): 17 | curs.execute ("INSERT INTO dates (Id,Name,tdate,intime) \ 18 | VALUES ('%d', '%s' , '%s' , '%s')" %(result[1],result[2],time.strftime("%Y-%m-%d"),time.strftime("%H:%M:%S"))) 19 | else: 20 | if str(result1[len(result1)-1][3]) == time.strftime("%Y-%m-%d"): 21 | curs.execute("UPDATE dates SET outtime='%s' WHERE id='%s' && tdate='%s'" % (time.strftime("%H:%M:%S"),label,time.strftime("%Y-%m-%d"))) 22 | else: 23 | curs.execute ("INSERT INTO dates (Id,Name,tdate,intime) \ 24 | VALUES ('%d', '%s' , '%s' , '%s')" %(result[1],result[2],time.strftime("%Y-%m-%d"),time.strftime("%H:%M:%S"))) 25 | 26 | db.commit() 27 | print "Data committed" 28 | #except: 29 | #print "DB rollback" 30 | #db.rollback() 31 | 32 | -------------------------------------------------------------------------------- /face.py: -------------------------------------------------------------------------------- 1 | """Raspberry Pi Face Recognition Treasure Box 2 | Face Detection Helper Functions 3 | Copyright 2013 Tony DiCola 4 | 5 | Functions to help with the detection and cropping of faces. 6 | """ 7 | import cv2 8 | 9 | import config 10 | 11 | 12 | haar_faces = cv2.CascadeClassifier(config.Cascade) 13 | 14 | 15 | def detect_single(image): 16 | """Return bounds (x, y, width, height) of detected face in grayscale image. 17 | If no face or more than one face are detected, None is returned. 18 | """ 19 | faces = haar_faces.detectMultiScale(image, 20 | scaleFactor=config.Scale_Factor, 21 | minNeighbors=config.Min_Neighbors, 22 | minSize=config.Size_of_Adjacent, 23 | flags=cv2.CASCADE_SCALE_IMAGE) 24 | if len(faces) != 1: 25 | return None 26 | return faces[0] 27 | 28 | def crop(image, x, y, w, h): 29 | """Crop box defined by x, y (upper left corner) and w, h (width and height) 30 | to an image with the same aspect ratio as the face training data. Might 31 | return a smaller crop if the box is near the edge of the image. 32 | """ 33 | crop_height = int((config.Face_Height / float(config.Face_Width)) * w) 34 | midy = y + h/2 35 | y1 = max(0, midy-crop_height/2) 36 | y2 = min(image.shape[0]-1, midy+crop_height/2) 37 | return image[y1:y2, x:x+w] 38 | 39 | def resize(image): 40 | """Resize a face image to the proper size for training and detection. 41 | """ 42 | return cv2.resize(image, 43 | (config.Face_Width, config.Face_Height), 44 | interpolation=cv2.INTER_LANCZOS4) 45 | -------------------------------------------------------------------------------- /install_dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Fail script if any command fails. 3 | set -e 4 | 5 | # Check that script is run as root with sudo. 6 | if [ `id -u` -ne 0 ]; then 7 | echo "Must be run as root with sudo! Try:" 8 | echo "sudo ./install_dependencies" 9 | exit 1 10 | fi 11 | 12 | # Check if running wheezy. 13 | if [ `cat /etc/apt/sources.list | grep -c 'jessie'` -eq 0 ] && [ `cat /etc/apt/sources.list | grep -c 'wheezy'` -gt 0 ]; then 14 | # Warn that OS will be upgraded to testing packages. 15 | echo "WARNING: Your operating system will now be upgraded to Raspbian testing/'jessie'" 16 | echo "To be safe, please make sure critical data is backed up before starting." 17 | echo "This process will take about an hour to run." 18 | echo 19 | echo "Type OK and press enter to continue (or anything else to quit):" 20 | read confirm 21 | if [ "$confirm" != "ok" ] && [ "$confirm" != "OK" ]; then 22 | echo "Exiting without performing upgrade." 23 | exit 1 24 | fi 25 | # Upgrade from stable to testing. 26 | cp /etc/apt/sources.list /etc/apt/sources.list.bak 27 | sed -i -e 's/ wheezy/ testing/ig' /etc/apt/sources.list 28 | apt-get update 29 | # First download all upgrade packages. 30 | apt-get -y --download-only dist-upgrade 31 | # Next perform upgrade with no prompts. 32 | DEBIAN_FRONTEND=noninteractive \ 33 | apt-get \ 34 | -o Dpkg::Options::="--force-confnew" \ 35 | --force-yes \ 36 | -fuy \ 37 | dist-upgrade 38 | fi 39 | 40 | # Install dependencies. 41 | apt-get -y install python-pip python-opencv python-dev 42 | pip install picamera 43 | pip install rpio 44 | 45 | echo "Installation complete!" 46 | echo 47 | echo "Make sure to run sudo raspi-config and enable the camera." 48 | -------------------------------------------------------------------------------- /database.py: -------------------------------------------------------------------------------- 1 | import json 2 | import re 3 | import time 4 | import MySQLdb 5 | nonspace =re.compile(r'\S') 6 | 7 | def iterparse(data): 8 | decoder = json.JSONDecoder() 9 | pos=0; 10 | while True: 11 | matched = nonspace.search(data,pos) 12 | if not matched: 13 | break 14 | pos = matched.start() 15 | decoded, pos = decoder.raw_decode(data,pos) 16 | yield decoded 17 | 18 | def data_base(label,count): 19 | date = time.strftime("%d:%m:%y") 20 | name = date + 'a.json' 21 | print name 22 | 23 | with open(name,'a') as out_file: 24 | if label is 0: 25 | data = [{'ID ': label, 'Name' : 'Shubham', 'Time':time.strftime("%H:%M:%S")}] 26 | json.dump(data,out_file,indent=3) 27 | elif label is 1: 28 | data = [{'ID ': label, 'Name' : 'Sankar', 'Time':time.strftime("%H:%M:%S")}] 29 | json.dump(data,out_file,indent=3) 30 | elif label is 2: 31 | data = [{'ID ': label, 'Name' : 'Apurv', 'Time':time.strftime("%H:%M:%S")}] 32 | json.dump(data,out_file,indent=3) 33 | elif label is 3: 34 | data = [{'ID ': label, 'Name' : 'Rahul', 'Time':time.strftime("%H:%M:%S")}] 35 | json.dump(data,out_file,indent=3) 36 | elif label is 4: 37 | data = [{'ID ': label, 'Name' : 'Kirti', 'Time':time.strftime("%H:%M:%S")}] 38 | json.dump(data,out_file,indent=3) 39 | elif label is 5: 40 | data = [{'ID ': label, 'Name' : 'Prof.Lokhande', 'Time':time.strftime("%H:%M:%S")}] 41 | json.dump(data,out_file,indent=3) 42 | 43 | with open(name,'r') as out_file: 44 | out = list(iterparse(out_file.read())) 45 | print out[count] 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Face Recognition Based Attendance System 2 | ========================================== 3 | 4 | Raspberry Pi powered face recognition system using USB Webcam. 5 | 6 | In today’s fast paced world, for an organization with around 500 employees, a manual attendance system is highly inefficient and time consuming. Traditional methods of automatic attendance systems like fingerprint, RFID or iris scans are easy to bypass as the biometric features such systems take into consideration are far less than facial features. Our facial recognition system is used to detect a person’s face and then compare it with the stored facial database to recognize it. Once the face is recognized, his attendance is marked along with his in-time and out-time and stored in a database. This project proposes a system which uses Haar Cascade method for facial detection integrated with Principal Component Analysis (PCA) technology for facial recognition. This whole process is carried out on a Raspberry Pi B+ Module using OpenCV (Open Source Computer Vision) library installed on it. The attendance database is created in MySQL which keeps a record of employee in-time and out-time. Proposed biometric face recognition system is basically used in three domains: employee management, leave management, time attendance system and last but not the least can be used as authorization and access control systems. 7 | 8 | This project has following objectives which are fulfilled using OpenCV: - 9 | 1. Capture the faces to create a database. 10 | 2. Train the recognizer for these faces. 11 | 3. Detect the face in a real time captured image. 12 | 4. Recognize the detected face by comparing with database. 13 | 5. Blink LED to show the user whether valid entry or not. 14 | 6. Store the in-time and out-time of a valid entry. 15 | 7. Link the stored database with a Centralized Server. 16 | 8. Store a copy of the facial data on the server machine using HTTP protocol (TCP socket) which acts as a backup and can be utilized for centralized access. 17 | -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | """Raspberry Pi Face Recognition Attendence System Configuration 2 | Copyright 2016 Aeron System Pvt. Ltd. 3 | """ 4 | # The following values below can be edited to configure the device 5 | # Threshold for the confidence of a recognized face before it's considered a 6 | # positive match. 7 | # but you might need to tweak this value down if 8 | # you're getting too many false positives (incorrectly recognized faces), or up 9 | # if too many false negatives (undetected faces). 10 | 11 | """The confidence of a recognized face before it's considered a positive match should 12 | be lesser than this threshold. Confidence values below this threshold will be considered 13 | a positive match because the lower the confidence value, or distance, the more confident 14 | the algorithm is that the face was correctly detected. 15 | """ 16 | Threshold = 70.0 17 | 18 | # The face recognizer model will be stored and loaded to this file. 19 | Training_Xml = 'training.xml' 20 | 21 | #Subject_Id is used to a holder which contain the subject Id value 22 | Subject_Id = 1 23 | 24 | # Subject_Dir is the directory which contain the subject training image data. 25 | Subject_Dir = './training/' 26 | Image_Dir = './img' 27 | 28 | # Size (in pixels) to resize images for training and prediction. 29 | # Don't change this unless you also change the size of the training images. 30 | Face_Width = 92 31 | Face_Height = 112 32 | 33 | # Face detection cascade classifier configuration. 34 | # You don't need to modify this unless you know what you're doing. 35 | # See: http://docs.opencv.org/modules/objdetect/doc/cascade_classification.html 36 | Cascade = 'haarcascade_frontalface_default.xml' 37 | Scale_Factor = 1.18 38 | Min_Neighbors = 4 39 | Size_of_Adjacent = (30, 30) 40 | 41 | # Filename to use when saving the most recently captured image for debugging. 42 | Recent_Image = 'capture.pgm' 43 | 44 | def get_camera(): 45 | # Use this code for capturing from a webcam: 46 | import webcam 47 | return webcam.OpenCVCapture(device_id=-1) 48 | -------------------------------------------------------------------------------- /facerec.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import glob 3 | import os 4 | import sys 5 | import select 6 | import config 7 | import face 8 | import Database_1 9 | 10 | def is_letter_input(letter): 11 | # Utility function to check if a specific character is available on stdin. 12 | # Comparison is case insensitive. 13 | if select.select([sys.stdin,],[],[],0.0)[0]: 14 | input_char = sys.stdin.read(1) 15 | return input_char.lower() == letter.lower() 16 | return False 17 | 18 | if __name__ == '__main__': 19 | count = 0 20 | 21 | # Load training data into model 22 | print 'Loading training data...' 23 | model = cv2.createLBPHFaceRecognizer() 24 | model.load(config.Training_Xml) 25 | print 'Training data loaded!' 26 | 27 | # Initialize camer and box. 28 | camera = config.get_camera() 29 | 30 | # Move box to locked position. 31 | print 'Running box...' 32 | 33 | #print 'Press button to lock (if unlocked), or unlock if the correct face is detected.' 34 | print 'Press Ctrl-C to quit.' 35 | 36 | while True: 37 | # Check if capture should be made. 38 | # Check if button is pressed. 39 | if is_letter_input('c'): 40 | print 'Button pressed, looking for face...' 41 | 42 | # Check for the positive face and unlock if found. 43 | image = camera.read() 44 | 45 | # Convert image to grayscale. 46 | image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) 47 | 48 | # Get coordinates of single face in captured image. 49 | result = face.detect_single(image) 50 | 51 | if result is None: 52 | print 'Could not detect single face! Check the image in capture.pgm' \ 53 | ' to see what was captured and try again with only one face visible.' 54 | continue 55 | x, y, w, h = result 56 | 57 | # Crop and resize image to face. 58 | crop = face.resize(face.crop(image, x, y, w, h)) 59 | 60 | # Test face against model. 61 | label, confidence = model.predict(crop) 62 | 63 | if confidence < config.Threshold: 64 | print 'Recognized face!' 65 | 66 | else: 67 | print 'Did not recognize face!' 68 | print 'name = {0} with confidence {1}'.format(label,confidence) 69 | Database_1.data_entry(label) 70 | -------------------------------------------------------------------------------- /webcam.py: -------------------------------------------------------------------------------- 1 | """ Copyright 2016 Aeron System Pvt. Ltd. 2 | Webcam device capture class using OpenCV. This class allows you to capture a 3 | single image from the webcam, as if it were a snapshot camera. 4 | This script is used to get the webcam working. The interface is 5 | the same as the picam.py capture class so it can be used in the code 6 | without many changes. 7 | """ 8 | 9 | import threading 10 | import time 11 | 12 | import cv2 13 | 14 | import config 15 | 16 | 17 | # This is the rate at which the webcam will be asked for new images. 18 | CAPTURE_HZ = 30.0 19 | 20 | 21 | class OpenCVCapture(object): 22 | def __init__(self, device_id=0): 23 | """Create an OpenCV capture object associated with the provided webcam 24 | device ID. 25 | """ 26 | # Open the camera. 27 | self._camera = cv2.VideoCapture(device_id) 28 | if not self._camera.isOpened(): 29 | self._camera.open() 30 | # Start a thread to continuously capture frames. 31 | # This must be done because different layers of buffering in the webcam 32 | # and OS drivers will cause you to retrieve old frames if they aren't 33 | # continuously read. 34 | self._capture_frame = None 35 | # Use a lock to prevent access concurrent access to the camera. 36 | self._capture_lock = threading.Lock() 37 | self._capture_thread = threading.Thread(target=self._grab_frames) 38 | self._capture_thread.daemon = True 39 | self._capture_thread.start() 40 | 41 | def _grab_frames(self): 42 | while True: 43 | retval, frame = self._camera.read() 44 | with self._capture_lock: 45 | self._capture_frame = None 46 | if retval: 47 | self._capture_frame = frame 48 | time.sleep(1.0/CAPTURE_HZ) 49 | 50 | def read(self): 51 | """Read a single frame from the camera and return the data as an OpenCV 52 | image (which is a numpy array). 53 | """ 54 | frame = None 55 | with self._capture_lock: 56 | frame = self._capture_frame 57 | # If there are problems, keep retrying until an image can be read. 58 | while frame == None: 59 | time.sleep(0) 60 | with self._capture_lock: 61 | frame = self._capture_frame 62 | # Save captured image for debugging. 63 | cv2.imwrite(config.Recent_Image, frame) 64 | # Return the capture image data. 65 | return frame 66 | -------------------------------------------------------------------------------- /train.py: -------------------------------------------------------------------------------- 1 | import fnmatch 2 | import os 3 | 4 | import cv2 5 | import numpy as np 6 | 7 | import config 8 | import face 9 | 10 | 11 | Mean = 'mean.png' 12 | Positive_Eigenface = 'positive_eigenface.png' 13 | Negative_Eigenface = 'negative_eigenface.png' 14 | 15 | def walk_files(directory, match='*'): 16 | """Generator function to iterate through all files in a directory recursively 17 | which match the given filename match parameter. 18 | """ 19 | for root, dirs, files in os.walk(directory): 20 | for filename in fnmatch.filter(files, match): 21 | yield os.path.join(root, filename) 22 | 23 | def prepare_image(filename): 24 | """Read an image as grayscale and resize it to the appropriate size for 25 | training the face recognition model. 26 | """ 27 | return face.resize(cv2.imread(filename, cv2.IMREAD_GRAYSCALE)) 28 | 29 | def normalize(X, low, high, dtype=None): 30 | """Normalizes a given array in X to a value between low and high. 31 | Adapted from python OpenCV face recognition example at: 32 | https://github.com/Itseez/opencv/blob/2.4/samples/python2/facerec_demo.py 33 | """ 34 | X = np.asarray(X) 35 | minX, maxX = np.min(X), np.max(X) 36 | # normalize to [0...1]. 37 | X = X - float(minX) 38 | X = X / float((maxX - minX)) 39 | # scale to [low...high]. 40 | X = X * (high-low) 41 | X = X + low 42 | if dtype is None: 43 | return np.asarray(X) 44 | return np.asarray(X, dtype=dtype) 45 | 46 | if __name__ == '__main__': 47 | print "Reading training images..." 48 | faces = [] 49 | labels = [] 50 | pos_count = 0 51 | neg_count = 0 52 | # Read all positive images 53 | for filename in walk_files(config.Subject_Dir, '*.pgm'): 54 | faces.append(prepare_image(filename)) 55 | directory = os.path.dirname(filename) 56 | Positive_Label = int(os.path.split(directory)[1].replace("positive_","")) 57 | labels.append(Positive_Label) 58 | pos_count += 1 59 | print 'label = {0} filename = {1}'.format(Positive_Label,filename) 60 | #POSITIVE_LABEL += 1 61 | # Read all negative images 62 | #for filename in walk_files(config.NEGATIVE_DIR, '*.pgm'): 63 | # faces.append(prepare_image(filename)) 64 | # labels.append(config.NEGATIVE_LABEL) 65 | # neg_count += 1 66 | print 'Read', pos_count, 'positive images and', pos_count/10 , 'Subjects' 67 | 68 | # Training of the Attendence System 69 | print 'Training model...' 70 | model = cv2.createLBPHFaceRecognizer() 71 | model.train(np.asarray(faces), np.asarray(labels)) 72 | 73 | # Save the trained Attendence System 74 | model.save(config.Training_Xml) 75 | print 'Training data saved to', config.Training_Xml 76 | -------------------------------------------------------------------------------- /capture-positives.py: -------------------------------------------------------------------------------- 1 | """Raspberry Pi Face Recognition Treasure Box 2 | Positive Image Capture Script 3 | Copyright 2013 Tony DiCola 4 | 5 | Run this script to capture positive images for training the face recognizer. 6 | """ 7 | import glob 8 | import os 9 | import sys 10 | import select 11 | import fnmatch 12 | import cv2 13 | import config 14 | import face 15 | 16 | # Prefix for positive training image filenames. 17 | Filename = 'positive_' 18 | 19 | def prepare_image(filename): 20 | """Read an image as grayscale and resize it to the appropriate size for 21 | training the face recognition model. 22 | """ 23 | return face.resize(cv2.imread(filename, cv2.IMREAD_GRAYSCALE)) 24 | 25 | def is_letter_input(letter): 26 | # Utility function to check if a specific character is available on stdin. 27 | # Comparison is case insensitive. 28 | if select.select([sys.stdin,],[],[],0.0)[0]: 29 | input_char = sys.stdin.read(1) 30 | return input_char.lower() == letter.lower() 31 | return False 32 | 33 | 34 | if __name__ == '__main__': 35 | image = [] 36 | camera = config.get_camera() 37 | 38 | # Create the directory for positive training images if it doesn't exist. 39 | if not os.path.exists(config.Subject_Dir): 40 | os.makedirs(config.Subject_Dir) 41 | foldername = os.path.join(config.Subject_Dir, Filename + '%03d' % (config.Subject_Id) 42 | 43 | # Create the folder for specificEemployee ID training images if it doesn't exist. 44 | if not os.path.exists(foldername): 45 | os.makedirs(foldername) 46 | 47 | # Find the largest ID of existing images. 48 | # Start new images after this ID value. 49 | files = sorted(glob.glob(os.path.join(foldername,'[0-9][0-9][0-9]' + '.pgm'))) 50 | count = 0 51 | 52 | if len(files) > 0: 53 | # Grab the count from the last filename. 54 | count = int(files[-1][-7:-4])+1 55 | print 'Capturing positive training images.' 56 | print 'Press button or type c (and press enter) to capture an image.' 57 | print 'Press Ctrl-C to quit.' 58 | 59 | while True: 60 | # Check if button was pressed or 'c' was received, then capture image. 61 | if is_letter_input('c'): 62 | print 'Capturing image...' 63 | 64 | #image = cv2.imread(filename) 65 | image = camera.read() 66 | 67 | # Convert image to grayscale. 68 | image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) 69 | 70 | # Get coordinates of single face in captured image. 71 | result = face.detect_single(image) 72 | 73 | if result is None: 74 | print 'Could not detect single face! Check the image in capture.pgm' \ 75 | ' to see what was captured and try again with only one face visible.' 76 | continue 77 | x, y, w, h = result 78 | # Crop image as close as possible to desired face aspect ratio. 79 | # Might be smaller if face is near edge of image. 80 | crop = face.crop(image, x, y, w, h) 81 | # Save image to file. 82 | filename = os.path.join(foldername,'%03d.pgm' % count) 83 | cv2.imwrite(filename, crop) 84 | print 'Found face and wrote training image', filename 85 | count += 1 86 | --------------------------------------------------------------------------------