Compare commits
No commits in common. "d6c5058f2eb02b7e5a8a900f1b8f87c34e933147" and "862a48131e52d013cadf1e814086f4202d4728a8" have entirely different histories.
d6c5058f2e
...
862a48131e
|
@ -6,6 +6,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
let mut arg = env::args();
|
let mut arg = env::args();
|
||||||
arg.next(); // skip executable
|
arg.next(); // skip executable
|
||||||
let filename = arg.next().ok_or(anyhow::anyhow!("unexpected"))?;
|
let filename = arg.next().ok_or(anyhow::anyhow!("unexpected"))?;
|
||||||
decode_to_files(&filename)?;
|
let frames = arg.next().unwrap_or("frames".into());
|
||||||
|
decode_to_files(&filename, &frames)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
cargo run --release --example main -- "$@"
|
|
17
src/lib.rs
17
src/lib.rs
|
@ -251,26 +251,15 @@ fn decode(filename: &str) -> PyResult<PyFrameIterator> {
|
||||||
Ok(iter.into())
|
Ok(iter.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// writes to frames/<basename of filename>
|
pub fn decode_to_files(filename: &str, frames_root: &str) -> anyhow::Result<()> {
|
||||||
pub fn decode_to_files(filename: &str) -> anyhow::Result<()> {
|
|
||||||
let frameiter = Decoder::new(filename)?;
|
let frameiter = Decoder::new(filename)?;
|
||||||
let basename = std::path::Path::new(filename)
|
|
||||||
.file_stem()
|
|
||||||
.ok_or(anyhow::anyhow!("cannot get basename"))?
|
|
||||||
.to_str()
|
|
||||||
.ok_or(anyhow::anyhow!("cannot convert to utf-8 from os name"))?;
|
|
||||||
let target_dir = format!("frames/{}", basename);
|
|
||||||
let target_dir = std::path::Path::new(&target_dir);
|
|
||||||
if !target_dir.exists() {
|
|
||||||
std::fs::create_dir(target_dir)?;
|
|
||||||
}
|
|
||||||
for (i, frame) in frameiter.enumerate() {
|
for (i, frame) in frameiter.enumerate() {
|
||||||
let name = format!("frames/{}/{:05}.png", basename, i);
|
let name = format!("{}/{:05}.png", frames_root, i);
|
||||||
if let Err(_e) = write_raw_frame(&name, &frame.raw) {
|
if let Err(_e) = write_raw_frame(&name, &frame.raw) {
|
||||||
println!("skipping bad frame {}", i);
|
println!("skipping bad frame {}", i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let name = format!("{}/temp_{:05}.png", target_dir.display(), i);
|
let name = format!("{}/temp_{:05}.png", frames_root, i);
|
||||||
let pixels = frame.pixels();
|
let pixels = frame.pixels();
|
||||||
write_calibrated_frame(&name, &pixels)?;
|
write_calibrated_frame(&name, &pixels)?;
|
||||||
}
|
}
|
||||||
|
|
BIN
thermal.mp4
BIN
thermal.mp4
Binary file not shown.
Loading…
Reference in New Issue
Block a user