diff --git a/README.md b/README.md index 537388e..b56d8d2 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ # Pot-App Paddle OCR 插件 (基于 [PaddleOCR-json](https://github.com/hiroi-sora/PaddleOCR-json)) + +> 此插件只支持 Windows x64 diff --git a/info.json b/info.json index 9e1763c..f685327 100644 --- a/info.json +++ b/info.json @@ -6,27 +6,15 @@ "homepage": "https://github.com/pot-app/pot-app-recognize-plugin-paddle", "needs": [], "language": { - "auto": "", - "zh_cn": "", - "zh_tw": "", - "en": "", - "ja": "", - "ko": "", - "fr": "", - "es": "", - "ru": "", - "de": "", - "it": "", - "tr": "", - "pt_pt": "", - "pt_br": "", - "vi": "", - "id": "", - "th": "", - "ms": "", - "ar": "", - "hi": "", - "mn_cy": "", - "km": "" + "auto": "chinese", + "zh_cn": "chinese", + "zh_tw": "chinese_cht", + "en": "en", + "ja": "japan", + "ko": "korean", + "fr": "french_v2", + "ru": "cyrillic", + "de": "german_v2", + "mn_cy": "cyrillic" } } diff --git a/src/lib.rs b/src/lib.rs index cbbdaa1..4ef4843 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,15 +1,14 @@ use dirs::{cache_dir, config_dir}; -use serde_json::{json, Value}; +use serde_json::Value; use std::collections::HashMap; use std::error::Error; -#[cfg(target_os = "windows")] use std::os::windows::process::CommandExt; use std::process::Command; #[no_mangle] pub fn recognize( _base64: &str, - _lang: &str, + lang: &str, _needs: HashMap, ) -> Result> { let config_dir_path = config_dir().unwrap(); @@ -33,7 +32,10 @@ pub fn recognize( let output = cmd .current_dir(paddle_dir_path) + .arg("use_angle_cls=true") + .arg("cls=true") .arg(&format!("--image_path={}", image_path.to_str().unwrap())) + .arg(&format!("--config_path=models/config_{}.txt", lang)) .output()?; let result = String::from_utf8_lossy(&output.stdout); @@ -62,7 +64,7 @@ mod tests { #[test] fn try_request() { let needs = HashMap::new(); - let result = recognize("", "", needs); + let result = recognize("", "chinese", needs); println!("{result:?}"); } }