Skip to content

Commit

Permalink
Revert accidentially pushed commits
Browse files Browse the repository at this point in the history
some commits
(6878214..6878214) were accidentially pushed to the main branch. this reverts this misstake
  • Loading branch information
anuejn committed Mar 11, 2024
1 parent bcc0542 commit 3733167
Show file tree
Hide file tree
Showing 45 changed files with 1,225 additions and 1,524 deletions.
49 changes: 6 additions & 43 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ track-drop = ["backtrace"]
clap = { version = "3.1.18", features = ["default", "derive"] }
indicatif = "0.17.0"
glob = "0.3.0"
anyhow = { version = "1.0.57", features = ["backtrace"] }
anyhow = "1.0.57"
itertools = "0.10.3"
bytemuck = "1.9.1"
vulkano = "0.30.0"
Expand Down Expand Up @@ -50,10 +50,6 @@ tokio = { version = "1.19.2", features = ["full"] }
hyper = { version = "0.14.23", features = ["full"] }
futures-util = "0.3.25"
portpicker = "0.1.1"
shaderc = "0.8.2"
indoc = "2.0.0"
spirv-reflect = "0.2.3"
regex = "1.7.1"

[target.'cfg(target_os = "linux")'.dependencies]
v4l = "0.13.0"
Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ The config file supports variable substitution. You can set name value pairs on

## Examples

Display a live stream from the AXIOM Beta (running in raw mode, adjust --device= number accoring to your HDMI capture device):
```shell
$ target/release/cli from-cli WebcamInput --device=0 ! DualFrameRawDecoder ! BitDepthConverter ! Debayer ! Display
```

