allow pick and flip with open cam
This commit is contained in:
parent
37df6fc27e
commit
7ed1e5e4e6
1 changed files with 25 additions and 25 deletions
|
|
@ -27,7 +27,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
std::process::exit(1);
|
||||
}
|
||||
|
||||
// Check if the whitening flag is set
|
||||
// Check if the quick flag is set
|
||||
let quick = args.contains(&String::from("-q"));
|
||||
|
||||
let camera_index: usize = args[1].parse().expect("Failed to parse camera index as a number");
|
||||
|
|
@ -74,20 +74,23 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
let grayscale_data1 = frame_to_grayscale(&data1);
|
||||
|
||||
if !ocelli.is_covered(&grayscale_data1, 50) {
|
||||
|
||||
let entropy: Vec<u8>;
|
||||
let mut entropy: Vec<u8> = [0].to_vec();
|
||||
|
||||
if quick {
|
||||
// Quicker capture using Pick and Flip
|
||||
entropy = ocelli.whiten(&ocelli.pick_and_flip(&grayscale_data1, frame_count as usize));
|
||||
} else {
|
||||
if ocelli.is_covered(&grayscale_data1, 50) {
|
||||
// Capture second frame
|
||||
let (data2, _) = stream.next().expect("Failed to capture second frame");
|
||||
let grayscale_data2 = frame_to_grayscale(&data2);
|
||||
|
||||
// Generate entropy using chop_and_tack
|
||||
entropy = ocelli.chop_and_tack(&grayscale_data1, &grayscale_data2, format.width as usize, 30);
|
||||
} else {
|
||||
println!("Camera is not covered. Please cover the camera.");
|
||||
frame_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
let shannon_entropy = ocelli.shannon(&entropy);
|
||||
|
|
@ -103,10 +106,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
} else {
|
||||
println!("Rejected entropy for frame {} (Shannon entropy: {:.3})", frame_count, shannon_entropy);
|
||||
}
|
||||
} else {
|
||||
println!("Camera is not covered. Please cover the camera.");
|
||||
frame_count = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue