def test_jpg(): img = imageio.imread('mlxtend/image/tests/data/lena-small.jpg') landmarks1 = extract_face_landmarks(img) landmarks2 = extract_face_landmarks(np.asarray(img)) np.testing.assert_array_equal(landmarks1, landmarks2) assert landmarks2.shape == (68, 2) true_vals = np.array([[85, 110], [85, 120], [85, 130], [87, 140], [91, 148], [97, 155], [104, 160], [112, 164], [120, 165], [125, 162]], dtype=np.int32) if os.name == 'nt': # on windows, imageio parses jpgs sometimes differently so pixel values # maybe slightly different assert np.sum(np.abs(landmarks2[:10] - true_vals) > 2) == 0 else: assert np.sum(np.abs(landmarks2[:10] - true_vals) > 0) == 0 np.testing.assert_array_equal(landmarks2[:10], true_vals)
def test_defaults(): img = imageio.imread('mlxtend/image/tests/data/lena-small.png') landmarks1 = extract_face_landmarks(img) landmarks2 = extract_face_landmarks(np.asarray(img)) np.testing.assert_array_equal(landmarks1, landmarks2) assert landmarks2.shape == (68, 2) true_vals = np.array( [[85, 111], [84, 120], [85, 131], [87, 140], [91, 148], [97, 155], [104, 161], [112, 164], [120, 165], [125, 162]], dtype=np.int32) np.testing.assert_array_equal(landmarks2[:10], true_vals)
def test_defaults(): path = 'mlxtend/image/tests/data/' eyepad = EyepadAlign() target_image = imageio.imread(os.path.join(path, 'celeba-subset/000001.jpg')) eyepad.fit_image(target_image) img = imageio.imread(os.path.join(path, 'lena-small.png')) img_tr = eyepad.transform(img) landmarks_tr = extract_face_landmarks(img_tr) true_vals = np.array([[35, 113], [33, 126], [34, 140], [36, 154], [41, 166], [51, 176], [61, 184], [72, 189], [82, 190], [90, 186]], dtype=np.int32) if os.name == 'nt': # on windows, imageio parses jpgs sometimes differently so pixel values # maybe slightly different assert np.sum(np.abs(landmarks_tr[:10] - true_vals) > 2) == 0 else: assert np.sum(np.abs(landmarks_tr[:10] - true_vals) > 0) == 0, \ np.sum(np.abs(landmarks_tr[:10] - true_vals)) np.testing.assert_array_equal(landmarks_tr[:10], true_vals)
def test_fit2dir(): path = 'mlxtend/image/tests/data/' eyepad = EyepadAlign() eyepad.fit_directory(target_img_dir=os.path.join(path, 'celeba-subset/'), target_width=178, target_height=218, file_extension='.jpg') img = imageio.imread(os.path.join(path, 'lena-small.png')) img_tr = eyepad.transform(img) landmarks_tr = extract_face_landmarks(img_tr) true_vals = np.array([[30, 115], [28, 130], [29, 145], [31, 160], [38, 173], [48, 182], [59, 191], [71, 196], [82, 197], [90, 193]], dtype=np.int32) if os.name == 'nt': # on windows, imageio parses jpgs sometimes differently so pixel values # maybe slightly different assert np.sum(np.abs(landmarks_tr[:10] - true_vals) > 3) == 0 else: assert np.sum(np.abs(landmarks_tr[:10] - true_vals) > 0) == 0, \ np.sum(np.abs(landmarks_tr[:10] - true_vals) > 0) np.testing.assert_array_equal(landmarks_tr[:10], true_vals)
def test_defaults(): path = 'mlxtend/image/tests/data/' eyepad = EyepadAlign() target_image = imageio.imread( os.path.join(path, 'celeba-subset/000001.jpg')) eyepad.fit_image(target_image) img = imageio.imread(os.path.join(path, 'lena-small.png')) img_tr = eyepad.transform(img) landmarks_tr = extract_face_landmarks(img_tr) true_vals = np.array( [[35, 113], [33, 126], [34, 140], [36, 154], [41, 166], [51, 176], [61, 184], [72, 189], [82, 190], [90, 186]], dtype=np.int32) if os.name == 'nt': # on windows, imageio parses jpgs sometimes differently so pixel values # maybe slightly different assert np.sum(np.abs(landmarks_tr[:10] - true_vals) > 2) == 0 else: assert np.sum(np.abs(landmarks_tr[:10] - true_vals) > 0) == 0, \ np.sum(np.abs(landmarks_tr[:10] - true_vals)) np.testing.assert_array_equal(landmarks_tr[:10], true_vals)
def test_fit2dir(): path = 'mlxtend/image/tests/data/' eyepad = EyepadAlign() eyepad.fit_directory(target_img_dir=os.path.join(path, 'celeba-subset/'), target_width=178, target_height=218, file_extension='.jpg') img = imageio.imread(os.path.join(path, 'lena-small.png')) img_tr = eyepad.transform(img) landmarks_tr = extract_face_landmarks(img_tr) true_vals = np.array( [[30, 115], [28, 130], [29, 145], [31, 160], [38, 173], [48, 182], [59, 191], [71, 196], [82, 197], [90, 193]], dtype=np.int32) if os.name == 'nt': # on windows, imageio parses jpgs sometimes differently so pixel values # maybe slightly different assert np.sum(np.abs(landmarks_tr[:10] - true_vals) > 3) == 0 else: assert np.sum(np.abs(landmarks_tr[:10] - true_vals) > 0) == 0, \ np.sum(np.abs(landmarks_tr[:10] - true_vals) > 0) np.testing.assert_array_equal(landmarks_tr[:10], true_vals)
def test_defaults(): img = imageio.imread('mlxtend/image/tests/data/lena-small.png') landmarks1 = extract_face_landmarks(img) landmarks2 = extract_face_landmarks(np.asarray(img)) np.testing.assert_array_equal(landmarks1, landmarks2) assert landmarks2.shape == (68, 2) true_vals = np.array([[85, 111], [84, 120], [85, 131], [87, 140], [91, 148], [97, 155], [104, 161], [112, 164], [120, 165], [125, 162]], dtype=np.int32) np.testing.assert_array_equal(landmarks2[:10], true_vals)
def extractFrames(pathIn, model): cap = cv2.VideoCapture(pathIn) X = np.zeros((1,num_of_cols)) i = 1 while (cap.isOpened()): # Capture frame-by-frame ret, frame = cap.read() if ret == True: # Extracting and saving facial landmarks from each frame frame = np.swapaxes(frame, 0, 1) # This rotates the image back to appropriate view # Facial landmark extractor try: landmarks = extract_face_landmarks(frame) except: print('No face detected!') landmarks = -1*np.ones((68,2)) else: landmarks = landmarks.flatten()[np.newaxis] finally: print('Facial detection algorithm is done!') # VGG16 feature extractor # convert the image pixels to a numpy array frame = cv2.resize(frame, newsize) # size image down by (224, 224) for VGG16 image = img_to_array(frame) # reshape data for the model image = image.reshape((1, image.shape[0], image.shape[1], image.shape[2])) # prepare the image for the VGG model image = preprocess_input(image) # get extracted features feature_vector = model.predict(image) print("VGG16's feature vector extracted!") X_new = np.append(landmarks, feature_vector, axis=1) print('Frame '+str(i)+' : Concatenation of row vectors is complete!') X = np.concatenate((X, X_new)) i += 1 else: X = np.delete(X, (0), axis=0) # Deletes entire first row because it was used for initialization np.savetxt('outfile_landmarks_'+str(name_of_mp4_video)+'.txt', X, fmt= '%.7f', delimiter= ' ') # Saves non-scaled facial landmarks # for each frame to text file in case it might be needed later # When everything done, release the capture cap.release() cv2.destroyAllWindows() break return X
def test_grayscale(): img = imageio.imread('mlxtend/image/tests/data/lena-small.png') img = rgb2gray(img) assert img.ndim == 2 landmarks1 = extract_face_landmarks(img) assert landmarks1.shape == (68, 2) true_vals = np.array( [[86, 111], [85, 120], [85, 130], [87, 140], [91, 148], [98, 155], [105, 160], [113, 164], [120, 165], [126, 162]], dtype=np.int32) np.testing.assert_array_equal(landmarks1[:10], true_vals)
def detect_landmarks_mlxtend(img): timestr = time.strftime("%Y%m%d-%H%M%S") landmarks = extract_face_landmarks(img) fig = plt.figure(figsize=(10, 5)) # ax = fig.add_subplot(1, 3, 1) # ax.imshow(img) ax = fig.add_subplot(1, 2, 1) ax.scatter(landmarks[:, 0], -landmarks[:, 1], alpha=0.8) # print(landmarks[:][:]) ax = fig.add_subplot(1, 2, 2) img2 = img.copy() for p in landmarks: x, y = p cv2.circle(img2, (x, y), 1, (0, 128, 0), 3) ax.imshow(img2) plt.show()
def test_grayscale(): img = imageio.imread('mlxtend/image/tests/data/lena-small.png') img = rgb2gray(img) assert img.ndim == 2 landmarks1 = extract_face_landmarks(img) assert landmarks1.shape == (68, 2) true_vals = np.array([[86, 111], [85, 120], [85, 130], [87, 140], [91, 148], [98, 155], [105, 160], [113, 164], [120, 165], [126, 162]], dtype=np.int32) np.testing.assert_array_equal(landmarks1[:10], true_vals)
def test_noface(): img = imageio.core.util.Array((np.random.random( (193, 341, 3)) * 255).astype(np.uint8)) landmarks = extract_face_landmarks(img) assert landmarks is None
def facialmark(name): image = "faces/" + name img = imageio.imread(image) landmarks = extract_face_landmarks(img) fig = plt.figure(figsize=(15, 5)) ax = fig.add_subplot(1, 3, 1) ax.imshow(img) ax = fig.add_subplot(1, 3, 2) ax.scatter(landmarks[:, 0], -landmarks[:, 1], alpha=0.8) ax = fig.add_subplot(1, 3, 3) img2 = img.copy() for p in landmarks: img2[p[1] - 3:p[1] + 3, p[0] - 3:p[0] + 3, :] = (120, 20, 255) ax.imshow(img2) plt.show() eleft = np.array([36, 37, 38, 39, 40, 41]) eright = np.array([42, 43, 44, 45, 46, 47]) nose = np.array([27, 28, 29, 30, 31, 32, 33, 34, 35]) mouth = np.array([ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67 ]) fig = plt.figure(figsize=(8, 8)) plt.plot(landmarks[:, 0], -landmarks[:, 1], 'ro', markersize=7, alpha=0.9) for i in range(landmarks.shape[0]): plt.text(landmarks[i, 0] + 1, -landmarks[i, 1], str(i), size=14) left_eye = np.mean(landmarks[eleft], axis=0) right_eye = np.mean(landmarks[eright], axis=0) nose_m = np.mean(landmarks[nose], axis=0) mouth_m = np.mean(landmarks[mouth], axis=0) plt.plot([left_eye[0]], [-left_eye[1]], marker='*', color='black', markersize=10, mew=3) plt.plot([right_eye[0]], [-right_eye[1]], marker='*', color='black', markersize=10, mew=3) plt.plot([nose_m[0]], [-nose_m[1]], marker='*', color='black', markersize=10, mew=3) plt.plot([mouth_m[0]], [-mouth_m[1]], marker='*', color='black', markersize=10, mew=3) plt.xticks([]) plt.yticks([]) plt.show() primary = left_eye[0] + right_eye[0] + nose_m[0] + mouth_m[0] secondary = left_eye[1] + right_eye[1] + nose_m[1] + mouth_m[1] return primary, secondary
image = cv2.rotate(image, cv2.cv2.ROTATE_90_CLOCKWISE) # image = cv2.resize(image,(244,244)) foundfase = False gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) faces = face_cascade.detectMultiScale(gray, 1.03, 5) area = 0 for (x, y, w, h) in faces: cv2.rectangle(image, (x, y), (x + w, y + h), (255, 0, 0), 2) if area <= h * w: roi_gray = gray[y:y + h, x:x + w] roi_color = image[y:y + h, x:x + w] foundfase = True if foundfase: copy = np.copy(roi_color) landmarks = extract_face_landmarks(copy) try: for points in landmarks: # copy=cv2.circle(copy,(points[0],points[1]),2,(255,255,255),-1) # print(i," ",points) # print(".",end=" ") pass # THIS FOR LOOP ALSO ACTS AS A FAILSAFE ON TYPE ERROR , when no landmarks are detected # lets start cropping eye succes, l_topl, l_botr, r_topl, r_botr = boxpointsfinder( landmarks, scalefactor=0.5)
def main(): print('loading stock face data...') stock_data = sys.argv[1] print(stock_data) imgL = cv2.imread(stock_data + 'L.jpg') # downscale images for faster processing imgR = cv2.imread(stock_data + 'R.jpg') imgL = cv2.resize(imgL, (400, 400), interpolation=cv2.INTER_AREA) imgR = cv2.resize(imgR, (400, 400), interpolation=cv2.INTER_AREA) landmarks = extract_face_landmarks(imgL) #print(len(landmarks)) z_ax = Depth_Estimation( imgL, imgR, 5, 7, 55, True, ) #print(len(z_ax)) (land3d1, xdata1, ydata1, zdata1) = Landmarks3D(landmarks, z_ax) #Plot3D(xdata1,ydata1,zdata1) print('loading input face data...') input_data = sys.argv[2] print(input_data) imgL = cv2.imread(input_data + 'L.jpg') # downscale images for faster processing imgR = cv2.imread(input_data + 'R.jpg') imgL = cv2.resize(imgL, (400, 400), interpolation=cv2.INTER_AREA) imgR = cv2.resize(imgR, (400, 400), interpolation=cv2.INTER_AREA) landmarks = extract_face_landmarks(imgL) #print(landmarks) z_ax = Depth_Estimation( imgL, imgR, 5, 7, 55, True, ) #print(z_ax) (land3d2, xdata2, ydata2, zdata2) = Landmarks3D(landmarks, z_ax) #Plot3D(xdata2,ydata2,zdata2) res = 0 ln = min(len(land3d1), len(land3d2)) for i in range(0, ln): if land3d2[i][2] != float("inf") and land3d1[i][2] != float("inf"): d1 = np.asarray([land3d1[i][0], land3d1[i][1], land3d1[i][2]]) d2 = np.asarray([land3d2[i][0], land3d2[i][1], land3d2[i][2]]) res += distance.euclidean(d1, d2) # Best possible accuracy achieved by us is 2000, This is becuase of the collected data is not Stereo Accurate. # But, Sri data gave a great accuracy of less than 1000 residue. # With Roh data we did achieve at accuracy of 900 as well. But, with only certain stock and input combinations. Which is not reliable in real world sometimes. if res < 2000: print('Face Recognised! and Residue is:', res) else: print('No Match. Becuase residue is:', res)
import imageio import matplotlib.pyplot as plt %matplotlib inline from mlxtend.image import extract_face_landmarks img = imageio.imread('m5.jpg') landmarks = extract_face_landmarks(img) print(landmarks.shape) print('\n\n landmarks:\n', landmarks) fig = plt.figure(figsize=(15, 5)) ax = fig.add_subplot(1, 3, 1) ax.imshow(img) ax = fig.add_subplot(1, 3, 2) ax.scatter(landmarks[:, 0], -landmarks[:, 1], alpha=0.8) ax = fig.add_subplot(1, 3, 3) img2 = img.copy() for p in landmarks: img2[p[1]-3:p[1]+3,p[0]-3:p[0]+3,:] = (255, 255, 255) ax.imshow(img2) plt.show() # Feature indexes import numpy as np jaw = np.array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]) left_eyebrow = np.array([17,18,19,20,21]) right_eyebrow = np.array([22,23,24,25,26]) nose = np.array([27,28,29,30,31,32,33,34,35]) left_eye = np.array([36, 37, 38, 39, 40, 41]) right_eye = np.array([42, 43, 44, 45, 46, 47])
image = cv2.imread(fileloc, 1) print("PRESS Q to quit") print(image[0]) # Not gona use this for the ime being #https://stackoverflow.com/questions/47697622/cnn-image-resizing-vs-padding-keeping-aspect-ratio-or-not # image_keep_aspect=resize2SquareKeepingAspectRation(image,224,cv2.INTER_AREA) # cv2.imshow("Frame",image_keep_aspect) # cv2.waitKey(0) rotations = rots(image) while rotations > 0: rotations -= 1 image = cv2.rotate(image, cv2.ROTATE_90_CLOCKWISE) image_resize = cv2.resize(image, (224, 224)) cv2.imshow("Frame", image_resize) cv2.waitKey(0) landmarks = extract_face_landmarks(image_resize) for points in landmarks: image_resize[points[1], points[0], 0] = 255 image_resize[points[1], points[0], 1] = 255 image_resize[points[1], points[0], 2] = 255 image_resize = cv2.circle(image_resize, (points[0], points[1]), 3, (255, 255, 255), -1) cv2.imshow("Frame", image_resize) cv2.waitKey(0) cv2.destroyAllWindows() pass
def test_noface(): img = imageio.core.util.Array(( np.random.random((193, 341, 3))*255).astype(np.uint8)) landmarks = extract_face_landmarks(img) assert landmarks is None
ni = 1 while True: return_value,frame = cap.read() # Resize frame of video to 1/4 size for faster face recognition processing small_frame = cv2.resize(frame, (0, 0), fx=0.5, fy=0.5) process_frame = cv2.resize(frame, (0, 0), fx=1, fy=1) cv2.imshow('test',small_frame) # Hit 'q' on the keyboard to quit! if cv2.waitKey(1) & 0xFF == ord('q'): break img = cv2.cvtColor(process_frame, cv2.COLOR_BGR2RGB) try: landmarks = extract_face_landmarks(img) #Individual facial features left_outer_eye = landmarks[36] right_outer_eye = landmarks[45] #We will use trigonometry to find roatation angle required to normalize the face h = left_outer_eye[1]-right_outer_eye[1] #Height of the triangle w = left_outer_eye[0]-right_outer_eye[0] #Width of the triangle angle = math.degrees(math.atan(h/w)) #Finding tan inverse and converting to degress for angle of rotation image_center = tuple(np.array(img.shape[1::-1])/2) rot_mat = cv2.getRotationMatrix2D(image_center, angle, 1.0) rotated_img = cv2.warpAffine(img, rot_mat, img.shape[1::-1], flags=cv2.INTER_LINEAR) landmarks = extract_face_landmarks(rotated_img) except UserWarning:
def test_defaults(): extract_face_landmarks()
def extract_features(image): image = cv2.resize(image, (360, 540)) print(image.shape) landmarks = extract_face_landmarks(image) # img2 = image.copy() # fig = plt.figure(figsize=(15, 5)) # ax = fig.add_subplot(1, 3, 1) # ax.imshow(image) # ax = fig.add_subplot(1, 3, 2) # ax.scatter(landmarks[:, 0], -landmarks[:, 1], alpha=0.8) # ax = fig.add_subplot(1, 3, 3) # for idx,p in enumerate(landmarks): # img2[p[1] - 3:p[1] + 3, p[0] - 3:p[0] + 3, :] = (255, 255, 255) # cv2.putText(img2, str(idx), (p[0], p[1]), fontFace=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, # fontScale=0.4, # color=(0, 0, 255)) # ax.imshow(img2) # plt.show() # landmarks = extract_face_landmarks(image) print(landmarks.shape) img2 = image.copy() p1 = landmarks[36] p2 = landmarks[39] p3 = landmarks[30] a = math.sqrt(((p1[0] - p2[0]) ** 2) + ((p1[1] - p2[1]) ** 2)) b = math.sqrt(((p1[0] - p3[0]) ** 2) + ((p1[1] - p3[1]) ** 2)) c = math.sqrt(((p2[0] - p3[0]) ** 2) + ((p2[1] - p3[1]) ** 2)) s = (a + b + c) / 2 area_A1 = (s * (s - a) * (s - b) * (s - c)) ** 0.5 p4 = landmarks[42] a = math.sqrt(((p2[0] - p4[0]) ** 2) + ((p2[1] - p4[1]) ** 2)) b = math.sqrt(((p4[0] - p3[0]) ** 2) + ((p4[1] - p3[1]) ** 2)) c = math.sqrt(((p2[0] - p3[0]) ** 2) + ((p2[1] - p3[1]) ** 2)) s = (a + b + c) / 2 area_A2 = (s * (s - a) * (s - b) * (s - c)) ** 0.5 p5 = landmarks[45] p6 = landmarks[54] a = math.sqrt(((p4[0] - p5[0]) ** 2) + ((p4[1] - p5[1]) ** 2)) b = math.sqrt(((p4[0] - p6[0]) ** 2) + ((p4[1] - p6[1]) ** 2)) c = math.sqrt(((p5[0] - p6[0]) ** 2) + ((p5[1] - p6[1]) ** 2)) s = (a + b + c) / 2 area_A3 = (s * (s - a) * (s - b) * (s - c)) ** 0.5 p7 = landmarks[48] a = math.sqrt(((p1[0] - p7[0]) ** 2) + ((p1[1] - p7[1]) ** 2)) b = math.sqrt(((p1[0] - p3[0]) ** 2) + ((p1[1] - p3[1]) ** 2)) c = math.sqrt(((p3[0] - p7[0]) ** 2) + ((p3[1] - p7[1]) ** 2)) s = (a + b + c) / 2 area_A4 = (s * (s - a) * (s - b) * (s - c)) ** 0.5 a = math.sqrt(((p4[0] - p6[0]) ** 2) + ((p4[1] - p6[1]) ** 2)) b = math.sqrt(((p3[0] - p6[0]) ** 2) + ((p3[1] - p6[1]) ** 2)) c = math.sqrt(((p3[0] - p4[0]) ** 2) + ((p3[1] - p4[1]) ** 2)) s = (a + b + c) / 2 area_A5 = (s * (s - a) * (s - b) * (s - c)) ** 0.5 a = math.sqrt(((p3[0] - p6[0]) ** 2) + ((p3[1] - p6[1]) ** 2)) b = math.sqrt(((p3[0] - p7[0]) ** 2) + ((p3[1] - p7[1]) ** 2)) c = math.sqrt(((p6[0] - p7[0]) ** 2) + ((p6[1] - p7[1]) ** 2)) s = (a + b + c) / 2 area_A6 = (s * (s - a) * (s - b) * (s - c)) ** 0.5 p19 = landmarks[19] p37 = landmarks[37] p24 = landmarks[24] p44 = landmarks[44] p27 = landmarks[27] p30 = landmarks[30] p36 = landmarks[36] p39 = landmarks[39] p42 = landmarks[42] p45 = landmarks[45] p57 = landmarks[57] p8 = landmarks[8] mat_trai_x = round((p36[0] + p39[0]) // 2) mat_trai_y = round((p36[1] + p39[1]) // 2) mat_phai_x = round((p42[0] + p45[0]) // 2) mat_phai_y = round((p42[1] + p45[1]) // 2) distance_two_eye = math.sqrt(((mat_trai_x - mat_phai_x) ** 2) + ((mat_trai_y - mat_phai_y) ** 2)) distance_eyebrow_eye_left = math.sqrt(((p19[0] - p37[0]) ** 2) + ((p19[1] - p37[1]) ** 2)) distance_eyebrow_eye_right = math.sqrt(((p24[0] - p44[0]) ** 2) + ((p24[1] - p44[1]) ** 2)) nose_along_lengh = math.sqrt(((p27[0] - p30[0]) ** 2) + ((p27[1] - p30[1]) ** 2)) distance_eye_left = math.sqrt(((p36[0] - p39[0]) ** 2) + ((p36[1] - p39[1]) ** 2)) distance_eye_right = math.sqrt(((p42[0] - p45[0]) ** 2) + ((p42[1] - p45[1]) ** 2)) distance_chin_mouth = math.sqrt(((p8[0] - p57[0]) ** 2) + ((p8[1] - p57[1]) ** 2)) features = [] # distance_1 = math.sqrt(((mat_trai_x - p15[0]) ** 2) + ((mat_trai_y - p15[1]) ** 2)) # distance_2 = math.sqrt(((mat_trai_x - p16[0]) ** 2) + ((mat_trai_y - p16[1]) ** 2)) # distance_eye_left = math.sqrt(((p1[0] - p2[0]) ** 2) + ((p1[1] - p2[1]) ** 2)) # distance2 = math.sqrt(((p3[0] - p4[0]) ** 2) + ((p3[1] - p4[1]) ** 2)) # distance_nose = math.sqrt(((p5[0] - p6[0]) ** 2) + ((p5[1] - p6[1]) ** 2)) # distance_mouth_nose = math.sqrt(((p7[0] - p8[0]) ** 2) + ((p7[1] - p8[1]) ** 2)) # distance_mouth = math.sqrt(((p9[0] - p10[0]) ** 2) + ((p9[1] - p10[1]) ** 2)) # distance6 = math.sqrt(((p11[0] - p12[0]) ** 2) + ((p11[1] - p12[1]) ** 2)) # distance7 = math.sqrt(((p13[0] - p14[0]) ** 2) + ((p13[1] - p14[1]) ** 2)) # tam_x = round((mat_phai_x + mat_trai_x) // 2) # tam_y = round((mat_phai_y + mat_trai_y) // 2) # distance_8 = math.sqrt(((tam_x - p17[0]) ** 2) + ((tam_y - p17[1]) ** 2)) # features.append(distance_two_eye) # features.append(distance_nose) # features.append(distance_mouth_nose) # features.append(distance_mouth) # features.append(distance6) # features.append(distance7) # features.append(distance_two_eye/distance_nose) # features.append(distance_two_eye/distance_mouth_nose) # features.append(distance_two_eye/distance_mouth) # features.append(distance_nose / distance_mouth_nose) # features.append(distance_nose / distance_mouth) # features.append(distance_mouth_nose / distance_mouth) # features.append(area_A1) # features.append(area_A2) # features.append(area_A3) # features.append(area_A4) # features.append(area_A5) # features.append(area_A6) features.append(distance_two_eye) features.append(distance_eyebrow_eye_left) features.append(distance_eyebrow_eye_right) features.append(nose_along_lengh) features.append(distance_eye_left) features.append(distance_eye_right) features.append(distance_chin_mouth) return features