Sfoglia il codice sorgente

idc ocr v2.3: fix none words picture

Tinger 2 anni fa
parent
commit
4819198860
1 ha cambiato i file con 4 aggiunte e 4 eliminazioni
  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: