Face Registration is integrated with Database.
							
								
								
									
										10
									
								
								DBHelper.py
									
										
									
									
									
								
							
							
						
						| 
						 | 
					@ -100,13 +100,13 @@ def get_address(user_id):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Uploads the photo of user, input should be something like "example.png"
 | 
					# Uploads the photo of user, input should be something like "example.png"
 | 
				
			||||||
def upload_user_photo(user_photo):
 | 
					def upload_user_photo(user_id):
 | 
				
			||||||
    storage.child("Photos_of_Users/" + user_photo).put("Photos_of_Users/" + user_photo)
 | 
					    storage.child("Photos_of_Users/" + user_id).put("Facial_images/face_rec/train/" + user_id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Uploads the photo of thief, input should be something like "example.png"
 | 
					# Uploads the photo of thief, input should be something like "example.png"
 | 
				
			||||||
def upload_thief_photo(user_photo):
 | 
					def upload_thief_photo(thief_id):
 | 
				
			||||||
    storage.child("Photos_of_Thieves/" + user_photo).put("Photos_of_Thieves/" + user_photo)
 | 
					    storage.child("Photos_of_Thieves/" + thief_id).put("Facial_images/face_rec/train/" + thief_id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Downloads the specified user photo.
 | 
					# Downloads the specified user photo.
 | 
				
			||||||
| 
						 | 
					@ -127,3 +127,5 @@ def delete_user_photo(user_photo):
 | 
				
			||||||
# Deletes photo of the specified thief.
 | 
					# Deletes photo of the specified thief.
 | 
				
			||||||
def delete_thief_photo(user_photo):
 | 
					def delete_thief_photo(user_photo):
 | 
				
			||||||
    storage.delete('Photos_of_Thieves/' + user_photo)
 | 
					    storage.delete('Photos_of_Thieves/' + user_photo)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					upload_data("1", "Batuhan", "Basoglu", "bbaso079@uottawa.ca", "6138072241", "257 Lisgar Street")
 | 
				
			||||||
| 
						 | 
					@ -4,30 +4,27 @@ import math
 | 
				
			||||||
import cv2
 | 
					import cv2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
label = "Batuhan_Basoglu"
 | 
					def register_your_face(label):
 | 
				
			||||||
num_cap = 20
 | 
					    num_cap = 20
 | 
				
			||||||
 | 
					
 | 
				
			||||||
path = sys.path[0]+'/Facial_images/face_rec/train/'+label
 | 
					    path = sys.path[0] + '/Facial_images/face_rec/train/' + label
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    folder = os.path.exists(path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
folder = os.path.exists(path)
 | 
					    if not folder:
 | 
				
			||||||
 | 
					 | 
				
			||||||
if not folder:
 | 
					 | 
				
			||||||
        os.makedirs(path)
 | 
					        os.makedirs(path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    cap = cv2.VideoCapture(0)
 | 
				
			||||||
cap = cv2.VideoCapture(0)
 | 
					    c = 0
 | 
				
			||||||
c=0                        
 | 
					    while c < num_cap:
 | 
				
			||||||
while(c < num_cap):
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
        ret, frame = cap.read()
 | 
					        ret, frame = cap.read()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cv2.imshow("capture", frame)
 | 
					        cv2.imshow("capture", frame)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    cv2.imwrite(path+'/'+str(c) + '.jpg', frame) 
 | 
					        cv2.imwrite(path + '/' + str(c) + '.jpg', frame)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    c=c+1
 | 
					        c = c + 1
 | 
				
			||||||
        cv2.waitKey(500)
 | 
					        cv2.waitKey(500)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cap.release()
 | 
					    cap.release()
 | 
				
			||||||
cv2.destroyAllWindows()
 | 
					    cv2.destroyAllWindows()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
		 Before Width: | Height: | Size: 52 KiB  | 
| 
		 Before Width: | Height: | Size: 51 KiB  | 
| 
		 Before Width: | Height: | Size: 52 KiB  | 
| 
		 Before Width: | Height: | Size: 50 KiB  | 
| 
		 Before Width: | Height: | Size: 51 KiB  | 
| 
		 Before Width: | Height: | Size: 51 KiB  | 
| 
		 Before Width: | Height: | Size: 50 KiB  | 
| 
		 Before Width: | Height: | Size: 50 KiB  | 
| 
		 Before Width: | Height: | Size: 50 KiB  | 
| 
		 Before Width: | Height: | Size: 50 KiB  | 
| 
		 Before Width: | Height: | Size: 50 KiB  | 
| 
		 Before Width: | Height: | Size: 50 KiB  | 
| 
		 Before Width: | Height: | Size: 52 KiB  | 
| 
		 Before Width: | Height: | Size: 52 KiB  | 
| 
		 Before Width: | Height: | Size: 51 KiB  | 
| 
		 Before Width: | Height: | Size: 51 KiB  | 
| 
		 Before Width: | Height: | Size: 51 KiB  | 
| 
		 Before Width: | Height: | Size: 51 KiB  | 
| 
		 Before Width: | Height: | Size: 52 KiB  | 
| 
		 Before Width: | Height: | Size: 52 KiB  | 
| 
		 Before Width: | Height: | Size: 80 KiB  | 
| 
		 Before Width: | Height: | Size: 80 KiB  | 
| 
		 Before Width: | Height: | Size: 78 KiB  | 
| 
		 Before Width: | Height: | Size: 78 KiB  | 
| 
		 Before Width: | Height: | Size: 78 KiB  | 
| 
		 Before Width: | Height: | Size: 78 KiB  | 
| 
		 Before Width: | Height: | Size: 78 KiB  | 
| 
		 Before Width: | Height: | Size: 78 KiB  | 
| 
		 Before Width: | Height: | Size: 79 KiB  | 
| 
		 Before Width: | Height: | Size: 79 KiB  | 
| 
		 Before Width: | Height: | Size: 79 KiB  | 
| 
		 Before Width: | Height: | Size: 79 KiB  | 
| 
		 Before Width: | Height: | Size: 77 KiB  | 
| 
		 Before Width: | Height: | Size: 78 KiB  | 
| 
		 Before Width: | Height: | Size: 78 KiB  | 
| 
		 Before Width: | Height: | Size: 79 KiB  | 
| 
		 Before Width: | Height: | Size: 78 KiB  | 
| 
		 Before Width: | Height: | Size: 78 KiB  | 
| 
		 Before Width: | Height: | Size: 78 KiB  | 
| 
		 Before Width: | Height: | Size: 78 KiB  | 
| 
						 | 
					@ -67,7 +67,7 @@ class Motor:
 | 
				
			||||||
        elif userStop=="N":
 | 
					        elif userStop=="N":
 | 
				
			||||||
            return False
 | 
					            return False
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            stop_motor(self)
 | 
					            self.stop_motor(self)
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def start_alarm(self):
 | 
					    def start_alarm(self):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
import DBHelper
 | 
					import DBHelper
 | 
				
			||||||
import Facial_Recognition_Software
 | 
					import Facial_Recognition_Registration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def upload_your_face(firstname, lastname, email, phone, address):
 | 
					def upload_your_face(firstname, lastname, email, phone, address):
 | 
				
			||||||
| 
						 | 
					@ -10,8 +10,12 @@ def upload_your_face(firstname, lastname, email, phone, address):
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        for user in users.each():
 | 
					        for user in users.each():
 | 
				
			||||||
            count += 1
 | 
					            count += 1
 | 
				
			||||||
        DBHelper.upload_data(count, firstname, lastname, email, phone, address)
 | 
					        DBHelper.upload_data("user_" + str(count), firstname, lastname, email, phone, address)
 | 
				
			||||||
 | 
					        Facial_Recognition_Registration.register_your_face("user_" + str(count))
 | 
				
			||||||
 | 
					        for x in range(20):
 | 
				
			||||||
 | 
					            DBHelper.upload_user_photo("user_" + str(count) + "/" + str(x) + ".jpg")
 | 
				
			||||||
    except:
 | 
					    except:
 | 
				
			||||||
        DBHelper.upload_data("1", firstname, lastname, email, phone, address)
 | 
					        DBHelper.upload_data("1", firstname, lastname, email, phone, address)
 | 
				
			||||||
 | 
					        Facial_Recognition_Registration.register_your_face("user_1")
 | 
				
			||||||
 | 
					        for x in range(20):
 | 
				
			||||||
 | 
					            DBHelper.upload_user_photo("user_1/" + str(x) + ".jpg")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||