Compare commits
2 Commits
4bdd3a8411
...
2347158093
Author | SHA1 | Date | |
---|---|---|---|
|
2347158093 | ||
|
faccc3d20b |
107
Cargo.lock
generated
107
Cargo.lock
generated
|
@ -168,6 +168,54 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96b09b5178381e0874812a9b157f7fe84982617e48f71f4e3235482775e5b540"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.77"
|
||||
|
@ -715,6 +763,46 @@ dependencies = [
|
|||
"libloading 0.8.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
|
||||
|
||||
[[package]]
|
||||
name = "clipboard-win"
|
||||
version = "5.1.0"
|
||||
|
@ -770,6 +858,12 @@ version = "1.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||
|
||||
[[package]]
|
||||
name = "com"
|
||||
version = "0.6.0"
|
||||
|
@ -2925,6 +3019,12 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
|
@ -2979,6 +3079,7 @@ name = "thermaldecoder"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"crossbeam",
|
||||
"crossbeam-channel",
|
||||
"dotenv",
|
||||
|
@ -3227,6 +3328,12 @@ dependencies = [
|
|||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||
|
||||
[[package]]
|
||||
name = "v4l"
|
||||
version = "0.14.0"
|
||||
|
|
|
@ -11,6 +11,7 @@ crate-type = ["rlib", "cdylib"]
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1.0.77"
|
||||
clap = { version = "4.5.1", features = ["derive"] }
|
||||
crossbeam = "0.8.4"
|
||||
crossbeam-channel = "0.5.11"
|
||||
dotenv = "0.15.0"
|
||||
|
|
|
@ -1,9 +1,31 @@
|
|||
use clap::Parser;
|
||||
use dotenv::dotenv;
|
||||
use std::io::Write;
|
||||
use thermaldecoder::{Header, HDR_SIZE};
|
||||
use v4l::video::Output;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct Args {
|
||||
#[arg(short, long, default_value_t = false)]
|
||||
temperature: bool,
|
||||
#[arg(short, long, default_value = "/dev/video0")]
|
||||
device: String,
|
||||
}
|
||||
|
||||
fn pixel_to_celcius(x: u16) -> u16 {
|
||||
let x: f64 = x.into();
|
||||
let x = x / 256.0;
|
||||
let t = (-1.665884e-08) * x.powf(4.)
|
||||
+ (1.347094e-05) * x.powf(3.)
|
||||
+ (-4.396264e-03) * x.powf(2.)
|
||||
+ (9.506939e-01) * x
|
||||
+ (-6.353247e+01);
|
||||
(t * 256.0) as u16
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let args = Args::parse();
|
||||
dotenv().ok();
|
||||
let device = match std::env::var("THERMALCAM_IFACE=enp1s0f0") {
|
||||
Ok(d) => {
|
||||
|
@ -21,9 +43,7 @@ fn main() -> anyhow::Result<()> {
|
|||
// get the default Device
|
||||
|
||||
println!("Using device {}", device.name);
|
||||
let output = std::env::args()
|
||||
.nth(1)
|
||||
.expect("required output file argument");
|
||||
let output = args.device;
|
||||
println!("Using output v4l2loopback device {}", output);
|
||||
|
||||
const WIDTH: usize = 288;
|
||||
|
@ -73,8 +93,12 @@ fn main() -> anyhow::Result<()> {
|
|||
// possibly limitation of current v4l2loopback or v4l rust wrapper or libv4l2
|
||||
let mut swapped = [0u8; FRAME_LEN];
|
||||
for i in 0..FRAME_LEN / 2 {
|
||||
swapped[i * 2] = frame[i * 2 + 1];
|
||||
swapped[i * 2 + 1] = frame[i * 2];
|
||||
let mut pixel = u16::from_be_bytes([frame[i * 2], frame[i * 2 + 1]]);
|
||||
if args.temperature {
|
||||
pixel = pixel_to_celcius(pixel);
|
||||
}
|
||||
let pixel_swapped = pixel.to_le_bytes();
|
||||
swapped[i * 2..i * 2 + 2].copy_from_slice(&pixel_swapped);
|
||||
}
|
||||
out.write_all(&swapped[..])?;
|
||||
}
|
||||
|
|
|
@ -10,4 +10,4 @@ TARGET=./target/release/examples/live
|
|||
# setcap does not work yet (EPERM on socket AF_PACKET)
|
||||
# sudo setcap cap_net_raw,cap_net_admin=eip $TARGET
|
||||
#sudo strace -f -o live.strace $TARGET /dev/video0
|
||||
sudo $TARGET /dev/video0
|
||||
sudo RUST_BACKTRACE=full $TARGET "$@"
|
||||
|
|
13
run_live_debug.sh
Executable file
13
run_live_debug.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
cd $(dirname $0)
|
||||
|
||||
set -e
|
||||
|
||||
# Python works but stutters
|
||||
#sudo ./venv/bin/python ./decode.py --live
|
||||
cargo build --example live
|
||||
TARGET=./target/debug/examples/live
|
||||
# setcap does not work yet (EPERM on socket AF_PACKET)
|
||||
# sudo setcap cap_net_raw,cap_net_admin=eip $TARGET
|
||||
#sudo strace -f -o live.strace $TARGET /dev/video0
|
||||
sudo RUST_BACKTRACE=full $TARGET "$@"
|
Loading…
Reference in New Issue
Block a user