Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

ocr_CN_support

Ren63b92d0bf86a
diff --git a/Cargo.toml b/Cargo.toml
index c10986594..024e294f0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -43,5 +43,8 @@ git = "https://github.com/microsoft/vcpkg"
rev = "2023.04.15"
dynamic = true
+# [dependencies]
+axum = "0.7" # 使用与您项目兼容的版本
+
diff --git a/screenpipe-server/Cargo.toml b/screenpipe-server/Cargo.toml
index db214d66b..1ff26409a 100644
--- a/screenpipe-server/Cargo.toml
+++ b/screenpipe-server/Cargo.toml
@@ -56,7 +56,7 @@ sysinfo = "0.29.0"
colored = "2.0"
# Plugins
-tower = "0.4"
+tower = { version = "0.5", features = ["util"] }
futures = "0.3.17"
# Directory management
diff --git a/screenpipe-server/tests/tags_test.rs b/screenpipe-server/tests/tags_test.rs
index 81150368b..9bef78ae4 100644
--- a/screenpipe-server/tests/tags_test.rs
+++ b/screenpipe-server/tests/tags_test.rs
@@ -400,4 +400,4 @@ async fn insert_test_data(db: &Arc<DatabaseManager>) {
)
.await
.unwrap();
-}
+}
\ No newline at end of file
diff --git a/screenpipe-vision/Cargo.toml b/screenpipe-vision/Cargo.toml
index 56e2a5c2a..ad6751f19 100644
--- a/screenpipe-vision/Cargo.toml
+++ b/screenpipe-vision/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-vision"
-version = { workspace = true }
+version = "0.1.93"
authors = { workspace = true }
description = { workspace = true }
repository = { workspace = true }
@@ -38,6 +38,8 @@ screenpipe-integrations = { path = "../screenpipe-integrations" }
tracing-subscriber = { workspace = true }
tracing = { workspace = true }
+axum = "0.7"
+
[dev-dependencies]
tempfile = "3.3.0"
criterion = { workspace = true }
diff --git a/screenpipe-vision/lib/libscreenpipe.dylib b/screenpipe-vision/lib/libscreenpipe.dylib
index 06c4f1e1b..55caba125 100755
Binary files a/screenpipe-vision/lib/libscreenpipe.dylib and b/screenpipe-vision/lib/libscreenpipe.dylib differ
diff --git a/screenpipe-vision/lib/libscreenpipe_arm64.dylib b/screenpipe-vision/lib/libscreenpipe_arm64.dylib
index 6edc908a9..4a198dc10 100755
Binary files a/screenpipe-vision/lib/libscreenpipe_arm64.dylib and b/screenpipe-vision/lib/libscreenpipe_arm64.dylib differ
diff --git a/screenpipe-vision/lib/libscreenpipe_x86_64.dylib b/screenpipe-vision/lib/libscreenpipe_x86_64.dylib
index 66bb8f0a3..5d3d2be5c 100755
Binary files a/screenpipe-vision/lib/libscreenpipe_x86_64.dylib and b/screenpipe-vision/lib/libscreenpipe_x86_64.dylib differ
diff --git a/screenpipe-vision/src/ocr.swift b/screenpipe-vision/src/ocr.swift
index c377a116c..8a586ec92 100644
--- a/screenpipe-vision/src/ocr.swift
+++ b/screenpipe-vision/src/ocr.swift
@@ -34,15 +34,16 @@ public func performOCR(imageData: UnsafePointer<UInt8>, length: Int, width: Int,
let context = CIContext(options: nil)
// Apply preprocessing filters (slightly reduced contrast compared to original)
- let processed =
- ciImage
- .applyingFilter(
- "CIColorControls", parameters: [kCIInputSaturationKey: 0, kCIInputContrastKey: 1.08]
- )
- .applyingFilter(
- "CIUnsharpMask", parameters: [kCIInputRadiusKey: 0.8, kCIInputIntensityKey: 0.4])
-
- guard let preprocessedCGImage = context.createCGImage(processed, from: processed.extent) else {
+ // let processed =
+ // ciImage
+ // .applyingFilter(
+ // "CIColorControls", parameters: [kCIInputContrastKey: 1.2]
+ // )
+ // .applyingFilter(
+ // "CIUnsharpMask", parameters: [kCIInputRadiusKey: 0.5, kCIInputIntensityKey: 0.7])
+ let processed = ciImage
+
+ guard let preprocessedCGImage = context.createCGImage(ciImage, from: ciImage.extent) else {
return strdup("Error: Failed to create preprocessed image")
}
@@ -91,7 +92,9 @@ public func performOCR(imageData: UnsafePointer<UInt8>, length: Int, width: Int,
}
}
- textRequest.recognitionLevel = .accurate // Keep accurate recognition
+ textRequest.recognitionLanguages = ["zh-Hans", "zh-Hant", "en-US"]
+ textRequest.recognitionLevel = .accurate
+ textRequest.usesLanguageCorrection = true
let handler = VNImageRequestHandler(cgImage: preprocessedCGImage, options: [:])
do {
diff --git a/screenpipe-vision/tests/apple_vision_test.rs b/screenpipe-vision/tests/apple_vision_test.rs
index 612fecff2..0126191b0 100644
--- a/screenpipe-vision/tests/apple_vision_test.rs
+++ b/screenpipe-vision/tests/apple_vision_test.rs
@@ -34,4 +34,24 @@ mod tests {
result
);
}
+// # 中文测试
+ #[tokio::test]
+ async fn test_apple_native_ocr_chinese() {
+ let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+ path.push("tests");
+ path.push("testing_OCR_chinese.png");
+ println!("Path to testing_OCR_chinese.png: {:?}", path);
+
+ let image = image::open(&path).expect("Failed to open Chinese test image");
+ println!("Image dimensions: {:?}", image.dimensions());
+
+ let result = perform_ocr_apple(&image);
+
+ println!("OCR text: {:?}", result);
+ assert!(
+ result.contains("管理分支"), // 替换为您的测试图像中的实际中文文本
+ "OCR failed to recognize Chinese text: {:?}",
+ result
+ );
+ }
}
diff --git a/screenpipe-vision/tests/testing_OCR_chinese.png b/screenpipe-vision/tests/testing_OCR_chinese.png
new file mode 100644
index 000000000..50e7a329e
Binary files /dev/null and b/screenpipe-vision/tests/testing_OCR_chinese.png differ