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
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
Average Accuracy: 0.68 Average Accuracy: 0.68 Average Accuracy: 0.68 Apple Vision OCR with Accuracy/Performance and Accuracy/ time: [474.63 ms 483.99 ms 495.27 ms] change: [+5.5274% +8.0847% +11.368%] (p = 0.00 < 0.05) Performance has regressed. Found 1 outliers among 10 measurements (10.00%) 1 (10.00%) high mild e.g. 0.48 -> 0.68 accuracy, almost same speed
Louis Beaumont1cd92033a5fb
diff --git a/screenpipe-vision/benches/ocr_benchmark.rs b/screenpipe-vision/benches/ocr_benchmark.rsindex f65fe3359..a62fd66db 100644--- a/screenpipe-vision/benches/ocr_benchmark.rs+++ b/screenpipe-vision/benches/ocr_benchmark.rs@@ -71,26 +71,6 @@ fn bench_apple_vision_ocr(c: &mut Criterion) {group.finish();}-#[cfg(target_os = "macos")]-fn test_apple_vision_ocr_accuracy() {- let image = load_test_image();- let result = perform_ocr_apple(&image);-- let matched_keywords = EXPECTED_KEYWORDS- .iter()- .filter(|&&keyword| result.contains(keyword))- .count();- let accuracy = matched_keywords as f32 / EXPECTED_KEYWORDS.len() as f32;-- println!("Apple Vision OCR Accuracy: {:.2}", accuracy);- println!(- "Matched keywords: {}/{}",- matched_keywords,- EXPECTED_KEYWORDS.len()- );- assert!(accuracy > 0.3, "Accuracy below threshold");-}-#[cfg(target_os = "macos")]fn bench_apple_vision_ocr_with_accuracy(c: &mut Criterion) {let image = load_test_image();@@ -142,26 +122,6 @@ fn bench_tesseract_ocr(c: &mut Criterion) {group.finish();}-#[cfg(target_os = "linux")]-fn test_tesseract_ocr_accuracy() {- let image = load_test_image();- let (result, _) = perform_ocr_tesseract(&image);-- let matched_keywords = EXPECTED_KEYWORDS- .iter()- .filter(|&&keyword| result.contains(keyword))- .count();- let accuracy = matched_keywords as f32 / EXPECTED_KEYWORDS.len() as f32;-- println!("Tesseract OCR Accuracy: {:.2}", accuracy);- println!(- "Matched keywords: {}/{}",- matched_keywords,- EXPECTED_KEYWORDS.len()- );- assert!(accuracy > 0.3, "Accuracy below threshold");-}-// Windows OCR benchmark (Windows only)#[cfg(target_os = "windows")]fn bench_windows_ocr(c: &mut Criterion) {@@ -181,26 +141,6 @@ fn bench_windows_ocr(c: &mut Criterion) {group.finish();}-#[cfg(target_os = "windows")]-async fn test_windows_ocr_accuracy() {- let image = load_test_image();- let (result, _) = perform_ocr_windows(&image).await;-- let matched_keywords = EXPECTED_KEYWORDS- .iter()- .filter(|&&keyword| result.contains(keyword))- .count();- let accuracy = matched_keywords as f32 / EXPECTED_KEYWORDS.len() as f32;-- println!("Windows OCR Accuracy: {:.2}", accuracy);- println!(- "Matched keywords: {}/{}",- matched_keywords,- EXPECTED_KEYWORDS.len()- );- assert!(accuracy > 0.3, "Accuracy below threshold");-}-// Criterion group definitions#[cfg(target_os = "macos")]criterion_group!(diff --git a/screenpipe-vision/lib/libscreenpipe.dylib b/screenpipe-vision/lib/libscreenpipe.dylibindex 641dd60e2..f5875e494 100755Binary files a/screenpipe-vision/lib/libscreenpipe.dylib and b/screenpipe-vision/lib/libscreenpipe.dylib differdiff --git a/screenpipe-vision/lib/libscreenpipe_arm64.dylib b/screenpipe-vision/lib/libscreenpipe_arm64.dylibindex df5862a8d..f135d11d1 100755Binary files a/screenpipe-vision/lib/libscreenpipe_arm64.dylib and b/screenpipe-vision/lib/libscreenpipe_arm64.dylib differdiff --git a/screenpipe-vision/lib/libscreenpipe_x86_64.dylib b/screenpipe-vision/lib/libscreenpipe_x86_64.dylibindex 868a5913c..809f4af99 100755Binary files a/screenpipe-vision/lib/libscreenpipe_x86_64.dylib and b/screenpipe-vision/lib/libscreenpipe_x86_64.dylib differdiff --git a/screenpipe-vision/src/ocr.swift b/screenpipe-vision/src/ocr.swiftindex 5f80ad76c..7d26727be 100644--- a/screenpipe-vision/src/ocr.swift+++ b/screenpipe-vision/src/ocr.swift@@ -1,7 +1,7 @@import CoreGraphics+import CoreImageimport Foundationimport Vision-import CoreImage@available(macOS 10.15, *)@_cdecl("perform_ocr")@@ -9,19 +9,19 @@ public func performOCR(imageData: UnsafePointer<UInt8>, length: Int, width: Int,-> UnsafeMutablePointer<CChar>? {guard let dataProvider = CGDataProvider(data: Data(bytes: imageData, count: length) as CFData),- let cgImage = CGImage(- width: width,- height: height,- bitsPerComponent: 8,- bitsPerPixel: 32,- bytesPerRow: width * 4,- space: CGColorSpaceCreateDeviceRGB(),- bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue),- provider: dataProvider,- decode: nil,- shouldInterpolate: false,- intent: .defaultIntent- )+ let cgImage = CGImage(+ width: width,+ height: height,+ bitsPerComponent: 8,+ bitsPerPixel: 32,+ bytesPerRow: width * 4,+ space: CGColorSpaceCreateDeviceRGB(),+ bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue),+ provider: dataProvider,+ decode: nil,+ shouldInterpolate: false,+ intent: .defaultIntent+ )else {return strdup("Error: Failed to create CGImage")}@@ -29,13 +29,16 @@ public func performOCR(imageData: UnsafePointer<UInt8>, length: Int, width: Int,// Preprocess the imagelet ciImage = CIImage(cgImage: cgImage)let context = CIContext(options: nil)-+// Apply preprocessing filters- let processed = ciImage- .applyingFilter("CIColorControls", parameters: [kCIInputSaturationKey: 0, kCIInputContrastKey: 1.1])- .applyingFilter("CIGaussianBlur", parameters: [kCIInputRadiusKey: 1])- .applyingFilter("CIColorControls", parameters: [kCIInputBrightnessKey: 0.1])-+ // Replace the current preprocessing chain with a more efficient one+ let processed =+ ciImage+ .applyingFilter(+ "CIColorControls", parameters: [kCIInputSaturationKey: 0, kCIInputContrastKey: 1.1]+ )+ .applyingFilter(+ "CIUnsharpMask", parameters: [kCIInputRadiusKey: 1.0, kCIInputIntensityKey: 0.5])guard let preprocessedCGImage = context.createCGImage(processed, from: processed.extent) else {return strdup("Error: Failed to create preprocessed image")}@@ -47,9 +50,9 @@ public func performOCR(imageData: UnsafePointer<UInt8>, length: Int, width: Int,var observationCount: Int = 0// Slice the image horizontally with overlap- let sliceCount = 5 // Adjust this number based on your needs+ let sliceCount = 5 // Adjust this number based on your needslet sliceHeight = height / sliceCount- let overlap = Int(Float(sliceHeight) * 0.1) // 10% overlap+ let overlap = Int(Float(sliceHeight) * 0.1) // 10% overlapfor i in 0..<sliceCount {let sliceY = max(0, i * sliceHeight - overlap)@@ -117,18 +120,18 @@ public func performOCR(imageData: UnsafePointer<UInt8>, length: Int, width: Int,]if let jsonData = try? JSONSerialization.data(withJSONObject: result, options: []),- let jsonString = String(data: jsonData, encoding: .utf8) {+ let jsonString = String(data: jsonData, encoding: .utf8) {return strdup(jsonString)} else {return strdup("Error: Failed to serialize result to JSON")}}-// # Compile for x86_64-// swiftc -emit-library -target x86_64-apple-macosx10.15 -o screenpipe-vision/lib/libscreenpipe_x86_64.dylib screenpipe-vision/src/ocr.swift+/*+Compile for multi arch:-// # Compile for arm64 (aarch64)-// swiftc -emit-library -target arm64-apple-macosx11.0 -o screenpipe-vision/lib/libscreenpipe_arm64.dylib screenpipe-vision/src/ocr.swift+swiftc -emit-library -target x86_64-apple-macosx11.0 -o screenpipe-vision/lib/libscreenpipe_x86_64.dylib screenpipe-vision/src/ocr.swift -framework Metal -framework MetalPerformanceShaders -framework Vision -framework CoreImage \+&& swiftc -emit-library -target arm64-apple-macosx11.0 -o screenpipe-vision/lib/libscreenpipe_arm64.dylib screenpipe-vision/src/ocr.swift -framework Metal -framework MetalPerformanceShaders -framework Vision -framework CoreImage \+&& lipo -create screenpipe-vision/lib/libscreenpipe_x86_64.dylib screenpipe-vision/lib/libscreenpipe_arm64.dylib -output screenpipe-vision/lib/libscreenpipe.dylib-// # Combine into a universal binary-// lipo -create screenpipe-vision/lib/libscreenpipe_x86_64.dylib screenpipe-vision/lib/libscreenpipe_arm64.dylib -output screenpipe-vision/lib/libscreenpipe.dylib\ No newline at end of file+*/