def prepare_database(): database = {} # load all the images of individuals to recognize into the database for file in glob.glob("images/*"): identity = os.path.splitext(os.path.basename(file))[0] database[identity] = fr_utils.img_path_to_encoding(file, FRmodel) print( f'prepare_database: file="{file}", identiti="{identity}"') return database
def reload_database(self): self.database = {} # load all the images of individuals to recognize into the database for photo_filename in glob.glob("%s/*" % (self.outputPath)): photo_object = cv2.imread(photo_filename) identity = os.path.splitext(os.path.basename(photo_filename))[0] self.database[identity] = fr_utils.img_path_to_encoding( photo_filename, self.FRmodel)
def get_face_dists(FR_model): face_database = {} for name in os.listdir('images'): for image in os.listdir(os.path.join('images', name)): identity = os.path.splitext(os.path.basename(image))[0] face_database[identity] = fr_utils.img_path_to_encoding( os.path.join('images', name, image), FR_model) print(face_database) return face_database
def myMainMethod(): FRmodel = inception_blocks_v2.faceRecoModel(input_shape=(3, 96, 96)) encoding = fr_utils.img_path_to_encoding("crop_frame.jpg", FRmodel) print(encoding)
# minNeighbors=5, # minSize=(30, 30), # flags=cv2.cv2.CV_HAAR_SCALE_IMAGE # ) faces = faceCascade.detectMultiScale(gray, 1.3, 4) # Draw a rectangle around the faces for (x, y, w, h) in faces: # cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2) print(x, y, w, h, frame.shape) # roi = frame[640:1279, 360:719, :] cv2.imwrite("frame.jpg", frame) file = cv2.imread("frame.jpg") temp_img = file[y-50:y + w+50, x-50:x + h+50] cv2.imwrite("temp_file.jpg", temp_img) encoding = fr_utils.img_path_to_encoding("temp_file.jpg", FRmodel) print(encoding) # Display the resulting frame cv2.imshow('Video', frame) if cv2.waitKey(1) & 0xFF == ord('q'): break # When everything is done, release the capture video_capture.release() cv2.destroyAllWindows()