Update app.py
Browse files
app.py
CHANGED
|
@@ -67,7 +67,6 @@ portraitReplaceThreshold = 0.5
|
|
| 67 |
printedCopyThreshold = 0.5
|
| 68 |
|
| 69 |
def activate_id_ocr_sdk():
|
| 70 |
-
return -1
|
| 71 |
id_ocr_key = os.environ.get("LICENSE_KEY")
|
| 72 |
id_ocr_dict_path = os.path.join(root_path, "id_ocr/engine/bin")
|
| 73 |
|
|
@@ -89,17 +88,12 @@ def activate_id_ocr_sdk():
|
|
| 89 |
else:
|
| 90 |
print_error(f"Falied to activate ID OCR SDK, Error code {ret}")
|
| 91 |
|
|
|
|
| 92 |
return ret
|
| 93 |
|
| 94 |
def activate_id_live_sdk():
|
| 95 |
-
print("id live sdk activation start")
|
| 96 |
-
sys.stdout.flush()
|
| 97 |
id_live_key = os.environ.get("ID_LIVE_LICENSE_KEY")
|
| 98 |
-
print(id_live_key)
|
| 99 |
-
sys.stdout.flush()
|
| 100 |
id_live_dict_path = os.path.join(root_path, "id_live/engine/model")
|
| 101 |
-
print(id_live_dict_path)
|
| 102 |
-
sys.stdout.flush()
|
| 103 |
ret = -1
|
| 104 |
if id_live_key is None:
|
| 105 |
print_warning("ID LIVE license key not found!")
|
|
@@ -107,13 +101,8 @@ def activate_id_live_sdk():
|
|
| 107 |
else:
|
| 108 |
ret = id_live_header.set_activation(id_live_key.encode('utf-8'))
|
| 109 |
|
| 110 |
-
print(f"activation result {ret}")
|
| 111 |
-
sys.stdout.flush()
|
| 112 |
if ret == 0:
|
| 113 |
ret = id_live_header.init_sdk(id_live_dict_path.encode('utf-8'))
|
| 114 |
-
print(f"init result {ret}")
|
| 115 |
-
sys.stdout.flush()
|
| 116 |
-
|
| 117 |
if ret == 0:
|
| 118 |
print_log("Successfully init ID LIVE SDK!")
|
| 119 |
else:
|
|
@@ -121,6 +110,7 @@ def activate_id_live_sdk():
|
|
| 121 |
else:
|
| 122 |
print_error(f"Falied to activate ID LIVE SDK, Error code {ret}")
|
| 123 |
|
|
|
|
| 124 |
return ret
|
| 125 |
|
| 126 |
def find_key_in_dict(d, target_key):
|
|
@@ -250,8 +240,10 @@ def check_liveness(frame):
|
|
| 250 |
detResult = "spoof"
|
| 251 |
|
| 252 |
# Update json_result with the modified process_results
|
|
|
|
| 253 |
return {"status": "ok", "data": {"result": detResult, "screenreplay_integrity_score": screenReply, "portraitreplace_integrity_score": portraitReplace, "printedcutout_integrity_score": printedCopy}}
|
| 254 |
-
|
|
|
|
| 255 |
return {"status": "error", "result": "document not found!"}
|
| 256 |
|
| 257 |
|
|
|
|
| 67 |
printedCopyThreshold = 0.5
|
| 68 |
|
| 69 |
def activate_id_ocr_sdk():
|
|
|
|
| 70 |
id_ocr_key = os.environ.get("LICENSE_KEY")
|
| 71 |
id_ocr_dict_path = os.path.join(root_path, "id_ocr/engine/bin")
|
| 72 |
|
|
|
|
| 88 |
else:
|
| 89 |
print_error(f"Falied to activate ID OCR SDK, Error code {ret}")
|
| 90 |
|
| 91 |
+
sys.stdout.flush()
|
| 92 |
return ret
|
| 93 |
|
| 94 |
def activate_id_live_sdk():
|
|
|
|
|
|
|
| 95 |
id_live_key = os.environ.get("ID_LIVE_LICENSE_KEY")
|
|
|
|
|
|
|
| 96 |
id_live_dict_path = os.path.join(root_path, "id_live/engine/model")
|
|
|
|
|
|
|
| 97 |
ret = -1
|
| 98 |
if id_live_key is None:
|
| 99 |
print_warning("ID LIVE license key not found!")
|
|
|
|
| 101 |
else:
|
| 102 |
ret = id_live_header.set_activation(id_live_key.encode('utf-8'))
|
| 103 |
|
|
|
|
|
|
|
| 104 |
if ret == 0:
|
| 105 |
ret = id_live_header.init_sdk(id_live_dict_path.encode('utf-8'))
|
|
|
|
|
|
|
|
|
|
| 106 |
if ret == 0:
|
| 107 |
print_log("Successfully init ID LIVE SDK!")
|
| 108 |
else:
|
|
|
|
| 110 |
else:
|
| 111 |
print_error(f"Falied to activate ID LIVE SDK, Error code {ret}")
|
| 112 |
|
| 113 |
+
sys.stdout.flush()
|
| 114 |
return ret
|
| 115 |
|
| 116 |
def find_key_in_dict(d, target_key):
|
|
|
|
| 240 |
detResult = "spoof"
|
| 241 |
|
| 242 |
# Update json_result with the modified process_results
|
| 243 |
+
sys.stdout.flush()
|
| 244 |
return {"status": "ok", "data": {"result": detResult, "screenreplay_integrity_score": screenReply, "portraitreplace_integrity_score": portraitReplace, "printedcutout_integrity_score": printedCopy}}
|
| 245 |
+
|
| 246 |
+
sys.stdout.flush()
|
| 247 |
return {"status": "error", "result": "document not found!"}
|
| 248 |
|
| 249 |
|