note: to be able to run this example you need the rustml dataset package see https://github.com/daniel-e/rustml#datasets The result of this example can be plotted with Octave as follows: start Octave and type: > load("/tmp/day_and_night.txt"); > hist(day_and_night, 256);
()
| 15 | // > load("/tmp/day_and_night.txt"); |
| 16 | // > hist(day_and_night, 256); |
| 17 | fn main() { |
| 18 | let video = Video::from_file( |
| 19 | &consts::path_for("videos/day_and_night_in_gray.avi").unwrap()).unwrap(); |
| 20 | let mask = GrayImage::from_file( |
| 21 | &consts::path_for("videos/day_and_night_in_gray_mask_sky.png").unwrap()).unwrap(); |
| 22 | |
| 23 | let mut f = File::create("/tmp/day_and_night.txt").unwrap(); |
| 24 | |
| 25 | for (idx, img) in video.gray_frame_iter().enumerate() { |
| 26 | |
| 27 | // write status to stderr for the impatient |
| 28 | if idx % 1000 == 0 { |
| 29 | writeln!(&mut std::io::stderr(), "{} frames", idx).unwrap(); |
| 30 | } |
| 31 | |
| 32 | writeln!(f, "{}", |
| 33 | img.mask_iter(&mask).map(|x| x as u32).collect::<Vec<u32>>().mean() |
| 34 | ).unwrap(); |
| 35 | } |
| 36 | } |
| 37 |
nothing calls this directly
no test coverage detected