Convert a directory of raw12 files recorded previously from the AXIOM Beta to mp4 (h264) using FFmpeg:
```shell
$ target/release/cli from-cli RawDirectoryReader --file-pattern '~/Darkbox-Timelapse-Clock-Sequence/*.raw12' --bit-depth 12 --height 3072 --width 4096 --loop true --fps 30 ! BitDepthConverter ! Debayer ! FfmpegWriter --output darkbox.mp4
Expand Down
42 changes: 11 additions & 31 deletions src/bin/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ fn processing_node_from_commandline(
let node_descriptor: &ParameterizableDescriptor =
available_nodes.get(name).ok_or_else(|| {
anyhow!(
"cant find node with name {}. available nodes are: \n{}",
"cant find node with name {}. avalable nodes are: \n{}",
name,
nodes_usages_string()
)
Expand All @@ -204,16 +204,13 @@ fn processing_node_from_commandline(
Mandatory(NodeInputParameter) | WithDefault(NodeInputParameter, _)
)
})
.filter_map(|(key, parameter_type)| {
results.value_of(key).map(|v| {
Ok((
key.to_string(),
parameter_type
.get_parameter_type()
.parse(v)
.context(format!("parameter is {}", key))?,
))
})
.map(|(key, parameter_type)| {
Ok((
key.to_string(),
parameter_type
.parse(results.value_of(key))
.context(format!("parameter is {}", key))?,
))
})
.collect::<Result<_, anyhow::Error>>()?;

Expand All @@ -231,7 +228,7 @@ fn clap_app_from_node_name(name: &str) -> Result<clap::Command<'static>> {
let node_descriptor: &ParameterizableDescriptor =
available_nodes.get(name).ok_or_else(|| {
anyhow!(
"cant find node with name {}. available nodes are: {:?}",
"cant find node with name {}. avalable nodes are: {:?}",
name,
available_nodes.keys()
)
Expand All @@ -255,40 +252,23 @@ fn clap_app_from_node_name(name: &str) -> Result<clap::Command<'static>> {
.allow_hyphen_values(true)
.validator(move |v| {
parameter_type_for_closure
.get_parameter_type()
.parse(v)
.parse(Some(v))
.map(|_| ())
.map_err(|e| format!("{}", e))
})
.required(true),
WithDefault(BoolParameter, BoolValue(false)) => {
Arg::new(key.as_str()).long(key).takes_value(false).required(false)
}
WithDefault(_, default) => Arg::new(key.as_str())
.long(key)
.takes_value(true)
.allow_hyphen_values(true)
.validator(move |v| {
parameter_type_for_closure
.get_parameter_type()
.parse(v)
.parse(Some(v))
.map(|_| ())
.map_err(|e| format!("{}", e))
})
.default_value(Box::leak(Box::new(default.to_string())))
.required(false),
Optional(_) => Arg::new(key.as_str())
.long(key)
.takes_value(true)
.allow_hyphen_values(true)
.validator(move |v| {
parameter_type_for_closure
.get_parameter_type()
.parse(v)
.map(|_| ())
.map_err(|e| format!("{}", e))
})
.required(false),
})
}
Ok(app)
Expand Down
11 changes: 7 additions & 4 deletions src/gui/image.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::pipeline_processing::{buffers::GpuBuffer, frame::Frame};
use crate::pipeline_processing::{
buffers::GpuBuffer,
frame::{Frame, Rgb},
};
use derivative::Derivative;
use narui::{layout::Maximal, *};
use std::sync::Arc;
Expand Down Expand Up @@ -117,7 +120,7 @@ impl<T> PartialEq for ArcPartialEqHelper<T> {
}

#[widget]
pub fn image(image: Arc<Frame<GpuBuffer>>, context: &mut WidgetContext) -> FragmentInner {
pub fn image(image: Arc<Frame<Rgb, GpuBuffer>>, context: &mut WidgetContext) -> FragmentInner {
let cloned_image = ArcPartialEqHelper(image.clone());
let device = context.vulkan_context.device.clone();

Expand Down Expand Up @@ -156,8 +159,8 @@ pub fn image(image: Arc<Frame<GpuBuffer>>, context: &mut WidgetContext) -> Fragm
origin: origin.into(),
size: size.into(),
z_index,
width: image.interpretation.width as u32,
height: image.interpretation.height as u32,
width: image.interp.width as u32,
height: image.interp.height as u32,
_dummy0: Default::default(),
};

Expand Down
28 changes: 13 additions & 15 deletions src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ use crate::nodes_gpu::plot::Plot;
use crate::nodes_io::reader_webcam::WebcamInput;
use crate::{
nodes_cpu::{
//average::Average,
average::Average,
benchmark_sink::BenchmarkSink,
bitdepth_convert::BitDepthConverter,
dual_frame_raw_decoder::{DualFrameRawDecoder, ReverseDualFrameRawDecoder},
//sz3::SZ3Compress,
sz3::SZ3Compress,
zstd::ZstdBlobReader,
},
nodes_gpu::{
bitdepth_convert::GpuBitDepthConverter,
calibrate::Calibrate,
color_voodoo::ColorVoodoo,
debayer::Debayer,
Expand All @@ -33,14 +35,10 @@ use crate::{
processing_context::ProcessingContext,
},
};
use crate::{
nodes_gpu::base_gpu_node::GpuNodeImpl,
nodes_io::{frameserver_cinema_dng::CinemaDngFrameserver, writer_ffmpeg::FfmpegWriter},
nodes_util::null_source::NullFrameSource,
};

use crate::nodes_io::{frameserver_cinema_dng::CinemaDngFrameserver, writer_ffmpeg::FfmpegWriter};
use anyhow::{anyhow, Result};
use std::collections::HashMap;

macro_rules! generate_dynamic_node_creation_functions {
($($(#[$m:meta])? $x:ty),+ $(,)?) => {
pub fn list_available_nodes() -> HashMap<String, ParameterizableDescriptor> {
Expand All @@ -67,27 +65,28 @@ macro_rules! generate_dynamic_node_creation_functions {
};
}


generate_dynamic_node_creation_functions![
RawDirectoryReader,
RawBlobReader,
CinemaDngWriter,
CinemaDngReader,
GpuNodeImpl<Debayer>,
GpuNodeImpl<ColorVoodoo>,
GpuNodeImpl<Lut3d>,
GpuBitDepthConverter,
Debayer,
#[cfg(target_os = "linux")]
Display,
BitDepthConverter,
DualFrameRawDecoder,
ReverseDualFrameRawDecoder,
BenchmarkSink,
ColorVoodoo,
RawDirectoryWriter,
RawBlobWriter,
//Average,
Lut3d,
Average,
TcpReader,
Cache,
Split,
//SZ3Compress,
SZ3Compress,
ZstdBlobReader,
Calibrate,
Histogram,
Expand All @@ -97,5 +96,4 @@ generate_dynamic_node_creation_functions![
WebcamInput,
FfmpegWriter,
CinemaDngFrameserver,
NullFrameSource,
];
22 changes: 11 additions & 11 deletions src/nodes_cpu/average.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
pipeline_processing::{
buffers::ChunkedCpuBuffer,
frame::{Frame},
frame::{Frame, Raw},
node::{Caps, InputProcessingNode, NodeID, ProcessingNode, Request},
parametrizable::prelude::*,
payload::Payload,
Expand Down Expand Up @@ -37,7 +37,7 @@ impl Parameterizable for Average {
Ok(Self {
input: parameters.take("input")?,
num_frames: parameters.take::<i64>("n")? as usize,
produce_std: parameters.has("std"),
produce_std: parameters.take("std")?,
last_frame_info: Default::default(),
context: context.clone(),
})
Expand All @@ -64,18 +64,18 @@ impl ProcessingNode for Average {

let context = &self.context;
let frame =
context.ensure_cpu_buffer_frame(&input).context("Wrong input format for Average")?;
let interpretation = frame.interpretation.clone();
assert_eq!(frame.interpretation.bit_depth, 12);
context.ensure_cpu_buffer::<Raw>(&input).context("Wrong input format for Average")?;
let interp = frame.interp;
assert_eq!(frame.interp.bit_depth, 12);

// println!("[{frame_number}] adding {n}");

// f32 -> 4 bytes per pixel
let out_buffer_avg =
unsafe { context.get_uninit_cpu_buffer((interpretation.height * interpretation.width * 4) as usize) };
unsafe { context.get_uninit_cpu_buffer((interp.height * interp.width * 4) as usize) };

let out_buffer_std =
unsafe { context.get_uninit_cpu_buffer((interpretation.height * interpretation.width * 4) as usize) };
unsafe { context.get_uninit_cpu_buffer((interp.height * interp.width * 4) as usize) };

let out = Arc::new(ChunkedCpuBuffer::<usize, 2>::new(
[out_buffer_avg, out_buffer_std],
Expand Down Expand Up @@ -127,7 +127,7 @@ impl ProcessingNode for Average {
_ => {}
}
let input = input?;
let frame = context_copy.ensure_cpu_buffer(&input).context("Wrong input format for Average")?;
let frame = context_copy.ensure_cpu_buffer::<Raw>(&input).context("Wrong input format for Average")?;
assert_eq!(interp.bit_depth, 12);

frame.storage.as_slice_async(|frame: &[u8]| async move {
Expand Down Expand Up @@ -198,10 +198,10 @@ impl ProcessingNode for Average {
}
});

let mut interp = interpretation;
let mut interp = interp;
interp.bit_depth = 32;
let avg_frame = Frame { storage: avg_buffer, interpretation: interp };
let std_frame = Frame { storage: std_buffer, interpretation: interp };
let avg_frame = Frame { storage: avg_buffer, interp };
let std_frame = Frame { storage: std_buffer, interp };

if self.produce_std {
Ok(Payload::from(vec![Payload::from(avg_frame), Payload::from(std_frame)]))
Expand Down
Loading

0 comments on commit 3733167

Please sign in to comment.