def return_128d_features(path_img):img_rd = io.imread(path_img)img_gray = cv2.cvtColor(img_rd, cv2.COLOR_BGR2RGB)faces = detector(img_gray, 1)print("%-40s %-20s" % ("檢測到人臉的圖像 / image with faces detected:", path_img), '\n')if len(faces) != 0: shape = predictor(img_gray, faces[0]) face_descriptor = face_rec.compute_face_descriptor(img_gray, shape)else: face_descriptor = 0 print("no face") return face_descriptor
def return_features_mean_personX(path_faces_personX): features_list_personX = [] photos_list = os.listdir(path_faces_personX) if photos_list: for i in range(len(photos_list)): with open("C:/Users/WH/Desktop/VScode/feature/featuresGiao"+str(i)+".csv", "w", newline="") as csvfile: writer = csv.writer(csvfile) print("%-40s %-20s" % ("正在讀的人臉圖像 / image to read:", path_faces_personX +"/" +photos_list[i])) features_128d = return_128d_features(path_faces_personX +"/" + photos_list[i]) print(features_128d) writer.writerow(features_128d)
while running this code, I got the error,how to fix it?
I don't understand the only one similiar question, hope someone can help me fix it
01Gary#####
正在讀的人臉圖像 / image to read: C:/Users/WH/Desktop/VScode/Facetrainset/01Gary/1.jpg檢測到人臉的圖像 / image with faces detected: C:/Users/WH/Desktop/VScode/Facetrainset/01Gary/1.jpg
NoneTraceback (most recent call last):File "c:\Users\WH\Desktop\VScode\人臉收集識別\datatransfer.py", line 88, in features_mean_personX = return_features_mean_personX(path_images_from_camera + person)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "c:\Users\WH\Desktop\VScode\人臉收集識別\datatransfer.py", line 60, in return_features_mean_personXwriter.writerow(features_128d)_csv.Error: iterable expected, not NoneType