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
passing json with element coordinates
matthew-heartful1395a3af9c46
diff --git a/screenpipe-vision/Cargo.toml b/screenpipe-vision/Cargo.tomlindex 56e2a5c2a..e2753c0c8 100644--- a/screenpipe-vision/Cargo.toml+++ b/screenpipe-vision/Cargo.toml@@ -38,6 +38,10 @@ screenpipe-integrations = { path = "../screenpipe-integrations" }tracing-subscriber = { workspace = true }tracing = { workspace = true }+# Shared memory+shared_memory = "0.12.4"+parking_lot = "0.12"+[dev-dependencies]tempfile = "3.3.0"criterion = { workspace = true }diff --git a/screenpipe-vision/examples/websocket.rs b/screenpipe-vision/examples/websocket.rsindex b83b54c97..625494713 100644--- a/screenpipe-vision/examples/websocket.rs+++ b/screenpipe-vision/examples/websocket.rs@@ -13,6 +13,7 @@ use tokio::net::{TcpListener, TcpStream};use tokio::sync::mpsc::channel;use tokio_tungstenite::tungstenite::Message;use tracing_subscriber::{fmt::format::FmtSpan, EnvFilter};+use std::collections::HashMap;#[derive(Clone, Serialize)]struct SimplifiedResult {@@ -22,10 +23,11 @@ struct SimplifiedResult {#[derive(Clone, Serialize)]pub struct SimplifiedWindowResult {- pub image: String, // Changed to String to store base64-encoded image+ // pub image: String,pub window_name: String,pub app_name: String,pub text: String,+ pub text_json: Vec<HashMap<String, String>>, // Change this linepub focused: bool,pub confidence: f64,}@@ -102,9 +104,9 @@ async fn run_websocket_server() -> Result<()> {let addr = format!("127.0.0.1:{}", port);let listener = TcpListener::bind(&addr).await?;- println!("WebSocket server listening on: {}", addr);+ println!("websocket server listening on: {}", addr);- let (tx, _) = tokio::sync::broadcast::channel::<SimplifiedResult>(512);+ let (tx, _) = tokio::sync::broadcast::channel::<SimplifiedResult>(2);let tx = Arc::new(tx);let tx_clone = tx.clone();@@ -128,10 +130,11 @@ async fn run_websocket_server(let base64_image = general_purpose::STANDARD.encode(buffer);SimplifiedWindowResult {- image: base64_image,+ // image: base64_image,window_name: window.window_name,app_name: window.app_name,text: window.text,+ text_json: window.text_json, // Add this linefocused: window.focused,confidence: window.confidence,}@@ -140,6 +143,9 @@ async fn run_websocket_server(timestamp: result.timestamp.elapsed().as_secs(),};let _ = tx_clone.send(simplified);++ // resubscribe to get only the latest message+ let _ = tx_clone.subscribe().resubscribe();}});diff --git a/screenpipe-vision/src/bin/screenpipe-vision.rs b/screenpipe-vision/src/bin/screenpipe-vision.rsindex 2e1721de0..28440e497 100644--- a/screenpipe-vision/src/bin/screenpipe-vision.rs+++ b/screenpipe-vision/src/bin/screenpipe-vision.rs@@ -51,14 +51,15 @@ async fn main() {// Example: Process results for 10 seconds, then pause for 5 seconds, then stoploop {if let Some(result) = result_rx.recv().await {- println!(- "OCR Text length across visible windows: {}",- result- .window_ocr_results- .iter()- .map(|w| w.text.len())- .sum::<usize>()- );+ for window_result in &result.window_ocr_results {+ println!(+ "Window: {}\nApp: {}\nText length: {}\nJSON data: {:?}",+ window_result.window_name,+ window_result.app_name,+ window_result.text.len(),+ window_result.text_json // Use {:?} to print the JSON data+ );+ }}// tokio::time::sleep(Duration::from_secs_f32(1.0 / cli.fps)).await;diff --git a/screenpipe-vision/src/core.rs b/screenpipe-vision/src/core.rsindex 3af3d3c5a..acd5eb2c5 100644--- a/screenpipe-vision/src/core.rs+++ b/screenpipe-vision/src/core.rs@@ -31,7 +31,7 @@ pub struct WindowOcrResult {pub window_name: String,pub app_name: String,pub text: String,- pub text_json: Vec<HashMap<String, String>>,+ pub text_json: Vec<HashMap<String, String>>, // Change this linepub focused: bool,pub confidence: f64,}