python将变量的类型更改为数组,面部识别

时间:2019-12-09 18:29:59

标签: arrays python-3.x string variables face-recognition

我想将数组类型变量转换为字符串,然后再返回数组,但是遇到了问题

import face_recognition


a = face_recognition.load_image_file('C:\\Users\zivsi\OneDrive\תמונות\סרט צילום\WIN_20191115_10_32_24_Pro.jpg') # my picture 1
b = face_recognition.load_image_file('C:\\Users\zivsi\OneDrive\תמונות\סרט צילום\WIN_20191115_09_48_56_Pro.jpg') # my picture 2
c = face_recognition.load_image_file('C:\\Users\zivsi\OneDrive\תמונות\סרט צילום\WIN_20191115_09_48_52_Pro.jpg')# my picture 3
d = face_recognition.load_image_file('C:\\Users\zivsi\OneDrive\תמונות\סרט צילום\ziv sion.jpg') # my picture 4
e = face_recognition.load_image_file('C:\\Users\zivsi\OneDrive\תמונות\סרט צילום\WIN_20191120_17_46_40_Pro.jpg') # my picture 5
f = face_recognition.load_image_file('C:\\Users\zivsi\OneDrive\תמונות\סרט צילום\WIN_20191117_16_19_11_Pro.jpg')# my picture 6

a = face_recognition.face_encodings(a)[0]
b = face_recognition.face_encodings(b)[0]
c = face_recognition.face_encodings(c)[0]
d = face_recognition.face_encodings(d)[0]
e = face_recognition.face_encodings(e)[0]
f = face_recognition.face_encodings(f)[0]

my_face = a, b, c, d, e, f
for i in range(1):
    new_face = 'C:\\Users\zivsi\OneDrive\תמונות\סרט צילום\ziv sion.jpg'

    new_face = face_recognition.load_image_file(new_face)
    new_face2 = face_recognition.face_encodings(new_face)[0]
    import numpy as np

    new_face2 = str(new_face2)
    new_face2 = np.array(new_face2) # Here's the problem


    results = face_recognition.compare_faces(my_face, new_face2, tolerance=0.4)

    print(results)

    my_face = *my_face, new_face2

任何人都知道如何更改变量类型才能使其正常工作吗?

(我想知道,因为我想稍后将其保存为字符串,并在下次运行时将其从文件中读取并转换为数组)

0 个答案:

没有答案