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

refactor: reduce cloning usage and fix vision queue issue

Louis Beaumont14d77eac9f32
diff --git a/screenpipe-audio/src/core.rs b/screenpipe-audio/src/core.rs
index 9ef627ae7..67a0c9ea2 100644
--- a/screenpipe-audio/src/core.rs
+++ b/screenpipe-audio/src/core.rs
@@ -136,7 +136,7 @@ pub async fn record_and_transcribe(
pub async fn start_realtime_recording(
audio_stream: Arc<AudioStream>,
- languages: Vec<Language>,
+ languages: Arc<Vec<Language>>,
is_running: Arc<AtomicBool>,
deepgram_api_key: Option<String>,
) -> Result<()> {
diff --git a/screenpipe-audio/src/deepgram/realtime.rs b/screenpipe-audio/src/deepgram/realtime.rs
index c0fd3f7d2..83f14fa0d 100644
--- a/screenpipe-audio/src/deepgram/realtime.rs
+++ b/screenpipe-audio/src/deepgram/realtime.rs
@@ -22,7 +22,7 @@ use tokio::sync::oneshot;
pub async fn stream_transcription_deepgram(
stream: Arc<AudioStream>,
- languages: Vec<Language>,
+ languages: Arc<Vec<Language>>,
is_running: Arc<AtomicBool>,
deepgram_api_key: Option<String>,
) -> Result<()> {
@@ -44,7 +44,7 @@ pub async fn start_deepgram_stream(
device: Arc<AudioDevice>,
sample_rate: u32,
is_running: Arc<AtomicBool>,
- _languages: Vec<Language>,
+ _languages: Arc<Vec<Language>>,
deepgram_api_key: Option<String>,
) -> Result<()> {
let api_key = deepgram_api_key.unwrap_or(CUSTOM_DEEPGRAM_API_TOKEN.to_string());
diff --git a/screenpipe-audio/src/realtime.rs b/screenpipe-audio/src/realtime.rs
index 37569d49f..e965163c8 100644
--- a/screenpipe-audio/src/realtime.rs
+++ b/screenpipe-audio/src/realtime.rs
@@ -7,7 +7,7 @@ use std::sync::{atomic::AtomicBool, Arc};
pub async fn realtime_stt(
stream: Arc<AudioStream>,
- languages: Vec<Language>,
+ languages: Arc<Vec<Language>>,
is_running: Arc<AtomicBool>,
deepgram_api_key: Option<String>,
) -> Result<()> {
diff --git a/screenpipe-audio/tests/realtime_test.rs b/screenpipe-audio/tests/realtime_test.rs
index 6785a7a01..c8427263f 100644
--- a/screenpipe-audio/tests/realtime_test.rs
+++ b/screenpipe-audio/tests/realtime_test.rs
@@ -35,7 +35,7 @@ async fn test_realtime_transcription() {
Arc::new(device),
sample_rate,
is_running_clone,
- vec![],
+ Arc::new([].to_vec()),
Some(deepgram_api_key),
)
.await;
diff --git a/screenpipe-integrations/src/unstructured_ocr.rs b/screenpipe-integrations/src/unstructured_ocr.rs
index d67b4bdee..93b7f8448 100644
--- a/screenpipe-integrations/src/unstructured_ocr.rs
+++ b/screenpipe-integrations/src/unstructured_ocr.rs
@@ -12,12 +12,13 @@ use std::io::Cursor;
use std::io::Read;
use std::io::Write;
use std::path::PathBuf;
+use std::sync::Arc;
use tempfile::NamedTempFile;
use tokio::time::{timeout, Duration};
pub async fn perform_ocr_cloud(
image: &DynamicImage,
- languages: Vec<Language>,
+ languages: Arc<Vec<Language>>,
) -> Result<(String, String, Option<f64>)> {
let api_key = match env::var("UNSTRUCTURED_API_KEY") {
Ok(key) => key,
diff --git a/screenpipe-server/src/add.rs b/screenpipe-server/src/add.rs
index 1b36e9ad6..af0df606b 100644
--- a/screenpipe-server/src/add.rs
+++ b/screenpipe-server/src/add.rs
@@ -183,12 +183,12 @@ pub async fn handle_index_command(
// Do OCR processing directly
let (text, _, confidence): (String, String, Option<f64>) = match engine.clone() {
#[cfg(target_os = "macos")]
- OcrEngine::AppleNative => perform_ocr_apple(frame, &[]),
+ OcrEngine::AppleNative => perform_ocr_apple(frame, Arc::new([].to_vec())),
#[cfg(target_os = "windows")]
OcrEngine::WindowsNative => perform_ocr_windows(&frame).await.unwrap(),
_ => {
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
- return perform_ocr_tesseract(&frame, vec![]);
+ return perform_ocr_tesseract(&frame, Arc::new([].to_vec()));
panic!("unsupported ocr engine");
}
diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rs
index 33f004d9c..fa24ed4b0 100644
--- a/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/screenpipe-server/src/bin/screenpipe-server.rs
@@ -679,7 +679,7 @@ async fn main() -> anyhow::Result<()> {
video_chunk_duration: Duration::from_secs(cli.video_chunk_duration),
use_pii_removal: cli.use_pii_removal,
capture_unfocused_windows: cli.capture_unfocused_windows,
- languages: languages.clone(),
+ languages: Arc::new(languages.clone()),
};
let audio_config = AudioConfig {
@@ -697,8 +697,8 @@ async fn main() -> anyhow::Result<()> {
let vision_config = VisionConfig {
disabled: cli.disable_vision,
ocr_engine: Arc::new(cli.ocr_engine.clone().into()),
- ignored_windows: cli.ignored_windows.clone(),
- include_windows: cli.included_windows.clone(),
+ ignored_windows: Arc::new(cli.ignored_windows.clone()),
+ include_windows: Arc::new(cli.included_windows.clone()),
};
let recording_future = start_continuous_recording(
diff --git a/screenpipe-server/src/core.rs b/screenpipe-server/src/core.rs
index ce22dc825..fb4a3822c 100644
--- a/screenpipe-server/src/core.rs
+++ b/screenpipe-server/src/core.rs
@@ -13,7 +13,7 @@ use screenpipe_core::pii_removal::remove_pii;
use screenpipe_core::{AudioDevice, DeviceManager, DeviceType, Language};
use screenpipe_events::{poll_meetings_events, send_event};
use screenpipe_vision::core::WindowOcr;
-use screenpipe_vision::OcrEngine;
+use screenpipe_vision::{CaptureResult, OcrEngine};
use std::collections::HashMap;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
@@ -29,7 +29,7 @@ pub struct RecordingConfig {
pub video_chunk_duration: Duration,
pub use_pii_removal: bool,
pub capture_unfocused_windows: bool,
- pub languages: Vec<Language>,
+ pub languages: Arc<Vec<Language>>,
}
#[derive(Clone)]
@@ -49,8 +49,8 @@ pub struct AudioConfig {
pub struct VisionConfig {
pub disabled: bool,
pub ocr_engine: Arc<OcrEngine>,
- pub ignored_windows: Vec<String>,
- pub include_windows: Vec<String>,
+ pub ignored_windows: Arc<Vec<String>>,
+ pub include_windows: Arc<Vec<String>>,
}
#[derive(Clone)]
@@ -61,10 +61,10 @@ pub struct VideoRecordingConfig {
pub ocr_engine: Arc<OcrEngine>,
pub monitor_id: u32,
pub use_pii_removal: bool,
- pub ignored_windows: Vec<String>,
- pub include_windows: Vec<String>,
+ pub ignored_windows: Arc<Vec<String>>,
+ pub include_windows: Arc<Vec<String>>,
pub video_chunk_duration: Duration,
- pub languages: Vec<Language>,
+ pub languages: Arc<Vec<Language>>,
pub capture_unfocused_windows: bool,
}
@@ -165,10 +165,10 @@ async fn record_vision(
db: Arc<DatabaseManager>,
output_path: Arc<String>,
fps: f64,
- languages: Vec<Language>,
+ languages: Arc<Vec<Language>>,
capture_unfocused_windows: bool,
- ignored_windows: Vec<String>,
- include_windows: Vec<String>,
+ ignored_windows: Arc<Vec<String>>,
+ include_windows: Arc<Vec<String>>,
video_chunk_duration: Duration,
use_pii_removal: bool,
) -> Result<()> {
@@ -199,11 +199,11 @@ async fn record_vision(
let db_manager_video = Arc::clone(&db);
let output_path_video = Arc::clone(&output_path);
let ocr_engine = Arc::clone(&ocr_engine);
- let ignored_windows_video = ignored_windows.to_vec();
- let include_windows_video = include_windows.to_vec();
let languages = languages.clone();
let device_manager_vision_clone = device_manager.clone();
+ let ignored_windows = ignored_windows.clone();
+ let include_windows = include_windows.clone();
let handle = tokio::spawn(async move {
let config = VideoRecordingConfig {
db: db_manager_video,
@@ -212,8 +212,8 @@ async fn record_vision(
ocr_engine,
monitor_id,
use_pii_removal,
- ignored_windows: ignored_windows_video,
- include_windows: include_windows_video,
+ ignored_windows,
+ include_windows,
video_chunk_duration,
languages,
capture_unfocused_windows,
@@ -306,65 +306,81 @@ async fn record_video(
_ => continue, // Ignore other devices or monitors
}
}
- _ = tokio::time::sleep(Duration::from_secs_f64(1.0 / config.fps)) => {
- if let Some(frame) = video_capture.ocr_frame_queue.pop() {
- for window_result in &frame.window_ocr_results {
- match config.db.insert_frame(&device_name, None).await {
- Ok(frame_id) => {
- let text_json =
- serde_json::to_string(&window_result.text_json).unwrap_or_default();
-
- let text = if config.use_pii_removal {
- &remove_pii(&window_result.text)
- } else {
- &window_result.text
- };
-
- let _ = send_event(
- "ocr_result",
- WindowOcr {
- image: Some(frame.image.clone()),
- text: text.clone(),
- text_json: window_result.text_json.clone(),
- app_name: window_result.app_name.clone(),
- window_name: window_result.window_name.clone(),
- focused: window_result.focused,
- confidence: window_result.confidence,
- timestamp: frame.timestamp,
- },
- );
-
- if let Err(e) = config.db
- .insert_ocr_text(
- frame_id,
- text,
- &text_json,
- &window_result.app_name,
- &window_result.window_name,
- Arc::clone(&config.ocr_engine),
- window_result.focused, // Add this line
- )
- .await
- {
- error!(
- "Failed to insert OCR text: {}, skipping window {} of frame {}",
- e, window_result.window_name, frame_id
- );
- continue;
- }
- }
+ // we should process faster than the fps we use to do OCR
+ _ = tokio::time::sleep(Duration::from_secs_f64(1.0 / (config.fps * 2.0))) => {
+ let frame = match video_capture.ocr_frame_queue.pop() {
+ Some(f) => f,
+ None => continue,
+ };
+
+ process_ocr_frame(
+ frame,
+ &config.db,
+ &device_name,
+ config.use_pii_removal,
+ config.ocr_engine.clone(),
+ ).await;
+ }
+ }
+ }
+}
- Err(e) => {
- warn!("Failed to insert frame: {}", e);
- tokio::time::sleep(Duration::from_millis(100)).await;
- continue;
- }
- }
- }
- }
- }
+async fn process_ocr_frame(
+ frame: Arc<CaptureResult>,
+ db: &DatabaseManager,
+ device_name: &str,
+ use_pii_removal: bool,
+ ocr_engine: Arc<OcrEngine>,
+) {
+ for window_result in &frame.window_ocr_results {
+ let frame_id = match db.insert_frame(device_name, None).await {
+ Ok(id) => id,
+ Err(e) => {
+ warn!("Failed to insert frame: {}", e);
+ tokio::time::sleep(Duration::from_millis(100)).await;
+ continue;
+ }
+ };
+
+ let text_json = serde_json::to_string(&window_result.text_json).unwrap_or_default();
+
+ let text = if use_pii_removal {
+ remove_pii(&window_result.text)
+ } else {
+ window_result.text.clone()
+ };
+
+ let _ = send_event(
+ "ocr_result",
+ WindowOcr {
+ image: Some(frame.image.clone()),
+ text: text.clone(),
+ text_json: window_result.text_json.clone(),
+ app_name: window_result.app_name.clone(),
+ window_name: window_result.window_name.clone(),
+ focused: window_result.focused,
+ confidence: window_result.confidence,
+ timestamp: frame.timestamp,
+ },
+ );
+
+ if let Err(e) = db
+ .insert_ocr_text(
+ frame_id,
+ &text,
+ &text_json,
+ &window_result.app_name,
+ &window_result.window_name,
+ ocr_engine.clone(),
+ window_result.focused,
+ )
+ .await
+ {
+ error!(
+ "Failed to insert OCR text: {}, skipping window {} of frame {}",
+ e, window_result.window_name, frame_id
+ );
}
- tokio::time::sleep(Duration::from_secs_f64(1.0 / config.fps)).await;
}
}
@@ -377,7 +393,7 @@ async fn record_audio(
audio_transcription_engine: Arc<AudioTranscriptionEngine>,
realtime_audio_enabled: bool,
realtime_audio_devices: Vec<Arc<AudioDevice>>,
- languages: Vec<Language>,
+ languages: Arc<Vec<Language>>,
deepgram_api_key: Option<String>,
) -> Result<()> {
let mut handles: HashMap<String, JoinHandle<()>> = HashMap::new();
diff --git a/screenpipe-server/src/video.rs b/screenpipe-server/src/video.rs
index 40dd99e10..6c8b1299c 100644
--- a/screenpipe-server/src/video.rs
+++ b/screenpipe-server/src/video.rs
@@ -39,15 +39,18 @@ impl VideoCapture {
new_chunk_callback: impl Fn(&str) + Send + Sync + 'static,
ocr_engine: Arc<OcrEngine>,
monitor_id: u32,
- ignore_list: Vec<String>,
- include_list: Vec<String>,
- languages: Vec<Language>,
+ ignore_list: Arc<Vec<String>>,
+ include_list: Arc<Vec<String>>,
+ languages: Arc<Vec<Language>>,
capture_unfocused_windows: bool,
) -> Self {
let fps = if fps.is_finite() && fps > 0.0 {
fps
} else {
- warn!("[monitor_id: {}] Invalid FPS value: {}. Using default of 1.0", monitor_id, fps);
+ warn!(
+ "[monitor_id: {}] Invalid FPS value: {}. Using default of 1.0",
+ monitor_id, fps
+ );
1.0
};
let interval = Duration::from_secs_f64(1.0 / fps);
@@ -66,8 +69,9 @@ impl VideoCapture {
let shutdown_rx_capture = shutdown_rx.clone();
let shutdown_rx_queue = shutdown_rx.clone();
let shutdown_rx_video = shutdown_rx.clone();
-
+ let languages_clone = languages.clone();
let result_sender_inner = result_sender.clone();
+
let capture_handle = tokio::spawn(async move {
let mut rx = shutdown_rx_capture;
loop {
@@ -80,15 +84,16 @@ impl VideoCapture {
}
let result_sender = result_sender_inner.clone();
let window_filters_clone = Arc::clone(&window_filters_clone);
+ let languages_clone = languages_clone.clone();
tokio::select! {
_ = continuous_capture(
result_sender,
interval,
- (*ocr_engine).clone(),
+ ocr_engine.clone(),
monitor_id,
window_filters_clone,
- languages.clone(),
+ languages_clone.clone(),
capture_unfocused_windows,
rx.clone(),
) => {
diff --git a/screenpipe-server/tests/video_utils_test.rs b/screenpipe-server/tests/video_utils_test.rs
index 7e14cbd50..93fe7f99b 100644
--- a/screenpipe-server/tests/video_utils_test.rs
+++ b/screenpipe-server/tests/video_utils_test.rs
@@ -105,6 +105,8 @@ async fn test_extract_frames() -> Result<()> {
#[cfg(target_os = "macos")]
#[tokio::test]
async fn test_extract_frames_and_ocr() -> Result<()> {
+ use std::sync::Arc;
+
use screenpipe_vision::perform_ocr_apple;
setup_test_env().await?;
let video_path = create_test_video().await?;
@@ -133,7 +135,10 @@ async fn test_extract_frames_and_ocr() -> Result<()> {
};
// perform ocr using apple native (macos only)
- let (text, _, confidence) = perform_ocr_apple(&captured_window.image, &[Language::English]);
+ let (text, _, confidence) = perform_ocr_apple(
+ &captured_window.image,
+ Arc::new([Language::English].to_vec()),
+ );
println!("ocr confidence: {}", confidence.unwrap_or(0.0));
println!("extracted text: {}", text);
diff --git a/screenpipe-vision/examples/websocket.rs b/screenpipe-vision/examples/websocket.rs
index d61f370e6..455953728 100644
--- a/screenpipe-vision/examples/websocket.rs
+++ b/screenpipe-vision/examples/websocket.rs
@@ -92,15 +92,15 @@ async fn main() -> Result<()> {
Duration::from_secs_f64(1.0 / cli.fps),
// if apple use apple otherwise if windows use windows native otherwise use tesseract
if cfg!(target_os = "macos") {
- OcrEngine::AppleNative
+ Arc::new(OcrEngine::AppleNative)
} else if cfg!(target_os = "windows") {
- OcrEngine::WindowsNative
+ Arc::new(OcrEngine::WindowsNative)
} else {
- OcrEngine::Tesseract
+ Arc::new(OcrEngine::Tesseract)
},
id,
window_filters,
- vec![],
+ Arc::new([].to_vec()),
false,
tokio::sync::watch::channel(false).1,
)
diff --git a/screenpipe-vision/src/apple.rs b/screenpipe-vision/src/apple.rs
index dcf1c62d7..2df1c8398 100644
--- a/screenpipe-vision/src/apple.rs
+++ b/screenpipe-vision/src/apple.rs
@@ -10,12 +10,13 @@ use log::error;
use screenpipe_core::Language;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
+use std::sync::Arc;
use std::sync::OnceLock;
use std::{ffi::c_void, ptr::null_mut};
static APPLE_LANGUAGE_MAP: OnceLock<HashMap<Language, &'static str>> = OnceLock::new();
-
-pub fn get_apple_languages(languages: &[Language]) -> Vec<String> {
+
+pub fn get_apple_languages(languages: Arc<Vec<Language>>) -> Vec<String> {
let map = APPLE_LANGUAGE_MAP.get_or_init(|| {
let mut m = HashMap::new();
m.insert(Language::English, "en-US");
@@ -71,7 +72,7 @@ extern "C" fn release_callback(_refcon: *mut c_void, _data_ptr: *const *const c_
#[cfg(target_os = "macos")]
pub fn perform_ocr_apple(
image: &DynamicImage,
- languages: &[Language],
+ languages: Arc<Vec<Language>>,
) -> (String, String, Option<f64>) {
cidre::objc::ar_pool(|| {
// Convert languages to Apple format and create ns::Array
diff --git a/screenpipe-vision/src/bin/screenpipe-vision.rs b/screenpipe-vision/src/bin/screenpipe-vision.rs
index bc1d02834..285ed4e63 100644
--- a/screenpipe-vision/src/bin/screenpipe-vision.rs
+++ b/screenpipe-vision/src/bin/screenpipe-vision.rs
@@ -45,10 +45,10 @@ async fn main() {
continuous_capture(
result_tx,
Duration::from_secs_f32(1.0 / cli.fps),
- OcrEngine::AppleNative,
+ Arc::new(OcrEngine::AppleNative),
id,
Arc::new(window_filters),
- languages.clone(),
+ Arc::new(languages),
false,
shutdown_rx,
)
diff --git a/screenpipe-vision/src/core.rs b/screenpipe-vision/src/core.rs
index 14683e29b..b45b70b15 100644
--- a/screenpipe-vision/src/core.rs
+++ b/screenpipe-vision/src/core.rs
@@ -135,10 +135,10 @@ pub struct OcrTaskData {
pub async fn continuous_capture(
result_tx: Sender<CaptureResult>,
interval: Duration,
- ocr_engine: OcrEngine,
+ ocr_engine: Arc<OcrEngine>,
monitor_id: u32,
window_filters: Arc<WindowFilters>,
- languages: Vec<Language>,
+ languages: Arc<Vec<Language>>,
capture_unfocused_windows: bool,
mut shutdown_rx: watch::Receiver<bool>,
) {
@@ -175,6 +175,7 @@ pub async fn continuous_capture(
}
}
_ = async {
+ let languages_clone = languages.clone();
let capture_result = match capture_screenshot(&monitor, &window_filters, capture_unfocused_windows).await {
Ok((image, window_images, image_hash, _capture_duration)) => {
debug!(
@@ -245,15 +246,15 @@ pub async fn continuous_capture(
return;
}
let ocr_task_data = OcrTaskData {
- image: max_avg_frame.image,
- window_images: max_avg_frame.window_images,
+ image: max_avg_frame.image.clone(),
+ window_images: max_avg_frame.window_images.iter().cloned().collect(),
frame_number: max_avg_frame.frame_number,
timestamp: max_avg_frame.timestamp,
result_tx: max_avg_frame.result_tx,
};
if let Err(e) =
- process_ocr_task(ocr_task_data, &ocr_engine, languages.clone()).await
+ process_ocr_task(ocr_task_data, ocr_engine.clone(), languages_clone).await
{
error!("Error processing OCR task: {}", e);
}
@@ -286,8 +287,8 @@ pub struct MaxAverageFrame {
pub async fn process_ocr_task(
ocr_task_data: OcrTaskData,
- ocr_engine: &OcrEngine,
- languages: Vec<Language>,
+ ocr_engine: Arc<OcrEngine>,
+ languages: Arc<Vec<Language>>,
) -> Result<(), std::io::Error> {
let OcrTaskData {
image,
@@ -308,7 +309,7 @@ pub async fn process_ocr_task(
let mut window_count = 0;
for captured_window in window_images {
- let (window_text, window_json_output, confidence) = match ocr_engine {
+ let (window_text, window_json_output, confidence) = match ocr_engine.as_ref() {
OcrEngine::Unstructured => perform_ocr_cloud(&captured_window.image, languages.clone())
.await
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?,
@@ -320,7 +321,7 @@ pub async fn process_ocr_task(
.await
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?,
#[cfg(target_os = "macos")]
- OcrEngine::AppleNative => perform_ocr_apple(&captured_window.image, &languages),
+ OcrEngine::AppleNative => perform_ocr_apple(&captured_window.image, languages.clone()),
OcrEngine::Custom(config) => {
perform_ocr_custom(&captured_window.image, languages.clone(), config)
.await
diff --git a/screenpipe-vision/src/custom_ocr.rs b/screenpipe-vision/src/custom_ocr.rs
index bfd077ecd..e39e7883c 100644
--- a/screenpipe-vision/src/custom_ocr.rs
+++ b/screenpipe-vision/src/custom_ocr.rs
@@ -1,3 +1,5 @@
+use std::sync::Arc;
+
use anyhow::Result;
use base64::{engine::general_purpose, Engine as _};
use image::DynamicImage;
@@ -23,7 +25,7 @@ impl Default for CustomOcrConfig {
pub async fn perform_ocr_custom(
image: &DynamicImage,
- languages: Vec<Language>,
+ languages: Arc<Vec<Language>>,
config: &CustomOcrConfig,
) -> Result<(String, String, Option<f64>)> {
// Convert image to RGB before encoding to JPEG
diff --git a/screenpipe-vision/src/tesseract.rs b/screenpipe-vision/src/tesseract.rs
index 1c1c518ae..c826c4f18 100644
--- a/screenpipe-vision/src/tesseract.rs
+++ b/screenpipe-vision/src/tesseract.rs
@@ -1,11 +1,10 @@
use image::DynamicImage;
use rusty_tesseract::{Args, DataOutput, Image};
use screenpipe_core::{Language, TESSERACT_LANGUAGES};
-use std::collections::HashMap;
-
+use std::{collections::HashMap, sync::Arc};
pub fn perform_ocr_tesseract(
image: &DynamicImage,
- languages: Vec<Language>,
+ languages: Arc<Vec<Language>>,
) -> (String, String, Option<f64>) {
let language_string = match languages.is_empty() {
true => "eng".to_string(),
diff --git a/screenpipe-vision/tests/apple_vision_test.rs b/screenpipe-vision/tests/apple_vision_test.rs
index e0a95e24f..fffa752d5 100644
--- a/screenpipe-vision/tests/apple_vision_test.rs
+++ b/screenpipe-vision/tests/apple_vision_test.rs
@@ -4,7 +4,7 @@ mod tests {
use image::GenericImageView;
use screenpipe_core::Language;
use screenpipe_vision::perform_ocr_apple;
- use std::path::PathBuf;
+ use std::{path::PathBuf, sync::Arc};
#[tokio::test]
async fn test_apple_native_ocr() {
@@ -26,7 +26,7 @@ mod tests {
let rgb_image = image.to_rgb8();
println!("RGB image dimensions: {:?}", rgb_image.dimensions());
- let (ocr_text, _, _) = perform_ocr_apple(&image, &[]);
+ let (ocr_text, _, _) = perform_ocr_apple(&image, Arc::new([].to_vec()));
println!("OCR text: {:?}", ocr_text);
assert!(
@@ -46,7 +46,7 @@ mod tests {
let image = image::open(&path).expect("Failed to open Chinese test image");
println!("Image dimensions: {:?}", image.dimensions());
- let (ocr_text, _, _) = perform_ocr_apple(&image, &[Language::Chinese]);
+ let (ocr_text, _, _) = perform_ocr_apple(&image, Arc::new([Language::Chinese].to_vec()));
println!("OCR text: {:?}", ocr_text);
assert!(
diff --git a/screenpipe-vision/tests/custom_ocr_test.rs b/screenpipe-vision/tests/custom_ocr_test.rs
index 701e5c9eb..283fbf9c6 100644
--- a/screenpipe-vision/tests/custom_ocr_test.rs
+++ b/screenpipe-vision/tests/custom_ocr_test.rs
@@ -55,7 +55,7 @@ async def read_ocr(payload: dict):
#
# Configure your "CustomOcrConfig" in Rust to point to http://localhost:8000/ocr
-# Clean up
+# Clean up
deactivate
rm -rf venv app.py
*/
@@ -67,6 +67,7 @@ mod tests {
use screenpipe_vision::custom_ocr::{perform_ocr_custom, CustomOcrConfig};
use screenpipe_vision::utils::OcrEngine;
use std::path::PathBuf;
+ use std::sync::Arc;
#[tokio::test]
async fn test_custom_ocr() {
@@ -98,7 +99,7 @@ mod tests {
// Perform the custom OCR.
let (ocr_text, structured_data, confidence) = match ocr_engine {
OcrEngine::Custom(ref config) => {
- perform_ocr_custom(&image, vec![Language::English], config)
+ perform_ocr_custom(&image, Arc::new([Language::English].to_vec()), config)
.await
.expect("Custom OCR failed")
}
@@ -142,7 +143,7 @@ mod tests {
let (ocr_text, _, _) = match ocr_engine {
OcrEngine::Custom(ref config) => {
- perform_ocr_custom(&image, vec![Language::Chinese], config)
+ perform_ocr_custom(&image, Arc::new([Language::Chinese].to_vec()), config)
.await
.expect("Custom OCR failed")
}