v4l by rust process, still sudo, endianess reversed
This commit is contained in:
@@ -1,40 +1,7 @@
|
||||
use dotenv::dotenv;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use thermaldecoder::{Frame, Header, HDR_SIZE};
|
||||
|
||||
// fn main() -> Result<(), eframe::Error> {
|
||||
// env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||
// let options = eframe::NativeOptions {
|
||||
// viewport: egui::ViewportBuilder::default().with_inner_size([600.0, 800.0]),
|
||||
// ..Default::default()
|
||||
// };
|
||||
// let (sender, receiver) = crossbeam::channel::unbounded();
|
||||
// eframe::run_native(
|
||||
// "Image Viewer",
|
||||
// options,
|
||||
// Box::new(|cc| {
|
||||
// // This gives us image support:
|
||||
// egui_extras::install_image_loaders(&cc.egui_ctx);
|
||||
// Box::<MyApp>::default()
|
||||
// }),
|
||||
// )
|
||||
// }
|
||||
|
||||
// #[derive(Default)]
|
||||
// struct MyApp {}
|
||||
|
||||
// impl eframe::App for MyApp {
|
||||
// fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
// egui::CentralPanel::default().show(ctx, |ui| {
|
||||
// egui::ScrollArea::both().show(ui, |ui| {
|
||||
// ui.add(egui::Image::new().rounding(10.0));
|
||||
|
||||
// ui.image(egui::include_image!("ferris.svg"));
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
use thermaldecoder::{Header, HDR_SIZE};
|
||||
use v4l::video::Output;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
dotenv().ok();
|
||||
@@ -57,7 +24,20 @@ fn main() -> anyhow::Result<()> {
|
||||
let output = std::env::args()
|
||||
.nth(1)
|
||||
.expect("required output file argument");
|
||||
println!("Using output {}", output);
|
||||
println!("Using output v4l2loopback device {}", output);
|
||||
|
||||
const WIDTH: usize = 288;
|
||||
const HEIGHT: usize = 384;
|
||||
|
||||
let mut out = v4l::Device::with_path(output)?;
|
||||
// To find the fourcc code, use v4l2-ctl --list-formats-out /dev/video0
|
||||
// (or read the source :)
|
||||
let format = v4l::Format::new(
|
||||
WIDTH as u32,
|
||||
HEIGHT as u32,
|
||||
v4l::format::FourCC::new(b"Y16 "),
|
||||
);
|
||||
Output::set_format(&out, &format)?;
|
||||
|
||||
// Setup Capture
|
||||
let mut cap = pcap::Capture::from_device(device)
|
||||
@@ -68,13 +48,12 @@ fn main() -> anyhow::Result<()> {
|
||||
|
||||
// get a packet and print its bytes
|
||||
const PACKET_LEN: usize = 6972;
|
||||
const FRAME_LEN: usize = 288 * 384 * 2;
|
||||
const FRAME_LEN: usize = WIDTH * HEIGHT * 2;
|
||||
let mut frame = [0u8; FRAME_LEN];
|
||||
let mut len = 0;
|
||||
let mut out = File::create(&output)?;
|
||||
while let Ok(p) = cap.next_packet() {
|
||||
let data = p.data;
|
||||
if data.len() != 6972 {
|
||||
if data.len() != PACKET_LEN {
|
||||
continue;
|
||||
}
|
||||
let data = &data[0x2a..];
|
||||
|
||||
Reference in New Issue
Block a user