Skip to content

Commit

Permalink
updated test
Browse files Browse the repository at this point in the history
  • Loading branch information
m13v committed Jul 18, 2024
1 parent b62d9df commit e977098
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions screenpipe-vision/tests/integration_test.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -9,17 +10,45 @@ fn test_ocr_output() -> Result<(), Box<dyn std::error::Error>> {

// 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(())
}

0 comments on commit e977098

Please sign in to comment.