This commit is contained in:
恍兮惚兮 2024-12-14 18:21:46 +08:00
parent 361410ab75
commit e2e9f48c1e
26 changed files with 74 additions and 54 deletions

View File

@ -207,9 +207,9 @@ def downloadCurl():
def downloadOCRModel():
os.chdir(rootDir + "\\files")
if not os.path.exists("ocr"):
os.mkdir("ocr")
os.chdir("ocr")
if not os.path.exists("ocrmodel"):
os.mkdir("ocrmodel")
os.chdir("ocrmodel")
subprocess.run(f"curl -LO {mylinks['ocr_models']['ja.zip']}")
subprocess.run(f"7z x ja.zip")
os.remove(f"ja.zip")

2
.gitignore vendored
View File

@ -27,7 +27,7 @@ py/.q_vscode_style
py/userconfig
py/cache
py/chrome_cache
py/files/ocr
py/files/ocrmodel
py/files/plugins
py/files/themes
py/run37.bat

View File

@ -1,7 +1,7 @@
set(VERSION_MAJOR 6)
set(VERSION_MINOR 11)
set(VERSION_PATCH 6)
set(VERSION_PATCH 7)
set(VERSION_REVISION 0)
set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}")
add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp)

View File

@ -251,7 +251,7 @@ def versionlabelmaybesettext(self, x):
def solvelinkitems(grid, source):
name = source["name"]
link = source["link"]
grid.append([((name), 1, ""), (makehtml(link), 2, "link")])
grid.append([name, (makehtml(link), 2, "link")])
def resourcegrid(self, l):
@ -265,7 +265,7 @@ def resourcegrid(self, l):
__grid = []
for link in source["links"]:
solvelinkitems(__grid, link)
__grid.append([link["name"], (makehtml(link["link"]), 2, "link")])
grid.append(
[
(

View File

@ -1810,7 +1810,7 @@ def automakegrid(grid: QGridLayout, lis, save=False, savelist=None):
elif len(item) == 3:
wid, cols, arg = item
if type(wid) == str:
wid = LLabel(wid)
wid = QLabel(wid)
if arg == "link":
wid.setOpenExternalLinks(True)
elif arg == "group":

View File

@ -88,18 +88,29 @@ class ocrwrapper:
_OcrDestroy(self.pOcrObj)
def findmodel(langcode):
check = lambda path: (
os.path.exists(path + "/det.onnx")
and os.path.exists(path + "/rec.onnx")
and os.path.exists(path + "/dict.txt")
)
for path in [
"./files/ocrmodel/{}".format(langcode),
"cache/ocrmodel/{}".format(langcode),
]:
if check(path):
return path
def getallsupports():
langs = []
for f in os.listdir("./files/ocr"):
path = "./files/ocr/{}".format(f)
if not (
os.path.exists(path + "/det.onnx")
and os.path.exists(path + "/rec.onnx")
and os.path.exists(path + "/dict.txt")
):
continue
langs.append(f)
return langs
validlangs = []
for d in ["./files/ocrmodel", "cache/ocrmodel"]:
if os.path.exists(d):
for lang in os.listdir(d):
if findmodel(lang):
validlangs.append(lang)
return validlangs
def dodownload(combo: QComboBox, allsupports: list):
@ -117,7 +128,7 @@ def doinstall(self, combo: QComboBox, allsupports: list, parent, callback):
return
try:
with zipfile.ZipFile(fn) as zipf:
zipf.extractall("files/ocr")
zipf.extractall("cache/ocrmodel")
getQMessageBox(self, "成功", "安装成功")
callback()
except:
@ -167,22 +178,11 @@ class OCR(baseocr):
self._savelang = None
self.checkchange()
def checklangvalid(self, langcode):
path = "./files/ocr/{}".format(langcode)
return (
os.path.exists(path + "/det.onnx")
and os.path.exists(path + "/rec.onnx")
and os.path.exists(path + "/dict.txt")
)
def checkchange(self):
if self._savelang == self.srclang:
return
if self.srclang == "auto":
validlangs = []
for lang in os.listdir("./files/ocr"):
if self.checklangvalid(lang):
validlangs.append(lang)
validlangs = getallsupports()
if len(validlangs) == 1:
uselang = validlangs[0]
elif len(validlangs) == 0:
@ -190,7 +190,7 @@ class OCR(baseocr):
else:
self.raise_cant_be_auto_lang()
else:
if self.checklangvalid(self.srclang):
if findmodel(self.srclang):
uselang = self.srclang
else:
raise Exception(
@ -206,7 +206,7 @@ class OCR(baseocr):
)
self._ocr = None
path = "./files/ocr/{}".format(uselang)
path = findmodel(uselang)
self._ocr = ocrwrapper(
path + "/det.onnx", path + "/rec.onnx", path + "/dict.txt"
)

View File

@ -754,5 +754,6 @@
"截取指定行数": "اعتراض عدد محدد من الصفوف",
"截取末尾": "اعتراض نهاية",
"更新记录": "تحديث السجلات",
"打开选择文本窗口": "فتح نافذة اختيار النص"
"打开选择文本窗口": "فتح نافذة اختيار النص",
"成功": "النجاح ."
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "截取指定行數",
"截取末尾": "截取末尾",
"更新记录": "更新記錄",
"打开选择文本窗口": "打開選擇文字視窗"
"打开选择文本窗口": "打開選擇文字視窗",
"成功": "成功"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "Extrahovat zadaný počet řádků",
"截取末尾": "Střih do konce",
"更新记录": "Aktualizovat záznam",
"打开选择文本窗口": "Otevřít textové okno výběru"
"打开选择文本窗口": "Otevřít textové okno výběru",
"成功": "úspěch"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "Die angegebene Anzahl von Zeilen extrahieren",
"截取末尾": "Bis zum Ende geschnitten",
"更新记录": "Datensatz aktualisieren",
"打开选择文本窗口": "Öffnen des Auswahltextfensters"
"打开选择文本窗口": "Öffnen des Auswahltextfensters",
"成功": "Erfolg"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "Extract the specified number of rows",
"截取末尾": "Cut to the end",
"更新记录": "Update Record",
"打开选择文本窗口": "Open the selection text window"
"打开选择文本窗口": "Open the selection text window",
"成功": "success"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "Interceptar el número de líneas especificadas",
"截取末尾": "Fin de la interceptación",
"更新记录": "Actualización de registros",
"打开选择文本窗口": "Abrir la ventana de texto de selección"
"打开选择文本窗口": "Abrir la ventana de texto de selección",
"成功": "éxito"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "Intercepte le nombre de lignes spécifié",
"截取末尾": "Fin de l'interception",
"更新记录": "Mettre à jour les enregistrements",
"打开选择文本窗口": "Ouvrir la fenêtre sélectionner le texte"
"打开选择文本窗口": "Ouvrir la fenêtre sélectionner le texte",
"成功": "Succès"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "Estrarre il numero specificato di righe",
"截取末尾": "Taglia fino alla fine",
"更新记录": "Aggiorna record",
"打开选择文本窗口": "Apri la finestra del testo di selezione"
"打开选择文本窗口": "Apri la finestra del testo di selezione",
"成功": "successo"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "指定した行数を切り取る",
"截取末尾": "末尾を切り取る",
"更新记录": "レコードの更新",
"打开选择文本窗口": "テキストの選択ウィンドウを開く"
"打开选择文本窗口": "テキストの選択ウィンドウを開く",
"成功": "成功"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "지정된 행 수 캡처",
"截取末尾": "끝을 가로채다",
"更新记录": "레코드 업데이트",
"打开选择文本窗口": "텍스트 선택 창 열기"
"打开选择文本窗口": "텍스트 선택 창 열기",
"成功": "성공"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "Het opgegeven aantal rijen uitpakken",
"截取末尾": "Snijd tot het einde",
"更新记录": "Record bijwerken",
"打开选择文本窗口": "Het selectietekstvenster openen"
"打开选择文本窗口": "Het selectietekstvenster openen",
"成功": "succes"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "Wyciągnij określoną liczbę wierszy",
"截取末尾": "Cięcie do końca",
"更新记录": "Aktualizuj rekord",
"打开选择文本窗口": "Otwórz okno tekstowe zaznaczenia"
"打开选择文本窗口": "Otwórz okno tekstowe zaznaczenia",
"成功": "sukces"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "Extrair o número especificado de linhas",
"截取末尾": "Cortar até ao fim",
"更新记录": "Actualizar o Registo",
"打开选择文本窗口": "Abrir a janela de texto da selecção"
"打开选择文本窗口": "Abrir a janela de texto da selecção",
"成功": "sucesso"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "Перехватить указанное число строк",
"截取末尾": "Отрезать конец",
"更新记录": "Обновить запись",
"打开选择文本窗口": "Открыть окно выбора текста"
"打开选择文本窗口": "Открыть окно выбора текста",
"成功": "Успех"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "Extrahera angivet antal rader",
"截取末尾": "Klipp till slutet",
"更新记录": "Uppdatera post",
"打开选择文本窗口": "Öppna markeringstextfönstret"
"打开选择文本窗口": "Öppna markeringstextfönstret",
"成功": "framgång"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "สกัดกั้นจำนวนแถวที่ระบุ",
"截取末尾": "ตัดตอนท้าย",
"更新记录": "บันทึกการปรับปรุง",
"打开选择文本窗口": "เปิดหน้าต่างเลือกข้อความ"
"打开选择文本窗口": "เปิดหน้าต่างเลือกข้อความ",
"成功": "ความสำเร็จ"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "Belirtilen satır sayısını çıkart",
"截取末尾": "Sonuna kesin.",
"更新记录": "Kayıt Güncelle",
"打开选择文本窗口": "Seçim metin penceresini aç"
"打开选择文本窗口": "Seçim metin penceresini aç",
"成功": "başarılı"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "Extract the specified number of rows",
"截取末尾": "Вирізати до кінця",
"更新记录": "Оновити запис",
"打开选择文本窗口": "Відкрити текстове вікно вибору"
"打开选择文本窗口": "Відкрити текстове вікно вибору",
"成功": "успіх"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "Chặn số dòng đã xác định",
"截取末尾": "Kết thúc cắt",
"更新记录": "Cập nhật hồ sơ",
"打开选择文本窗口": "Mở cửa sổ Select Text"
"打开选择文本窗口": "Mở cửa sổ Select Text",
"成功": "Thành công"
}

View File

@ -754,5 +754,6 @@
"截取指定行数": "",
"截取末尾": "",
"更新记录": "",
"打开选择文本窗口": ""
"打开选择文本窗口": "",
"成功": ""
}