use glint_mask_tools::{
algorithms::ThresholdAlgorithm,
core::{
masker::MaskerBuilder,
postprocessor::{CompositePostProcessor, MetashapeConverter, PixelBufferProcessor},
sensor::SensorRegistry,
},
error::Result,
loaders::SingleFileLoader,
};
use std::path::PathBuf;
fn main() -> Result<()> {
tracing_subscriber::fmt::init();
let input_dir = PathBuf::from("input_images");
let output_dir = PathBuf::from("output_masks");
let registry = SensorRegistry::from_user_config();
let rgb_sensor = registry.get_sensor("rgb").unwrap().clone();
let thresholds = vec![0.9, 0.8, 0.7]; let algorithm = ThresholdAlgorithm::new(thresholds)?;
let postprocessor = CompositePostProcessor::new()
.add_processor(Box::new(PixelBufferProcessor::new(2))) .add_processor(Box::new(MetashapeConverter::new()));
let loader = SingleFileLoader::rgb()?;
let masker = MaskerBuilder::new()
.with_sensor(rgb_sensor)
.with_algorithm(Box::new(algorithm))
.with_postprocessor(Box::new(postprocessor))
.with_loader(Box::new(loader))
.build()?;
println!("Processing RGB images...");
let stats = masker.process_directory(&input_dir, &output_dir, None)?;
println!("Processing complete!");
println!("Total captures: {}", stats.total_captures);
println!("Successful: {}", stats.successful_captures);
println!("Failed: {}", stats.failed_captures);
println!("Success rate: {:.1}%", stats.success_rate());
if !stats.all_successful() {
eprintln!("Some captures failed to process");
for error in &stats.errors {
eprintln!(" Error: {}", error);
}
}
Ok(())
}