remove indicatif, add dotenv, write to stdout, gst to v4lsink, usable with ffplay, still some hiccups, not cpu related
This commit is contained in:
parent
5acd03828d
commit
49f9aa98ed
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -965,6 +965,12 @@ dependencies = [
|
|||
"litrs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dotenv"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
||||
|
||||
[[package]]
|
||||
name = "downcast-rs"
|
||||
version = "1.2.0"
|
||||
|
@ -2892,6 +2898,7 @@ dependencies = [
|
|||
"anyhow",
|
||||
"crossbeam",
|
||||
"crossbeam-channel",
|
||||
"dotenv",
|
||||
"eframe",
|
||||
"egui",
|
||||
"indicatif",
|
||||
|
|
|
@ -13,6 +13,7 @@ crate-type = ["rlib", "cdylib"]
|
|||
anyhow = "1.0.77"
|
||||
crossbeam = "0.8.4"
|
||||
crossbeam-channel = "0.5.11"
|
||||
dotenv = "0.15.0"
|
||||
eframe = "0.26.2"
|
||||
egui = "0.26.2"
|
||||
indicatif = "0.17.7"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use indicatif::ProgressBar;
|
||||
use dotenv::dotenv;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use thermaldecoder::{Frame, Header, HDR_SIZE};
|
||||
|
@ -37,11 +37,27 @@ use thermaldecoder::{Frame, Header, HDR_SIZE};
|
|||
// }
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
dotenv().ok();
|
||||
let device = match std::env::var("THERMALCAM_IFACE=enp1s0f0") {
|
||||
Ok(d) => {
|
||||
let device = pcap::Device::list()
|
||||
.expect("device list failed")
|
||||
.into_iter()
|
||||
.find(|x| x.name == d)
|
||||
.expect(&format!("could not find device {}", d));
|
||||
device
|
||||
}
|
||||
Err(_) => pcap::Device::lookup()
|
||||
.expect("device lookup failed")
|
||||
.expect("no device available"),
|
||||
};
|
||||
// get the default Device
|
||||
let device = pcap::Device::lookup()
|
||||
.expect("device lookup failed")
|
||||
.expect("no device available");
|
||||
|
||||
println!("Using device {}", device.name);
|
||||
let output = std::env::args()
|
||||
.nth(1)
|
||||
.expect("required output file argument");
|
||||
println!("Using output {}", output);
|
||||
|
||||
// Setup Capture
|
||||
let mut cap = pcap::Capture::from_device(device)
|
||||
|
@ -52,8 +68,7 @@ fn main() -> anyhow::Result<()> {
|
|||
|
||||
// get a packet and print its bytes
|
||||
let mut parts = vec![];
|
||||
let pb = ProgressBar::new(1024);
|
||||
let mut out = File::create("output.raw")?;
|
||||
let mut out = File::create(&output)?;
|
||||
while let Ok(p) = cap.next_packet() {
|
||||
let data = p.data;
|
||||
if data.len() != 6972 {
|
||||
|
@ -72,7 +87,6 @@ fn main() -> anyhow::Result<()> {
|
|||
};
|
||||
if frame.raw.len() == 384 * 288 * 2 {
|
||||
out.write_all(&frame.raw)?;
|
||||
pb.inc(1);
|
||||
}
|
||||
parts.clear();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
|
||||
import base64
|
||||
from scapy.all import *
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# Base64 encoded packet data
|
||||
encoded_packet = "////////AAFsWfAKCABFAAA4KB0AAIARkEfAqAABwKgA/x+bH5wA2QAAASABgBtAACAAAAAAAAAADwAAAAEAAAEAACArAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////////////////////////////////AAAAAAAAAAIBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||
|
@ -16,5 +20,8 @@ decoded_packet = base64.b64decode(encoded_packet)
|
|||
packet = Ether(decoded_packet)
|
||||
#print(packet.show(dump=True))
|
||||
|
||||
iface = os.environ.get('THERMALCAM_IFACE', 'enp1s0f0')
|
||||
print(f'using interface {iface}')
|
||||
|
||||
# (packet)
|
||||
sendp(packet, iface="enp1s0f0")
|
||||
sendp(packet, iface=iface)
|
||||
|
|
13
run_live.sh
13
run_live.sh
|
@ -1,3 +1,14 @@
|
|||
#!/bin/bash
|
||||
cd $(dirname $0)
|
||||
sudo ./venv/bin/python ./decode.py --live
|
||||
|
||||
set -e
|
||||
|
||||
# Python works but stutters
|
||||
#sudo ./venv/bin/python ./decode.py --live
|
||||
cargo build --release --example live
|
||||
sudo ./target/release/examples/live /dev/stdout | gst-launch-1.0 filesrc location=/dev/stdin \
|
||||
! rawvideoparse use_sink_caps=false height=384 width=288 format=gray16-le \
|
||||
! videoconvertscale \
|
||||
! v4l2sink device=/dev/video0
|
||||
# ! videoconvertscale
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user