raised thresholds

This commit is contained in:
randogoth 2024-12-30 22:35:30 +02:00
parent 424acf0858
commit 37df6fc27e

View file

@ -60,26 +60,27 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let ocelli = Ocelli; let ocelli = Ocelli;
let mut total_entropy = Vec::new(); let mut total_entropy = Vec::new();
let start_time = Instant::now(); let start_time = Instant::now();
let shannon_threshold = 4.0; let shannon_threshold = 7.9;
let mut frame_count = 0; let mut frame_count = 0;
while total_entropy.len() < length { while total_entropy.len() < length {
// Capture first frame // Capture first frame
let (data1, _) = stream.next().expect("Failed to capture frame"); let (data1, _) = stream.next().expect("Failed to capture frame");
// Skip the first 30 frames
if frame_count <= 30 {
frame_count += 1;
} else {
let grayscale_data1 = frame_to_grayscale(&data1); let grayscale_data1 = frame_to_grayscale(&data1);
if ocelli.is_covered(&grayscale_data1, 50) { if !ocelli.is_covered(&grayscale_data1, 50) {
// Skip the first 10 frames
while frame_count < 10 {
let _ = stream.next().expect("Failed to capture frame");
frame_count += 1;
}
let entropy: Vec<u8>; let entropy: Vec<u8>;
if quick { if quick {
// Quicker capture using Pick and Flip // Quicker capture using Pick and Flip
entropy = ocelli.pick_and_flip(&grayscale_data1, frame_count as usize); entropy = ocelli.whiten(&ocelli.pick_and_flip(&grayscale_data1, frame_count as usize));
} else { } else {
// Capture second frame // Capture second frame
let (data2, _) = stream.next().expect("Failed to capture second frame"); let (data2, _) = stream.next().expect("Failed to capture second frame");
@ -100,13 +101,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
shannon_entropy shannon_entropy
); );
} else { } else {
println!("Rejected entropy (Shannon entropy: {:.3})", shannon_entropy); println!("Rejected entropy for frame {} (Shannon entropy: {:.3})", frame_count, shannon_entropy);
} }
} else { } else {
println!("Camera is not covered. Please cover the camera."); println!("Camera is not covered. Please cover the camera.");
frame_count = 0; frame_count = 0;
} }
} }
}
// Trim total_entropy to the exact length // Trim total_entropy to the exact length
total_entropy.truncate(length); total_entropy.truncate(length);