1 Star 0 Fork 1

如果未来有可能/ 人脸识别 Face recognition

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
common.py 2.12 KB
一键复制 编辑 原始数据 按行查看 历史
Submitk 提交于 2021-04-21 22:57 . commit
import os
import csv
def create_newcsv(path):
with open(path, "w+", newline='') as file:
csv_file = csv.writer(file)
def create_csv(path):
with open(path, "w+", newline='') as file:
csv_file = csv.writer(file)
head = ["student_ID","name","sex","age","class","time"]
csv_file.writerow(head)
def append_csv(path,datas):
with open(path, "a+", newline='') as file:
csv_file = csv.writer(file)
#datas = [["hoojjack3", "boy3"]]
csv_file.writerows(datas)
def read_csv(path):
with open(path,"r+") as file:
csv_file = csv.reader(file)
for data in csv_file:
print("data:", data)
print(data[0])
read_csv('face.csv')
def read_csv_id(path,id):
with open(path,"r+") as file:
csv_file = csv.reader(file)
for data in csv_file:
# print("datas:", data)
if data[0]==id:
return data
print(read_csv_id('face.csv','111111'))
def read_csv_studentid(path):
with open(path,"r+") as file:
csv_file = csv.reader(file)
for data in csv_file:
# print("datas:", data)
return data[0]
############################################
# 函数名:read_max_id #
# 输入:图片的位置path #
# 返回值:最大的编号id_max #
# 作用:获取人脸数据最大编号 #
############################################
def read_max_id(path):
id_max = -1
image_paths = [os.path.join(path, f) for f in os.listdir(path)]
for image_path in image_paths:
if os.path.split(image_path)[-1].split(".")[-1] != 'jpg':
continue #查找jpg结尾的图
image_id = int(os.path.split(image_path)[-1].split(".")[1])
id = image_id
if id_max < id:
id_max = id
else:
continue
return id_max
############################################
# 函数名:del_file #
# 输入:图片的位置path #
# 返回值:无 #
# 作用:递归删除所有人脸数据 #
############################################
def del_file(path):
ls = os.listdir(path)
for i in ls:
c_path = os.path.join(path, i)
if os.path.isdir(c_path):
del_file(c_path)
else:
os.remove(c_path)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/li12247060li/face-recognition.git
git@gitee.com:li12247060li/face-recognition.git
li12247060li
face-recognition
人脸识别 Face recognition
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385