import sys from scipy import ndimage import cv2 import utils from svm import fetch_data if len(sys.argv) == 1: fetch_data() exit() elif len(sys.argv) > 2: print("\nError: More Than One Saving Directory Specified\n") exit() else: PROFILE_FOLDER_PATH = utils.create_profile_in_database(sys.argv[1]) DISPLAY_FACE_DIM = (128, 128) SKIP_FRAME = 2 # the fixed skip frame FRAME_SKIP_RATE = 0 # skip SKIP_FRAME frames every other frame SCALE_FACTOR = 2 # used to resize the captured frame for face detection for faster processing speed CURRENT_ROTATION_MAP = utils.get_rotation_map(0) WEBCAM = cv2.VideoCapture(0) RET, FRAME = WEBCAM.read() # get first frame FRAME_SCALE = (int(FRAME.shape[1] / SCALE_FACTOR), int(FRAME.shape[0] / SCALE_FACTOR)) # (y, x) CROPPED_FACE = [] NUM_OF_FACE_TO_COLLECT = 128 NUM_OF_FACE_SAVED = 0 UNSAVED = True
cropped_face = [] num_of_face_to_collect = 150 num_of_face_saved = 0 # For saving face data to directory profile_folder_path = None if len(sys.argv) == 1: print "\nError: No Saving Diectory Specified\n" exit() elif len(sys.argv) > 2: print "\nError: More Than One Saving Directory Specified\n" exit() else: profile_folder_path = ut.create_profile_in_database(sys.argv[1]) while ret: key = cv2.waitKey(1) # exit on 'q' 'esc' 'Q' if key in [27, ord('Q'), ord('q')]: break # resize the captured frame for face detection to increase processing speed resized_frame = cv2.resize(frame, frame_scale) processed_frame = resized_frame # Skip a frame if the no face was found last frame if frame_skip_rate == 0: faceFound = False for rotation in current_rotation_map:
cropped_face = [] num_of_face_to_collect = 150 num_of_face_saved = 0 # For saving face data to directory profile_folder_path = None if len(sys.argv) == 1: print "\nError: No Saving Diectory Specified\n" exit() elif len(sys.argv) > 2: print "\nError: More Than One Saving Directory Specified\n" exit() else: profile_folder_path = ut.create_profile_in_database(sys.argv[1]) while ret: key = cv2.waitKey(1) # exit on 'q' 'esc' 'Q' if key in [27, ord("Q"), ord("q")]: break # resize the captured frame for face detection to increase processing speed resized_frame = cv2.resize(frame, frame_scale) processed_frame = resized_frame # Skip a frame if the no face was found last frame if frame_skip_rate == 0: faceFound = False for rotation in current_rotation_map: