Skip to content

Commit

Permalink
Merge pull request #1081 from luxonis/stereo_filter_improvements
Browse files Browse the repository at this point in the history
Stereo filter improvements; do filtering in 13 bit range
  • Loading branch information
SzabolcsGergely authored Nov 8, 2024
2 parents 1740463 + 872b74c commit 78fd99b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
13 changes: 12 additions & 1 deletion src/pipeline/datatype/StereoDepthConfigBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void bind_stereodepthconfig(pybind11::module& m, void* pCallstack){
py::enum_<RawStereoDepthConfig::AlgorithmControl::DepthAlign> depthAlign(algorithmControl, "DepthAlign", DOC(dai, RawStereoDepthConfig, AlgorithmControl, DepthAlign));
py::enum_<RawStereoDepthConfig::AlgorithmControl::DepthUnit> depthUnit(algorithmControl, "DepthUnit", DOC(dai, RawStereoDepthConfig, AlgorithmControl, DepthUnit));
py::class_<RawStereoDepthConfig::PostProcessing> postProcessing(rawStereoDepthConfig, "PostProcessing", DOC(dai, RawStereoDepthConfig, PostProcessing));
py::enum_<RawStereoDepthConfig::PostProcessing::Filter> filter(postProcessing, "Filter", DOC(dai, RawStereoDepthConfig, PostProcessing, Filter));
py::class_<RawStereoDepthConfig::PostProcessing::SpatialFilter> spatialFilter(postProcessing, "SpatialFilter", DOC(dai, RawStereoDepthConfig, PostProcessing, SpatialFilter));
py::class_<RawStereoDepthConfig::PostProcessing::TemporalFilter> temporalFilter(postProcessing, "TemporalFilter", DOC(dai, RawStereoDepthConfig, PostProcessing, TemporalFilter));
py::enum_<RawStereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode> persistencyMode(temporalFilter, "PersistencyMode", DOC(dai, RawStereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode));
Expand Down Expand Up @@ -51,7 +52,15 @@ void bind_stereodepthconfig(pybind11::module& m, void* pCallstack){
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////

// Metadata / raw
filter
.value("DECIMATION", RawStereoDepthConfig::PostProcessing::Filter::DECIMATION, DOC(dai, RawStereoDepthConfig, PostProcessing, Filter, DECIMATION))
.value("SPECKLE", RawStereoDepthConfig::PostProcessing::Filter::SPECKLE, DOC(dai, RawStereoDepthConfig, PostProcessing, Filter, SPECKLE))
.value("MEDIAN", RawStereoDepthConfig::PostProcessing::Filter::MEDIAN, DOC(dai, RawStereoDepthConfig, PostProcessing, Filter, MEDIAN))
.value("TEMPORAL", RawStereoDepthConfig::PostProcessing::Filter::TEMPORAL, DOC(dai, RawStereoDepthConfig, PostProcessing, Filter, TEMPORAL))
.value("SPATIAL", RawStereoDepthConfig::PostProcessing::Filter::SPATIAL, DOC(dai, RawStereoDepthConfig, PostProcessing, Filter, SPATIAL))
.value("FILTER_COUNT", RawStereoDepthConfig::PostProcessing::Filter::FILTER_COUNT, DOC(dai, RawStereoDepthConfig, PostProcessing, Filter, FILTER_COUNT))
;

medianFilter
.value("MEDIAN_OFF", MedianFilter::MEDIAN_OFF)
.value("KERNEL_3x3", MedianFilter::KERNEL_3x3)
Expand Down Expand Up @@ -137,6 +146,7 @@ void bind_stereodepthconfig(pybind11::module& m, void* pCallstack){
.def(py::init<>())
.def_readwrite("enable", &RawStereoDepthConfig::PostProcessing::SpeckleFilter::enable, DOC(dai, RawStereoDepthConfig, PostProcessing, SpeckleFilter, enable))
.def_readwrite("speckleRange", &RawStereoDepthConfig::PostProcessing::SpeckleFilter::speckleRange, DOC(dai, RawStereoDepthConfig, PostProcessing, SpeckleFilter, speckleRange))
.def_readwrite("differenceThreshold", &RawStereoDepthConfig::PostProcessing::SpeckleFilter::differenceThreshold, DOC(dai, RawStereoDepthConfig, PostProcessing, SpeckleFilter, differenceThreshold))
;

decimationMode
Expand All @@ -153,6 +163,7 @@ void bind_stereodepthconfig(pybind11::module& m, void* pCallstack){

postProcessing
.def(py::init<>())
.def_readwrite("filteringOrder", &RawStereoDepthConfig::PostProcessing::filteringOrder, DOC(dai, RawStereoDepthConfig, PostProcessing, filteringOrder))
.def_readwrite("median", &RawStereoDepthConfig::PostProcessing::median, DOC(dai, RawStereoDepthConfig, PostProcessing, median))
.def_readwrite("bilateralSigmaValue", &RawStereoDepthConfig::PostProcessing::bilateralSigmaValue, DOC(dai, RawStereoDepthConfig, PostProcessing, bilateralSigmaValue))
.def_readwrite("spatialFilter", &RawStereoDepthConfig::PostProcessing::spatialFilter, DOC(dai, RawStereoDepthConfig, PostProcessing, spatialFilter))
Expand Down
23 changes: 21 additions & 2 deletions src/pipeline/node/StereoDepthBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,27 @@ void bind_stereodepth(pybind11::module& m, void* pCallstack){
;

stereoDepthPresetMode
.value("HIGH_ACCURACY", StereoDepth::PresetMode::HIGH_ACCURACY, DOC(dai, node, StereoDepth, PresetMode, HIGH_ACCURACY))
.value("HIGH_DENSITY", StereoDepth::PresetMode::HIGH_DENSITY, DOC(dai, node, StereoDepth, PresetMode, HIGH_DENSITY))
.value("HIGH_ACCURACY", StereoDepth::PresetMode::HIGH_ACCURACY, "**Deprecated:** Will be removed in future releases and replaced with DEFAULT")
.value("HIGH_DENSITY", StereoDepth::PresetMode::HIGH_DENSITY, "**Deprecated:** Will be removed in future releases and replaced with DEFAULT")

.value("DEFAULT", StereoDepth::PresetMode::DEFAULT)
.value("FACE", StereoDepth::PresetMode::FACE)
.value("HIGH_DETAIL", StereoDepth::PresetMode::HIGH_DETAIL)
.value("HIGH_FPS", StereoDepth::PresetMode::HIGH_FPS)
.value("HIGH_ACCURACY2", StereoDepth::PresetMode::HIGH_ACCURACY2)
.value("ROBOTICS", StereoDepth::PresetMode::ROBOTICS)

// Deprecated overriden
.def_property_readonly_static("HIGH_ACCURACY", [](py::object){
PyErr_WarnEx(PyExc_DeprecationWarning, "HIGH_ACCURACY is deprecated, will be removed in future releases and replaced with DEFAULT.", 1);
return StereoDepth::PresetMode::HIGH_ACCURACY;
})

.def_property_readonly_static("HIGH_DENSITY", [](py::object){
PyErr_WarnEx(PyExc_DeprecationWarning, "HIGH_DENSITY is deprecated, will be removed in future releases and replaced with DEFAULT.", 1);
return StereoDepth::PresetMode::HIGH_DENSITY;
})

;

// Node
Expand Down

0 comments on commit 78fd99b

Please sign in to comment.