Compare commits
2 Commits
862a48131e
...
d6c5058f2e
Author | SHA1 | Date | |
---|---|---|---|
|
d6c5058f2e | ||
|
3ea0c74e7f |
|
@ -6,7 +6,6 @@ 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"))?;
|
||||||
let frames = arg.next().unwrap_or("frames".into());
|
decode_to_files(&filename)?;
|
||||||
decode_to_files(&filename, &frames)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
2
rustdecode.sh
Executable file
2
rustdecode.sh
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
cargo run --release --example main -- "$@"
|
17
src/lib.rs
17
src/lib.rs
|
@ -251,15 +251,26 @@ fn decode(filename: &str) -> PyResult<PyFrameIterator> {
|
||||||
Ok(iter.into())
|
Ok(iter.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decode_to_files(filename: &str, frames_root: &str) -> anyhow::Result<()> {
|
/// writes to frames/<basename of filename>
|
||||||
|
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!("{}/{:05}.png", frames_root, i);
|
let name = format!("frames/{}/{:05}.png", basename, 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", frames_root, i);
|
let name = format!("{}/temp_{:05}.png", target_dir.display(), 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