diff --git a/.gitignore b/.gitignore index 0b65044..09a2815 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ !/.gitignore !/readme.md !/componentdevelopment/ -!/FaceRegWeb/ \ No newline at end of file +!/FaceRegWeb/ +!/FaceRegWeb5.2/ \ No newline at end of file diff --git a/FaceRegWeb/docx/人脸识别web端使用说明V5.2.docx b/FaceRegWeb/docx/人脸识别web端使用说明V5.2.docx deleted file mode 100644 index f8e9804..0000000 Binary files a/FaceRegWeb/docx/人脸识别web端使用说明V5.2.docx and /dev/null differ diff --git a/FaceRegWeb/docx/人脸识别需求设计说明书V5.2.docx b/FaceRegWeb/docx/人脸识别需求设计说明书V5.2.docx deleted file mode 100644 index eda1afd..0000000 Binary files a/FaceRegWeb/docx/人脸识别需求设计说明书V5.2.docx and /dev/null differ diff --git a/FaceRegWeb/checkpoints/face_landmarker_pts5_net1.onnx b/FaceRegWeb5.2/FaceRegWeb/checkpoints/face_landmarker_pts5_net1.onnx similarity index 100% rename from FaceRegWeb/checkpoints/face_landmarker_pts5_net1.onnx rename to FaceRegWeb5.2/FaceRegWeb/checkpoints/face_landmarker_pts5_net1.onnx diff --git a/FaceRegWeb/checkpoints/face_landmarker_pts5_net2.onnx b/FaceRegWeb5.2/FaceRegWeb/checkpoints/face_landmarker_pts5_net2.onnx similarity index 100% rename from FaceRegWeb/checkpoints/face_landmarker_pts5_net2.onnx rename to FaceRegWeb5.2/FaceRegWeb/checkpoints/face_landmarker_pts5_net2.onnx diff --git a/FaceRegWeb/checkpoints/face_recognizer.onnx b/FaceRegWeb5.2/FaceRegWeb/checkpoints/face_recognizer.onnx similarity index 100% rename from FaceRegWeb/checkpoints/face_recognizer.onnx rename to FaceRegWeb5.2/FaceRegWeb/checkpoints/face_recognizer.onnx diff --git a/FaceRegWeb/checkpoints/faceboxesv2-640x640.onnx b/FaceRegWeb5.2/FaceRegWeb/checkpoints/faceboxesv2-640x640.onnx similarity index 100% rename from FaceRegWeb/checkpoints/faceboxesv2-640x640.onnx rename to FaceRegWeb5.2/FaceRegWeb/checkpoints/faceboxesv2-640x640.onnx diff --git a/FaceRegWeb/checkpoints/fsanet-conv.onnx b/FaceRegWeb5.2/FaceRegWeb/checkpoints/fsanet-conv.onnx similarity index 100% rename from FaceRegWeb/checkpoints/fsanet-conv.onnx rename to FaceRegWeb5.2/FaceRegWeb/checkpoints/fsanet-conv.onnx diff --git a/FaceRegWeb/checkpoints/fsanet-var.onnx b/FaceRegWeb5.2/FaceRegWeb/checkpoints/fsanet-var.onnx similarity index 100% rename from FaceRegWeb/checkpoints/fsanet-var.onnx rename to FaceRegWeb5.2/FaceRegWeb/checkpoints/fsanet-var.onnx diff --git a/FaceRegWeb/checkpoints/model_gray_mobilenetv2_rotcls.onnx b/FaceRegWeb5.2/FaceRegWeb/checkpoints/model_gray_mobilenetv2_rotcls.onnx similarity index 100% rename from FaceRegWeb/checkpoints/model_gray_mobilenetv2_rotcls.onnx rename to FaceRegWeb5.2/FaceRegWeb/checkpoints/model_gray_mobilenetv2_rotcls.onnx diff --git a/FaceRegWeb/config.yaml b/FaceRegWeb5.2/FaceRegWeb/config.yaml similarity index 100% rename from FaceRegWeb/config.yaml rename to FaceRegWeb5.2/FaceRegWeb/config.yaml diff --git a/FaceRegWeb/flushredis.py b/FaceRegWeb5.2/FaceRegWeb/flushredis.py similarity index 100% rename from FaceRegWeb/flushredis.py rename to FaceRegWeb5.2/FaceRegWeb/flushredis.py diff --git a/FaceRegWeb/models/__init__.py b/FaceRegWeb5.2/FaceRegWeb/models/__init__.py similarity index 100% rename from FaceRegWeb/models/__init__.py rename to FaceRegWeb5.2/FaceRegWeb/models/__init__.py diff --git a/FaceRegWeb/models/__pycache__/__init__.cpython-38.pyc b/FaceRegWeb5.2/FaceRegWeb/models/__pycache__/__init__.cpython-38.pyc similarity index 100% rename from FaceRegWeb/models/__pycache__/__init__.cpython-38.pyc rename to FaceRegWeb5.2/FaceRegWeb/models/__pycache__/__init__.cpython-38.pyc diff --git a/FaceRegWeb/models/__pycache__/facealign.cpython-38.pyc b/FaceRegWeb5.2/FaceRegWeb/models/__pycache__/facealign.cpython-38.pyc similarity index 100% rename from FaceRegWeb/models/__pycache__/facealign.cpython-38.pyc rename to FaceRegWeb5.2/FaceRegWeb/models/__pycache__/facealign.cpython-38.pyc diff --git a/FaceRegWeb/models/__pycache__/facedetector.cpython-38.pyc b/FaceRegWeb5.2/FaceRegWeb/models/__pycache__/facedetector.cpython-38.pyc similarity index 100% rename from FaceRegWeb/models/__pycache__/facedetector.cpython-38.pyc rename to FaceRegWeb5.2/FaceRegWeb/models/__pycache__/facedetector.cpython-38.pyc diff --git a/FaceRegWeb/models/__pycache__/facelandmarks5er.cpython-38.pyc b/FaceRegWeb5.2/FaceRegWeb/models/__pycache__/facelandmarks5er.cpython-38.pyc similarity index 100% rename from FaceRegWeb/models/__pycache__/facelandmarks5er.cpython-38.pyc rename to FaceRegWeb5.2/FaceRegWeb/models/__pycache__/facelandmarks5er.cpython-38.pyc diff --git a/FaceRegWeb/models/__pycache__/facerecoger.cpython-38.pyc b/FaceRegWeb5.2/FaceRegWeb/models/__pycache__/facerecoger.cpython-38.pyc similarity index 100% rename from FaceRegWeb/models/__pycache__/facerecoger.cpython-38.pyc rename to FaceRegWeb5.2/FaceRegWeb/models/__pycache__/facerecoger.cpython-38.pyc diff --git a/FaceRegWeb/models/__pycache__/imgchecker.cpython-38.pyc b/FaceRegWeb5.2/FaceRegWeb/models/__pycache__/imgchecker.cpython-38.pyc similarity index 100% rename from FaceRegWeb/models/__pycache__/imgchecker.cpython-38.pyc rename to FaceRegWeb5.2/FaceRegWeb/models/__pycache__/imgchecker.cpython-38.pyc diff --git a/FaceRegWeb/models/facealign.py b/FaceRegWeb5.2/FaceRegWeb/models/facealign.py similarity index 100% rename from FaceRegWeb/models/facealign.py rename to FaceRegWeb5.2/FaceRegWeb/models/facealign.py diff --git a/FaceRegWeb/models/facedetector.py b/FaceRegWeb5.2/FaceRegWeb/models/facedetector.py similarity index 100% rename from FaceRegWeb/models/facedetector.py rename to FaceRegWeb5.2/FaceRegWeb/models/facedetector.py diff --git a/FaceRegWeb/models/facelandmarks5er.py b/FaceRegWeb5.2/FaceRegWeb/models/facelandmarks5er.py similarity index 100% rename from FaceRegWeb/models/facelandmarks5er.py rename to FaceRegWeb5.2/FaceRegWeb/models/facelandmarks5er.py diff --git a/FaceRegWeb/models/facerecoger.py b/FaceRegWeb5.2/FaceRegWeb/models/facerecoger.py similarity index 100% rename from FaceRegWeb/models/facerecoger.py rename to FaceRegWeb5.2/FaceRegWeb/models/facerecoger.py diff --git a/FaceRegWeb/models/imgchecker.py b/FaceRegWeb5.2/FaceRegWeb/models/imgchecker.py similarity index 100% rename from FaceRegWeb/models/imgchecker.py rename to FaceRegWeb5.2/FaceRegWeb/models/imgchecker.py diff --git a/FaceRegWeb/process.py b/FaceRegWeb5.2/FaceRegWeb/process.py similarity index 82% rename from FaceRegWeb/process.py rename to FaceRegWeb5.2/FaceRegWeb/process.py index 2326aae..f2085d8 100644 --- a/FaceRegWeb/process.py +++ b/FaceRegWeb5.2/FaceRegWeb/process.py @@ -47,27 +47,30 @@ for i in range(NUM_WORKERS): rw_lock = RedisReadWriteLock(redis_client, max_readers=max_readers) ErrorMsg = { - "101":"no face in the database", - "102":"invalid file path", - "103":"invaild file suffix", + + "30003": "no face found in the database", + "30004": "invalid file path", + "30005": "invalid file suffix", - "201":"input file type is not support, only support: base64, url, local-path", - "202":"this updateDB type is not support", + "30006": "unsupported input file type; only supports: base64, URL, local path", + "30007": "unsupported type for database update", - "300":"deal the image successfully.", - "301":"no face in the image.", - "302":"too many face in the image.", - "303":"bad bright of face in the image.", - "3041":"face shifted left/right, partially not captured.", - "3042":"face shifted top/bottom, partially not captured.", - "3051":"rightFace in the image.", - "3052":"leftFace in the image.", - "3053":"upFace in the image.", - "3054":"downFace in the image.", - "306":"too small resolution of face in the image.", - "307":"bad clarity of face in the image.", - - "401":"identity has exist. to pretect the db, reject opt of this time ", + "30000": "facial recognition of a known individual", + "30001": "facial recognition of an unknown individual", + "30002": "successful image processing", + "30018": "no face detected in the image", + "30008": "multiple faces found in the image", + "30009": "poor bright conditions affecting facial quality in the image", + "30010": "face partially out of frame, shifted left or right", + "30011": "face partially out of frame, shifted top or bottom", + "30012": "face rotated to the right in the image", + "30013": "face rotated to the left in the image", + "30014": "face rotated upwards in the image", + "30015": "face rotated downwards in the image", + "30016": "low resolution of a face in the image", + "30017": "poor clarity of a face in the image", + + "30019": "identity already exists; for database protection, operation rejected at this time" } class FileError(Exception): @@ -158,9 +161,9 @@ def load_img(img_path:str): image = cv2.imdecode(image_array, cv2.IMREAD_COLOR) elif img_path.startswith(("./","/","C:","D:","E:",".\\")) or os.path.isfile(img_path): # local-path if not os.path.isfile(img_path): - raise FileError("102") # push: invalid file path + raise FileError("30004") # push: invalid file path elif not img_path.lower().endswith((".jpg",'.jpeg','.png')): - raise FileError("103") # push: invaild file suffix + raise FileError("30005") # push: invaild file suffix else: image = cv2.imread(img_path) elif img_path.startswith("data:") and "base64" in img_path: # base64 @@ -172,7 +175,7 @@ def load_img(img_path:str): nparr = np.fromstring(base64.b64decode(encoded_data), np.uint8) image = cv2.imdecode(nparr, cv2.IMREAD_COLOR) else: - raise NotImpltError("201") # push: input file type is not support, only support: base64, url, local-path + raise NotImpltError("30006") # push: input file type is not support, only support: base64, url, local-path except Exception as e: logger.info(f"{e}") raise e @@ -248,7 +251,7 @@ class FaceHelper: try: if self.db_embeddings is None: - raise FileError("101") # push: no face in the database + raise FileError("30003") # push: no face in the database image = load_img(img_path) # get bgr numpy image @@ -257,14 +260,10 @@ class FaceHelper: image = self.rotadjust(image) # 调整角度 detect_result = self.fd.detect(image) detect_result = [(box.x1, box.y1, box.x2, box.y2) for box in detect_result] - rett = {'code':" ", 'msg':" ", 'data':" "} if len(detect_result) == 0: logger.info(f"{img_path[:200]}: no face in the image") print(f"{img_path[:200]}: no face in the image") - raise FaceError("301") # push: no face in the image - elif len(detect_result) > 1: - rett['code'] = '302' - rett['data'] = {'code':" ", 'msg':" ", 'data':" "} + raise FaceError("30018") # push: no face in the image for facebox in detect_result: landmarks5 = self.ld5er.inference(image, facebox) # return: [(),(),(),(),()] 左眼 右眼 鼻子 左嘴角 右嘴角 # print("5点关键点:",landmarks5) @@ -291,12 +290,15 @@ class FaceHelper: ret_data = [] for i, (facebox, name) in enumerate(zip(detect_result, names)): if name != 'unknown': - ret_data.append({'code':"300", 'msg': ErrorMsg["300"], 'data':name}) + ret_data.append({'code':"30000", 'msg': ErrorMsg["30000"], 'data':[name,facebox]}) else: code = self.check_face("None", image, facebox, prefix='facereg') - ret_data.append({'code':code, 'msg': ErrorMsg[code], 'data':name}) + if code == "30002": + ret_data.append({'code':"30001", 'msg': ErrorMsg["30001"], 'data':[name,facebox]}) + else: + ret_data.append({'code':code, 'msg': ErrorMsg[code], 'data':[name,facebox]}) if len(ret_data) != 1: - ret_data = {'code':"302", 'msg': ErrorMsg["302"], 'data': ret_data} + ret_data = {'code':"30008", 'msg': ErrorMsg["30008"], 'data': ret_data} else: ret_data = ret_data[0] @@ -311,6 +313,49 @@ class FaceHelper: return ret_data # return names, [ encoder_img2base64(det) for det in cropped_images] + # 只是提取人脸特征,不要对别的有任何影响 + def featureDetect(self, img_path:str): + rw_lock.acquire_read() + + try: + image = load_img(img_path) # get bgr numpy image + + unknown_embeddings = [] + image = self.rotadjust(image) # 调整角度 + detect_result = self.fd.detect(image) + detect_result = [(box.x1, box.y1, box.x2, box.y2) for box in detect_result] + if len(detect_result) == 0: + logger.info(f"{img_path[:200]}: no face in the image") + print(f"{img_path[:200]}: no face in the image") + raise FaceError("30018") # push: no face in the image + for facebox in detect_result: + landmarks5 = self.ld5er.inference(image, facebox) # return: [(),(),(),(),()] 左眼 右眼 鼻子 左嘴角 右嘴角 + # print("5点关键点:",landmarks5) + # 输入image 和5点特征点位置(基于原图image的位置) , return all cropped aligned face (裁剪后的对齐后的人脸部分图像, 简写为aligned_faces) + landmarks5 = [ [ld5[0],ld5[1]] for ld5 in landmarks5] + cropped_face = self.fa.align(image, landmarks5=landmarks5) + # 输入aligned_faces ,return all features of aligned_faces + feature = self.fr.inference(cropped_face) + unknown_embeddings.append(feature) + + ret_data = [] + for _, (facebox, feature) in enumerate(zip(detect_result, unknown_embeddings)): + code = self.check_face("None", image, facebox, prefix='featuredetect') + ret_data.append({'code':code, 'msg': ErrorMsg[code], 'data': [f"{feature.tobytes()},{str(feature.dtype)}", facebox]}) + + if len(ret_data) != 1: + ret_data = {'code':"30008", 'msg': ErrorMsg["30008"], 'data': ret_data} + else: + ret_data = ret_data[0] + + except Exception as e: + logger.info(f"{e}") + rw_lock.release_read() + raise e + else: + rw_lock.release_read() + return ret_data + # opt in ['add','delete','replace'] identity作为检索的标识符,img_path只是提供文件路径 # 写操作 def updateDB(self, img_path :str, opt :str, identity :str, Onlyrefresh=False): @@ -333,14 +378,14 @@ class FaceHelper: img = self.rotadjust(img) # 调整角度 if opt in ["add","replace"]: if opt == "add" and self.db_identities is not None and identity in self.db_identities: - raise UpdatedbError("401") # push: identity has exist. to pretect the db, reject opt of this time + raise UpdatedbError("30019") # push: identity has exist. to pretect the db, reject opt of this time else: detect_result = self.fd.detect(img) if len(detect_result) == 0: # no face logger.info(f"{img_path[:200]}: when update, no face in the image") print(f"{img_path[:200]}: when update, no face in the image") - raise FaceError("301") # push: no face in the image + raise FaceError("30018") # push: no face in the image else: # 获取最大的face,然后进行check # H, W = img.shape[:2] areas = [ box.area() for box in detect_result] @@ -348,7 +393,7 @@ class FaceHelper: facebox = detect_result[max_idx] facebox = (facebox.x1, facebox.y1, facebox.x2, facebox.y2) # top_left point, bottom_right point FaceError_number = self.check_face(img_path=img_path[:200], img=img, facebox=facebox, prefix='update') - if FaceError_number != "300": + if FaceError_number != "30002": raise FaceError(FaceError_number) cv2.imwrite(os.path.join(self.db_dir, identity+'.jpg'),img,[cv2.IMWRITE_JPEG_QUALITY, 100]) # 如果file已经存在,则会替换它 @@ -359,7 +404,7 @@ class FaceHelper: except FileNotFoundError: pass else: - raise NotImpltError("202") # push: this updateDB type is not support + raise NotImpltError("30007") # push: this updateDB type is not support print("end the updateDB") logger.info(f"end the updateDB") @@ -448,7 +493,7 @@ class FaceHelper: if check: FaceError_number = self.check_face(img_path=new_image[:200], img=image, facebox=facebox, prefix='refreshdb') - if FaceError_number != "300": + if FaceError_number != "30002": continue landmarks5 = self.ld5er.inference(image, facebox) # return: [(),(),(),(),()] 左眼 右眼 鼻子 左嘴角 右嘴角 @@ -489,14 +534,14 @@ class FaceHelper: if len(representations) <= 0: self.db_embeddings = None empty = True - # raise FileError("101") # push: no face in db + # raise FileError("30003") # push: no face in db else: self.db_embeddings = np.array([rep["embedding"] for rep in representations], dtype=np.float32) self.db_identities = [os.path.splitext(os.path.basename(rep["identity"]))[0] for rep in representations] redis_client.set(f"worker_{self.pid}", 1) # 当前进程已更新 if empty: logger.info("no face in the database") - raise FileError("101") # push: no face in db + raise FileError("30003") # push: no face in db def rotadjust(self, img: np.ndarray): image = img.copy() @@ -560,29 +605,29 @@ class FaceHelper: if facebox[0] < 0 or facebox[2] >= W: logger.info(f"{img_path}: when {prefix}, face shifted left/right") print(f"{img_path}: when {prefix}, face shifted left/right") - return "3041" # face shifted left/right, partially not captured. + return "30010" # face shifted left/right, partially not captured. if facebox[1] < 0 or facebox[3] >= H: logger.info(f"{img_path}: when {prefix}, face shifted top/bottom") print(f"{img_path}: when {prefix}, face shifted top/bottom") - return "3042" # face shifted top/bottom, partially not captured. + return "30011" # face shifted top/bottom, partially not captured. face_img = img[ max(0,int(facebox[1])):int(facebox[3]), max(0,int(facebox[0])):int(facebox[2]) ] if not self.qc.check_bright(face_img): logger.info(f"{img_path}: when {prefix}, bad bright face in the image") print(f"{img_path}: when {prefix}, bad bright face in the image") - return "303" # bad bright face in the image + return "30009" # bad bright face in the image if not self.qc.check_resolution(face_img): logger.info(f"{img_path}: when {prefix}, too small resolution of face in the image") print(f"{img_path}: when {prefix}, too small resolution of face in the image") - return "306" # small face in the image + return "30016" # small face in the image pose = self.qpose.check(face_img) if pose != "frontFace": logger.info(f"{img_path}: when {prefix}, {pose} in the image") print(f"{img_path}: when {prefix}, {pose} in the image") - dictt = {"rightFace": "3051", "leftFace": "3052", "upFace": "3053", "downFace": "3054"} + dictt = {"rightFace": "30012", "leftFace": "30013", "upFace": "30014", "downFace": "30015"} return dictt[pose] # pose of face in the image if not self.qclarity.check(face_img): logger.info(f"{img_path}: when {prefix}, bad clarity of face in the image") print(f"{img_path}: when {prefix}, bad clarity of face in the image") - return "307" # bad clarity of face in the image + return "30017" # poor clarity of face in the image - return "300" \ No newline at end of file + return "30002" \ No newline at end of file diff --git a/FaceRegWeb/readme.md b/FaceRegWeb5.2/FaceRegWeb/readme.md similarity index 88% rename from FaceRegWeb/readme.md rename to FaceRegWeb5.2/FaceRegWeb/readme.md index 675fad9..3963eaf 100644 --- a/FaceRegWeb/readme.md +++ b/FaceRegWeb5.2/FaceRegWeb/readme.md @@ -3,6 +3,7 @@ 项目细节详见docx文档. # requirements +``` fastapi 0.103.2 uvicorn[standard] 0.22.0 opencv-python 4.9.0.80 @@ -10,10 +11,11 @@ requests 2.31.0 Pillow 9.4.0 redis 5.0.6 onnxruntime 1.18.1 +``` 推荐使用 `pip install` 安装上述库,可以不遵循其版本号(这里写出具体版本是为了复现原运行环境). # file struct - +``` ./ checkpoints 储存模型的目录 models 方法函数目录 @@ -23,9 +25,10 @@ onnxruntime 1.18.1 redisLock.py 基于redis的读写锁 redis.yaml redis的配置文件 config.yaml 项目的配置文件 - setup.sh 启动项目的脚本(linux版本) + setup.sh 启动项目的脚本(linux版本) + reflushdb.sh 手动刷新数据库(usage: ./reflushdb.sh ip:port) readme.md 本文件 - +``` # setup `bash setup.sh [ip] [port] [进程数] [并发工作线程数]` e.g.: `bash setup.sh 0.0.0.0 8017 1 60` diff --git a/FaceRegWeb/redis.yaml b/FaceRegWeb5.2/FaceRegWeb/redis.yaml similarity index 100% rename from FaceRegWeb/redis.yaml rename to FaceRegWeb5.2/FaceRegWeb/redis.yaml diff --git a/FaceRegWeb/redisLock.py b/FaceRegWeb5.2/FaceRegWeb/redisLock.py similarity index 100% rename from FaceRegWeb/redisLock.py rename to FaceRegWeb5.2/FaceRegWeb/redisLock.py diff --git a/FaceRegWeb5.2/FaceRegWeb/reflushdb.sh b/FaceRegWeb5.2/FaceRegWeb/reflushdb.sh new file mode 100644 index 0000000..ea02f61 --- /dev/null +++ b/FaceRegWeb5.2/FaceRegWeb/reflushdb.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# keep input valid +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +# ip:host +SERVER=$1 +ENDPOINT="/refreshdb" + +# 使用 curl 调用接口 +response=$(curl -s -X POST "$SERVER$ENDPOINT" -H "Content-Type: application/json") + +# 打印响应 +echo "Response from $ENDPOINT: $response" + diff --git a/FaceRegWeb/setup.sh b/FaceRegWeb5.2/FaceRegWeb/setup.sh similarity index 100% rename from FaceRegWeb/setup.sh rename to FaceRegWeb5.2/FaceRegWeb/setup.sh diff --git a/FaceRegWeb/webmain.py b/FaceRegWeb5.2/FaceRegWeb/webmain.py similarity index 64% rename from FaceRegWeb/webmain.py rename to FaceRegWeb5.2/FaceRegWeb/webmain.py index 9d5cc90..7ea32ea 100644 --- a/FaceRegWeb/webmain.py +++ b/FaceRegWeb5.2/FaceRegWeb/webmain.py @@ -18,9 +18,10 @@ class face(BaseModel): class dbface(BaseModel): img:str optMode:str - imgName:str + uniqueKey:str @app.post("/refreshdb") +@app.post("/refreshdb/") def refresh(): global facehelper try: @@ -30,9 +31,9 @@ def refresh(): # return {"status":e.code, "detail":f"{e}"} return {'code': e.code, 'msg': f"{e}", 'data': 'None'} else: - return {'code': "300", 'msg': ErrorMsg['300'], 'data': 'None'} - + return {'code': "30002", 'msg': ErrorMsg['30002'], 'data': 'None'} +@app.post("/facerecognition") @app.post("/facerecognition/") def faceRecognition(input:face): start = time.time() @@ -49,19 +50,34 @@ def faceRecognition(input:face): return ret_data return {"status":1, "name":identity, "resImg":res_img_base64} +@app.post("/featuredetect") +@app.post("/featuredetect/") +def featureDetect(input:face): + start = time.time() + global facehelper + try: + ret_data = facehelper.featureDetect(input.img) + print("finished featuredetect...") + end = time.time() + print("runtime: ", end-start) + except Exception as e: + return {'code': e.code, 'msg': f"{e}", 'data': 'None'} + # return {"status":f"{e.code}", "detail":f"{e}"} + else: + return ret_data +@app.post("/updatedb") @app.post("/updatedb/") def updateDB(input:dbface): global facehelper - # 在这儿加一句,只取imgName中第一个`.`前面的部分str - input.imgName = os.path.splitext(os.path.basename(input.imgName))[0] + # input.uniqueKey = os.path.splitext(os.path.basename(input.uniqueKey))[0] try: with lock: - facehelper.updateDB(input.img, input.optMode, input.imgName) + facehelper.updateDB(input.img, input.optMode, input.uniqueKey) except Exception as e: return {'code': e.code, 'msg': f"{e}", 'data': 'None'} # return {"status":f"{e.code}", "detail":f"{e}"} else: - return {'code': "300", 'msg': ErrorMsg['300'], 'data': 'None'} + return {'code': "30002", 'msg': ErrorMsg['30002'], 'data': 'None'} diff --git a/FaceRegWeb5.2/人脸识别web端使用说明V5.2.docx b/FaceRegWeb5.2/人脸识别web端使用说明V5.2.docx new file mode 100644 index 0000000..d45dc5a Binary files /dev/null and b/FaceRegWeb5.2/人脸识别web端使用说明V5.2.docx differ diff --git a/FaceRegWeb/docx/facereg知识介绍.docx b/FaceRegWeb5.2/人脸识别代码详解和调试.docx similarity index 61% rename from FaceRegWeb/docx/facereg知识介绍.docx rename to FaceRegWeb5.2/人脸识别代码详解和调试.docx index d5dd337..feac837 100644 Binary files a/FaceRegWeb/docx/facereg知识介绍.docx and b/FaceRegWeb5.2/人脸识别代码详解和调试.docx differ diff --git a/FaceRegWeb/docx/人脸识别组件测试报告.docx b/FaceRegWeb5.2/人脸识别组件测试报告.docx similarity index 100% rename from FaceRegWeb/docx/人脸识别组件测试报告.docx rename to FaceRegWeb5.2/人脸识别组件测试报告.docx diff --git a/FaceRegWeb5.2/人脸识别需求设计说明书V5.2.docx b/FaceRegWeb5.2/人脸识别需求设计说明书V5.2.docx new file mode 100644 index 0000000..b6b9c66 Binary files /dev/null and b/FaceRegWeb5.2/人脸识别需求设计说明书V5.2.docx differ