def get_face_database(self, cid): # print(cid) # course_sid = SC.query.filter(SC.c_id==cid).all() # all_sid = [] # for sc in course_sid: # all_sid.append(sc.s_id) # from_db_all_features = Faces.query.filter(Faces.s_id.in_(all_sid)).all() from_db_all_features = Faces.query.all() if from_db_all_features: for from_db_one_features in from_db_all_features: someone_feature_str = str(from_db_one_features.feature).split(',') self.name_known_list.append(from_db_one_features.s_id) features_someone_arr = [] for one_feature in someone_feature_str: if one_feature == '': features_someone_arr.append('0') else: features_someone_arr.append(float(one_feature)) self.features_known_list.append(features_someone_arr) # print("Faces in Database:", len(self.features_known_list)) return 1 else: # print('##### Warning #####', '\n') # print("'features' is empty") # print('##### End Warning #####') return 0 # 更新 FPS / Update FPS of video stream
时间: 2023-06-19 14:09:16 浏览: 96
这段代码中的函数get_face_database是用来从数据库中获取人脸特征信息的。首先,它查询指定课程下所有学生的ID,然后从数据库中获取这些学生的人脸特征信息。如果成功获取到特征信息,则将学生ID和特征信息分别存储在self.name_known_list和self.features_known_list中。最后,返回1表示成功获取到人脸特征信息,返回0表示未能获取到。在函数末尾,还有一行注释说明是用来更新视频流的帧率。
阅读全文