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(): def downloadOCRModel():
os.chdir(rootDir + "\\files") os.chdir(rootDir + "\\files")
if not os.path.exists("ocr"): if not os.path.exists("ocrmodel"):
os.mkdir("ocr") os.mkdir("ocrmodel")
os.chdir("ocr") os.chdir("ocrmodel")
subprocess.run(f"curl -LO {mylinks['ocr_models']['ja.zip']}") subprocess.run(f"curl -LO {mylinks['ocr_models']['ja.zip']}")
subprocess.run(f"7z x ja.zip") subprocess.run(f"7z x ja.zip")
os.remove(f"ja.zip") os.remove(f"ja.zip")

2
.gitignore vendored
View File

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

View File

@ -1,7 +1,7 @@
set(VERSION_MAJOR 6) set(VERSION_MAJOR 6)
set(VERSION_MINOR 11) set(VERSION_MINOR 11)
set(VERSION_PATCH 6) set(VERSION_PATCH 7)
set(VERSION_REVISION 0) set(VERSION_REVISION 0)
set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}") set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}")
add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp) 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): def solvelinkitems(grid, source):
name = source["name"] name = source["name"]
link = source["link"] link = source["link"]
grid.append([((name), 1, ""), (makehtml(link), 2, "link")]) grid.append([name, (makehtml(link), 2, "link")])
def resourcegrid(self, l): def resourcegrid(self, l):
@ -265,7 +265,7 @@ def resourcegrid(self, l):
__grid = [] __grid = []
for link in source["links"]: for link in source["links"]:
solvelinkitems(__grid, link) __grid.append([link["name"], (makehtml(link["link"]), 2, "link")])
grid.append( grid.append(
[ [
( (

View File

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

View File

@ -88,18 +88,29 @@ class ocrwrapper:
_OcrDestroy(self.pOcrObj) _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(): def getallsupports():
langs = [] validlangs = []
for f in os.listdir("./files/ocr"): for d in ["./files/ocrmodel", "cache/ocrmodel"]:
path = "./files/ocr/{}".format(f) if os.path.exists(d):
if not ( for lang in os.listdir(d):
os.path.exists(path + "/det.onnx") if findmodel(lang):
and os.path.exists(path + "/rec.onnx") validlangs.append(lang)
and os.path.exists(path + "/dict.txt") return validlangs
):
continue
langs.append(f)
return langs
def dodownload(combo: QComboBox, allsupports: list): def dodownload(combo: QComboBox, allsupports: list):
@ -117,7 +128,7 @@ def doinstall(self, combo: QComboBox, allsupports: list, parent, callback):
return return
try: try:
with zipfile.ZipFile(fn) as zipf: with zipfile.ZipFile(fn) as zipf:
zipf.extractall("files/ocr") zipf.extractall("cache/ocrmodel")
getQMessageBox(self, "成功", "安装成功") getQMessageBox(self, "成功", "安装成功")
callback() callback()
except: except:
@ -167,22 +178,11 @@ class OCR(baseocr):
self._savelang = None self._savelang = None
self.checkchange() 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): def checkchange(self):
if self._savelang == self.srclang: if self._savelang == self.srclang:
return return
if self.srclang == "auto": if self.srclang == "auto":
validlangs = [] validlangs = getallsupports()
for lang in os.listdir("./files/ocr"):
if self.checklangvalid(lang):
validlangs.append(lang)
if len(validlangs) == 1: if len(validlangs) == 1:
uselang = validlangs[0] uselang = validlangs[0]
elif len(validlangs) == 0: elif len(validlangs) == 0:
@ -190,7 +190,7 @@ class OCR(baseocr):
else: else:
self.raise_cant_be_auto_lang() self.raise_cant_be_auto_lang()
else: else:
if self.checklangvalid(self.srclang): if findmodel(self.srclang):
uselang = self.srclang uselang = self.srclang
else: else:
raise Exception( raise Exception(
@ -206,7 +206,7 @@ class OCR(baseocr):
) )
self._ocr = None self._ocr = None
path = "./files/ocr/{}".format(uselang) path = findmodel(uselang)
self._ocr = ocrwrapper( self._ocr = ocrwrapper(
path + "/det.onnx", path + "/rec.onnx", path + "/dict.txt" 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ů", "截取指定行数": "Extrahovat zadaný počet řádků",
"截取末尾": "Střih do konce", "截取末尾": "Střih do konce",
"更新记录": "Aktualizovat záznam", "更新记录": "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", "截取指定行数": "Die angegebene Anzahl von Zeilen extrahieren",
"截取末尾": "Bis zum Ende geschnitten", "截取末尾": "Bis zum Ende geschnitten",
"更新记录": "Datensatz aktualisieren", "更新记录": "Datensatz aktualisieren",
"打开选择文本窗口": "Öffnen des Auswahltextfensters" "打开选择文本窗口": "Öffnen des Auswahltextfensters",
"成功": "Erfolg"
} }

View File

@ -754,5 +754,6 @@
"截取指定行数": "Extract the specified number of rows", "截取指定行数": "Extract the specified number of rows",
"截取末尾": "Cut to the end", "截取末尾": "Cut to the end",
"更新记录": "Update Record", "更新记录": "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", "截取指定行数": "Interceptar el número de líneas especificadas",
"截取末尾": "Fin de la interceptación", "截取末尾": "Fin de la interceptación",
"更新记录": "Actualización de registros", "更新记录": "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é", "截取指定行数": "Intercepte le nombre de lignes spécifié",
"截取末尾": "Fin de l'interception", "截取末尾": "Fin de l'interception",
"更新记录": "Mettre à jour les enregistrements", "更新记录": "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", "截取指定行数": "Estrarre il numero specificato di righe",
"截取末尾": "Taglia fino alla fine", "截取末尾": "Taglia fino alla fine",
"更新记录": "Aggiorna record", "更新记录": "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", "截取指定行数": "Het opgegeven aantal rijen uitpakken",
"截取末尾": "Snijd tot het einde", "截取末尾": "Snijd tot het einde",
"更新记录": "Record bijwerken", "更新记录": "Record bijwerken",
"打开选择文本窗口": "Het selectietekstvenster openen" "打开选择文本窗口": "Het selectietekstvenster openen",
"成功": "succes"
} }

View File

@ -754,5 +754,6 @@
"截取指定行数": "Wyciągnij określoną liczbę wierszy", "截取指定行数": "Wyciągnij określoną liczbę wierszy",
"截取末尾": "Cięcie do końca", "截取末尾": "Cięcie do końca",
"更新记录": "Aktualizuj rekord", "更新记录": "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", "截取指定行数": "Extrair o número especificado de linhas",
"截取末尾": "Cortar até ao fim", "截取末尾": "Cortar até ao fim",
"更新记录": "Actualizar o Registo", "更新记录": "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", "截取指定行数": "Extrahera angivet antal rader",
"截取末尾": "Klipp till slutet", "截取末尾": "Klipp till slutet",
"更新记录": "Uppdatera post", "更新记录": "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", "截取指定行数": "Belirtilen satır sayısını çıkart",
"截取末尾": "Sonuna kesin.", "截取末尾": "Sonuna kesin.",
"更新记录": "Kayıt Güncelle", "更新记录": "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", "截取指定行数": "Extract the specified number of rows",
"截取末尾": "Вирізати до кінця", "截取末尾": "Вирізати до кінця",
"更新记录": "Оновити запис", "更新记录": "Оновити запис",
"打开选择文本窗口": "Відкрити текстове вікно вибору" "打开选择文本窗口": "Відкрити текстове вікно вибору",
"成功": "успіх"
} }

View File

@ -754,5 +754,6 @@
"截取指定行数": "Chặn số dòng đã xác định", "截取指定行数": "Chặn số dòng đã xác định",
"截取末尾": "Kết thúc cắt", "截取末尾": "Kết thúc cắt",
"更新记录": "Cập nhật hồ sơ", "更新记录": "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 @@
"截取指定行数": "", "截取指定行数": "",
"截取末尾": "", "截取末尾": "",
"更新记录": "", "更新记录": "",
"打开选择文本窗口": "" "打开选择文本窗口": "",
"成功": ""
} }