|
@@ -7,7 +7,8 @@ from time import localtime, strftime
|
|
from paddleocr.tools.infer.utility import draw_box_txt_fine
|
|
from paddleocr.tools.infer.utility import draw_box_txt_fine
|
|
|
|
|
|
__all__ = [
|
|
__all__ = [
|
|
- "Args", "Response", "rand_str", "current_time", "get_ext_name", "is_image_ext", "recognize", "draw_img"
|
|
|
|
|
|
+ "Args", "Response", "rand_str", "current_time", "get_ext_name", "is_image_ext", "recognize", "draw_img",
|
|
|
|
+ "json_all"
|
|
]
|
|
]
|
|
|
|
|
|
__StrBase = "qwertyuioplkjhgfdsazxcvbnm1234567890ZXCVBNMLKJHGFDSAQWERTYUIOP"
|
|
__StrBase = "qwertyuioplkjhgfdsazxcvbnm1234567890ZXCVBNMLKJHGFDSAQWERTYUIOP"
|
|
@@ -113,3 +114,21 @@ def draw_img(shape: "tuple", data: "list[dict]", path: "str", drop: "float" = 0.
|
|
img = cv2.bitwise_and(img, text) # noqa
|
|
img = cv2.bitwise_and(img, text) # noqa
|
|
|
|
|
|
cv2.imwrite(path, np.array(img)) # noqa
|
|
cv2.imwrite(path, np.array(img)) # noqa
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def json_all(data: "dict or list") -> "bool":
|
|
|
|
+ if isinstance(data, list):
|
|
|
|
+ for item in data:
|
|
|
|
+ if isinstance(item, str) and not item:
|
|
|
|
+ return False
|
|
|
|
+ elif isinstance(item, (list, dict)) and not json_all(item):
|
|
|
|
+ return False
|
|
|
|
+ return True
|
|
|
|
+ elif isinstance(data, dict):
|
|
|
|
+ for value in data.values():
|
|
|
|
+ if isinstance(value, str) and not value:
|
|
|
|
+ return False
|
|
|
|
+ elif isinstance(value, (list, dict)) and not json_all(value):
|
|
|
|
+ return False
|
|
|
|
+ return True
|
|
|
|
+ raise TypeError(f"except node type are: [list, dict], but got a {type(data)} instead.")
|