diff --git a/adder-codec-rs/src/transcoder/source/davis.rs b/adder-codec-rs/src/transcoder/source/davis.rs index 6dddf003..44653599 100644 --- a/adder-codec-rs/src/transcoder/source/davis.rs +++ b/adder-codec-rs/src/transcoder/source/davis.rs @@ -3,12 +3,12 @@ use crate::transcoder::source::video::SourceError::BufferEmpty; use crate::transcoder::source::video::{ integrate_for_px, Source, SourceError, Video, VideoBuilder, }; -use adder_codec_core::DeltaT; use adder_codec_core::Mode::{Continuous, FramePerfect}; +use adder_codec_core::{DeltaT, PixelMultiMode}; use davis_edi_rs::aedat::events_generated::Event as DvsEvent; use davis_edi_rs::util::reconstructor::{IterVal, ReconstructionError, Reconstructor}; +use rayon::iter::IndexedParallelIterator; use rayon::iter::ParallelIterator; -use rayon::iter::{IndexedParallelIterator}; use opencv::core::{Mat, CV_8U}; use opencv::prelude::*; @@ -950,7 +950,7 @@ impl Source for Davis { TranscoderMode::RawDvs => { let time_mult = 1E6 / self.time_change; let events_per_sec = self.num_dvs_events as f64 * time_mult; - // Best-case 9 bytes per raw DVS event + // Best-case 9 bytes per raw DVS event events_per_sec * 9.0 * 8.0 } } @@ -1020,6 +1020,7 @@ impl VideoBuilder for Davis { mut self, source_camera: SourceCamera, time_mode: TimeMode, + pixel_multi_mode: PixelMultiMode, encoder_type: EncoderType, encoder_options: EncoderOptions, write: W, @@ -1027,6 +1028,7 @@ impl VideoBuilder for Davis { self.video = self.video.write_out( Some(source_camera), Some(time_mode), + Some(pixel_multi_mode), encoder_type, encoder_options, write, diff --git a/adder-codec-rs/src/transcoder/source/framed.rs b/adder-codec-rs/src/transcoder/source/framed.rs index d833d4eb..89e51814 100644 --- a/adder-codec-rs/src/transcoder/source/framed.rs +++ b/adder-codec-rs/src/transcoder/source/framed.rs @@ -2,7 +2,7 @@ use crate::transcoder::source::video::SourceError; use crate::transcoder::source::video::Video; use crate::transcoder::source::video::{Source, VideoBuilder}; use adder_codec_core::Mode::FramePerfect; -use adder_codec_core::{DeltaT, Event, PlaneSize, SourceCamera, TimeMode}; +use adder_codec_core::{DeltaT, Event, PixelMultiMode, PlaneSize, SourceCamera, TimeMode}; use crate::utils::viz::ShowFeatureMode; use adder_codec_core::codec::{EncoderOptions, EncoderType}; @@ -257,6 +257,7 @@ impl VideoBuilder for Framed { mut self, source_camera: SourceCamera, time_mode: TimeMode, + pixel_multi_mode: PixelMultiMode, encoder_type: EncoderType, encoder_options: EncoderOptions, write: W, @@ -264,6 +265,7 @@ impl VideoBuilder for Framed { self.video = self.video.write_out( Some(source_camera), Some(time_mode), + Some(pixel_multi_mode), encoder_type, encoder_options, write, diff --git a/adder-codec-rs/src/transcoder/source/video.rs b/adder-codec-rs/src/transcoder/source/video.rs index 4185679c..273ed14d 100644 --- a/adder-codec-rs/src/transcoder/source/video.rs +++ b/adder-codec-rs/src/transcoder/source/video.rs @@ -157,7 +157,7 @@ pub enum FramedViewMode { pub struct VideoStateParams { pub(crate) pixel_tree_mode: Mode, - pub(crate) pixel_multi_mode: PixelMultiMode, + pub pixel_multi_mode: PixelMultiMode, /// The maximum time difference between events of the same pixel, in ticks pub delta_t_max: u32, @@ -303,6 +303,7 @@ pub trait VideoBuilder { self, source_camera: SourceCamera, time_mode: TimeMode, + pixel_multi_mode: PixelMultiMode, encoder_type: EncoderType, encoder_options: EncoderOptions, write: W, @@ -544,6 +545,7 @@ impl Video { mut self, source_camera: Option, time_mode: Option, + pixel_multi_mode: Option, encoder_type: EncoderType, encoder_options: EncoderOptions, write: W, @@ -552,7 +554,8 @@ impl Video { EncoderType::Compressed => { #[cfg(feature = "compression")] { - self.state.params.pixel_multi_mode = PixelMultiMode::Collapse; + self.state.params.pixel_multi_mode = + pixel_multi_mode.unwrap_or(PixelMultiMode::Collapse); let compression = CompressedOutput::new( CodecMetadata { codec_version: LATEST_CODEC_VERSION, @@ -578,7 +581,8 @@ impl Video { } } EncoderType::Raw => { - self.state.params.pixel_multi_mode = PixelMultiMode::Collapse; + self.state.params.pixel_multi_mode = + pixel_multi_mode.unwrap_or(PixelMultiMode::Collapse); let compression = RawOutput::new( CodecMetadata { codec_version: LATEST_CODEC_VERSION, @@ -596,7 +600,8 @@ impl Video { Encoder::new_raw(compression, encoder_options) } EncoderType::Empty => { - self.state.params.pixel_multi_mode = PixelMultiMode::Collapse; + self.state.params.pixel_multi_mode = + pixel_multi_mode.unwrap_or(PixelMultiMode::Collapse); let compression = EmptyOutput::new( CodecMetadata { codec_version: LATEST_CODEC_VERSION, diff --git a/adder-viz/src/transcoder/adder.rs b/adder-viz/src/transcoder/adder.rs index 50b31c00..2f419a9a 100644 --- a/adder-viz/src/transcoder/adder.rs +++ b/adder-viz/src/transcoder/adder.rs @@ -97,6 +97,7 @@ impl AdderTranscoder { framed = *framed.write_out( FramedU8, ui_state.time_mode, + ui_state.integration_mode_radio_state, ui_state.encoder_type, ui_state.encoder_options, writer, @@ -219,6 +220,7 @@ impl AdderTranscoder { davis_source = *davis_source.write_out( DavisU8, ui_state.time_mode, + ui_state.integration_mode_radio_state, ui_state.encoder_type, ui_state.encoder_options, writer, diff --git a/adder-viz/src/transcoder/ui.rs b/adder-viz/src/transcoder/ui.rs index 886fa70e..d4153bda 100644 --- a/adder-viz/src/transcoder/ui.rs +++ b/adder-viz/src/transcoder/ui.rs @@ -15,8 +15,8 @@ use std::error::Error; use crate::utils::PlotY; use adder_codec_rs::adder_codec_core::codec::rate_controller::{Crf, CRF, DEFAULT_CRF_QUALITY}; use adder_codec_rs::adder_codec_core::codec::{EncoderOptions, EncoderType, EventDrop, EventOrder}; -use adder_codec_rs::adder_codec_core::PlaneSize; use adder_codec_rs::adder_codec_core::TimeMode; +use adder_codec_rs::adder_codec_core::{PixelMultiMode, PlaneSize}; #[cfg(feature = "open-cv")] use adder_codec_rs::transcoder::source::davis::TranscoderMode::RawDvs; use adder_codec_rs::utils::cv::{calculate_quality_metrics, QualityMetrics}; @@ -69,6 +69,7 @@ pub struct ParamsUiState { metric_mse: bool, metric_psnr: bool, metric_ssim: bool, + pub(crate) integration_mode_radio_state: PixelMultiMode, } impl Default for ParamsUiState { @@ -113,6 +114,7 @@ impl Default for ParamsUiState { metric_mse: true, metric_psnr: true, metric_ssim: false, + integration_mode_radio_state: Default::default(), } } } @@ -448,7 +450,9 @@ impl TranscoderState { || source.get_video_ref().get_encoder_options().event_drop != self.ui_state.encoder_options.event_drop || source.get_video_ref().get_encoder_options().event_order - != self.ui_state.encoder_options.event_order) + != self.ui_state.encoder_options.event_order + || source.get_video_ref().state.params.pixel_multi_mode + != self.ui_state.integration_mode_radio_state) && self.ui_info_state.output_path.is_some()) { if self.ui_state.davis_mode_radio_state == RawDvs { @@ -880,6 +884,21 @@ fn side_panel_grid_contents( ui.add_enabled(enabled, egui::Checkbox::new(&mut ui_state.color, "Color?")); ui.end_row(); + ui.label("Integration mode:"); + ui.horizontal(|ui| { + ui.radio_value( + &mut ui_state.integration_mode_radio_state, + PixelMultiMode::Normal, + "Normal", + ); + ui.radio_value( + &mut ui_state.integration_mode_radio_state, + PixelMultiMode::Collapse, + "Collapse", + ); + }); + ui.end_row(); + ui.label("View mode:"); ui.vertical(|ui| { ui.horizontal(|ui| {