def extract_features(face_id, image_id, face_top, face_left, face_height, face_width, image_height, image_width, landmarks): features = feature_comp.compute(landmarks) if not features: return cursor.execute('INSERT INTO `features`(face_id, d_eyes_1, d_eyes_2, width_eye_left, width_eye_right, angle_chin_1, angle_chin_2, angle_chin_3, len_nose) VALUES (%d, %f, %f, %f, %f, %f, %f, %f, %f)'%(face_id, features['d_eyes_1'], features['d_eyes_2'], features['width_eye_left'], features['width_eye_right'], features['angle_chin_1'], features['angle_chin_2'],features['angle_chin_3'], features['len_nose']))
faces_obj = [] for i, face in enumerate(faces): face_top = face.top() face_left = face.left() face_width = face.width() face_height = face.height() landmarks = deserialize(serialize(predictor(img, face))) scaleX = 150 / face_width scaleY = 150 / face_height landmarks = scale(landmarks, scaleX, scaleY) features = feature_comp.compute(landmarks) face = { 'face_top': face_top, 'face_left': face_left, 'face_width': face_width, 'face_height': face_height, 'features': features } faces_obj.append(face) res = { 'faces': faces_obj, 'image_height': img_height, 'image_width': img_width }