Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pylogmon committed Sep 26, 2023
1 parent 54acb58 commit e073127
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Pot-App Paddle OCR 插件 (基于 [PaddleOCR-json](https://github.com/hiroi-sora/PaddleOCR-json))

> 此插件只支持 Windows x64
32 changes: 10 additions & 22 deletions info.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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<String, String>,
) -> Result<Value, Box<dyn Error>> {
let config_dir_path = config_dir().unwrap();
Expand All @@ -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);
Expand Down Expand Up @@ -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:?}");
}
}

0 comments on commit e073127

Please sign in to comment.