Преглед изворни кода

idc ocr v2.3: fix none words picture

Tinger пре 2 година
родитељ
комит
4819198860
1 измењених фајлова са 4 додато и 4 уклоњено
  1. 4 4
      blues/idc.py

+ 4 - 4
blues/idc.py

@@ -86,11 +86,11 @@ class IdcView(views.MethodView):
         for idx, (ocr_res, _) in enumerate(rec):
             words = [it[1][0].replace(" ", "") for it in ocr_res]
             if which == "face":
-                if not words[0].startswith("姓名"):
+                if not words or not words[0].startswith("姓名"):
                     continue
                 info, msg, sta = get_face_info(words)
             else:
-                if not words[0].startswith("中华"):
+                if not words or not words[0].startswith("中华"):
                     continue
                 info, msg, sta = get_icon_info(words)
             if sta:
@@ -126,11 +126,11 @@ class IdcHtmlView(views.MethodView):
         for idx, (ocr_res, _) in enumerate(rec):
             words = [it[1][0].replace(" ", "") for it in ocr_res]
             if which == "face":
-                if not words[0].startswith("姓名"):
+                if not words or not words[0].startswith("姓名"):
                     continue
                 info, msg, sta = get_face_info(words)
             else:
-                if not words[0].startswith("中华"):
+                if not words or not words[0].startswith("中华"):
                     continue
                 info, msg, sta = get_icon_info(words)
             if sta: