MCPcopy Create free account
hub / github.com/daniel-e/rustml / main

Function main

examples/video_histogram.rs:17–36  ·  view source on GitHub ↗

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);

()

Source from the content-addressed store, hash-verified

15// > load("/tmp/day_and_night.txt");
16// > hist(day_and_night, 256);
17fn 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

Callers

nothing calls this directly

Calls 3

from_fileFunction · 0.85
path_forFunction · 0.85
gray_frame_iterMethod · 0.80

Tested by

no test coverage detected