diff --git a/screenpipe-vision/tests/integration_test.rs b/screenpipe-vision/tests/integration_test.rs index ce109278..ffc9ec59 100644 --- a/screenpipe-vision/tests/integration_test.rs +++ b/screenpipe-vision/tests/integration_test.rs @@ -1,6 +1,7 @@ use assert_fs::prelude::*; use std::path::PathBuf; use std::fs; +use std::time::Instant; use screenpipe_vision::core::perform_ocr; // Adjust the import path #[test] @@ -9,17 +10,45 @@ fn test_ocr_output() -> Result<(), Box> { // Use the correct path to the testing_OCR.png file let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - path.push("tests/testing_OCR.png"); - println!("Path to testing_OCR.png: {:?}", path); + path.push("tests/image.png"); + println!("Path to image.png: {:?}", path); let image = image::open(&path).expect("Failed to open image"); - let (text, tsv_output, json_output) = perform_ocr(&image); - // println!("OCR Text: {}", text); - println!("json_output: {}", json_output); + // Start timing + let start = Instant::now(); + + let (text, data_output, json_output) = perform_ocr(&image); + + // Stop timing + let duration = start.elapsed(); + let duration_secs = duration.as_secs_f64(); + + // Calculate average confidence score + let total_conf: f32 = data_output.data.iter().map(|line| line.conf).sum(); + let avg_conf = total_conf / data_output.data.len() as f32; + + println!("Average confidence score: {:.2}", avg_conf); + + // println!("TSV:"); + // println!("{}", tsv_output); + // println!("Text:"); + // println!("{}", text); + // println!("json_output:"); + // println!("{}", json_output); + // println!("Data output:"); + // println!("{:?}", data_output); + + println!("Time taken for OCR: {:.1} seconds", duration_secs); + + // Print character lengths + println!("Character length of OCR text: {}", text.len()); + // println!("Character length of TSV output: {}", tsv_output.len()); + println!("Character length of JSON output: {}", json_output.len()); + assert!(!text.is_empty(), "OCR text should not be empty"); - assert!(!tsv_output.is_empty(), "TSV output should not be empty"); + // assert!(!tsv_output.is_empty(), "TSV output should not be empty"); Ok(()) } \ No newline at end of file