From 64a7e31259925d934171bb1892a3ae9450b309ac Mon Sep 17 00:00:00 2001 From: lnotspotl Date: Tue, 25 Nov 2025 19:33:39 +0100 Subject: [PATCH 01/10] add neural depth post processing pipeline --- .../datatype/NeuralDepthConfigBindings.cpp | 10 +++++++++- .../pipeline/datatype/NeuralDepthConfig.hpp | 14 +++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/bindings/python/src/pipeline/datatype/NeuralDepthConfigBindings.cpp b/bindings/python/src/pipeline/datatype/NeuralDepthConfigBindings.cpp index f73d8f57ab..c27d792e8d 100644 --- a/bindings/python/src/pipeline/datatype/NeuralDepthConfigBindings.cpp +++ b/bindings/python/src/pipeline/datatype/NeuralDepthConfigBindings.cpp @@ -18,6 +18,7 @@ void bind_neuraldepthconfig(pybind11::module& m, void* pCallstack) { py::class_, Buffer, std::shared_ptr> neuralDepthConfig( m, "NeuralDepthConfig", DOC(dai, NeuralDepthConfig)); + py::class_ postProcessing(neuralDepthConfig, "PostProcessing", DOC(dai, NeuralDepthConfig, PostProcessing)); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// @@ -42,5 +43,12 @@ void bind_neuraldepthconfig(pybind11::module& m, void* pCallstack) { .def("setDepthUnit", &NeuralDepthConfig::setDepthUnit, DOC(dai, NeuralDepthConfig, setDepthUnit)) .def("getDepthUnit", &NeuralDepthConfig::getDepthUnit, DOC(dai, NeuralDepthConfig, getDepthUnit)) .def("setCustomDepthUnitMultiplier", &NeuralDepthConfig::setCustomDepthUnitMultiplier, DOC(dai, NeuralDepthConfig, setCustomDepthUnitMultiplier)) - .def("getCustomDepthUnitMultiplier", &NeuralDepthConfig::getCustomDepthUnitMultiplier, DOC(dai, NeuralDepthConfig, getCustomDepthUnitMultiplier)); + .def("getCustomDepthUnitMultiplier", &NeuralDepthConfig::getCustomDepthUnitMultiplier, DOC(dai, NeuralDepthConfig, getCustomDepthUnitMultiplier)) + .def_readwrite("postProcessing", &NeuralDepthConfig::postProcessing, DOC(dai, NeuralDepthConfig, postProcessing)); + + // PostProcessing + postProcessing.def(py::init<>()) + .def_readwrite("confidenceThreshold", &NeuralDepthConfig::PostProcessing::confidenceThreshold, DOC(dai, NeuralDepthConfig, PostProcessing, confidenceThreshold)) + .def_readwrite("edgeThreshold", &NeuralDepthConfig::PostProcessing::edgeThreshold, DOC(dai, NeuralDepthConfig, PostProcessing, edgeThreshold)) + .def_readwrite("temporalFilter", &NeuralDepthConfig::PostProcessing::temporalFilter, DOC(dai, NeuralDepthConfig, PostProcessing, temporalFilter)); } diff --git a/include/depthai/pipeline/datatype/NeuralDepthConfig.hpp b/include/depthai/pipeline/datatype/NeuralDepthConfig.hpp index 1f9e515d2d..64bae61336 100644 --- a/include/depthai/pipeline/datatype/NeuralDepthConfig.hpp +++ b/include/depthai/pipeline/datatype/NeuralDepthConfig.hpp @@ -4,6 +4,7 @@ #include #include +#include "depthai/pipeline/FilterParams.hpp" #include "depthai/pipeline/datatype/Buffer.hpp" namespace dai { @@ -36,7 +37,7 @@ class NeuralDepthConfig : public Buffer { DEPTHAI_SERIALIZE(AlgorithmControl, depthUnit, customDepthUnitMultiplier); }; - struct Filtering { + struct PostProcessing { /** * Confidence threshold for disparity calculation, * Confidences above this value will be considered valid. @@ -51,7 +52,14 @@ class NeuralDepthConfig : public Buffer { */ uint8_t edgeThreshold = 10; - DEPTHAI_SERIALIZE(Filtering, confidenceThreshold, edgeThreshold); + using TemporalFilter = filters::params::TemporalFilter; + + /** + * Temporal filtering with optional persistence. + */ + TemporalFilter temporalFilter; + + DEPTHAI_SERIALIZE(PostProcessing, confidenceThreshold, edgeThreshold, temporalFilter); }; /** @@ -104,7 +112,7 @@ class NeuralDepthConfig : public Buffer { /** * Controls the postprocessing of disparity and/or depth map. */ - Filtering postProcessing; + PostProcessing postProcessing; void serialize(std::vector& metadata, DatatypeEnum& datatype) const override; DEPTHAI_SERIALIZE(NeuralDepthConfig, algorithmControl, postProcessing); From 35a35d9bf20382fbe046121738d7cf1900396ab1 Mon Sep 17 00:00:00 2001 From: lnotspotl Date: Sat, 29 Nov 2025 14:32:36 +0100 Subject: [PATCH 02/10] Update NeuralDepth examples to reflect the addition of a new temporal filter --- .../src/pipeline/datatype/NeuralDepthConfigBindings.cpp | 3 ++- examples/cpp/NeuralDepth/neural_depth.cpp | 6 ++++++ examples/python/NeuralDepth/neural_depth.py | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bindings/python/src/pipeline/datatype/NeuralDepthConfigBindings.cpp b/bindings/python/src/pipeline/datatype/NeuralDepthConfigBindings.cpp index c27d792e8d..2e92c0a67d 100644 --- a/bindings/python/src/pipeline/datatype/NeuralDepthConfigBindings.cpp +++ b/bindings/python/src/pipeline/datatype/NeuralDepthConfigBindings.cpp @@ -48,7 +48,8 @@ void bind_neuraldepthconfig(pybind11::module& m, void* pCallstack) { // PostProcessing postProcessing.def(py::init<>()) - .def_readwrite("confidenceThreshold", &NeuralDepthConfig::PostProcessing::confidenceThreshold, DOC(dai, NeuralDepthConfig, PostProcessing, confidenceThreshold)) + .def_readwrite( + "confidenceThreshold", &NeuralDepthConfig::PostProcessing::confidenceThreshold, DOC(dai, NeuralDepthConfig, PostProcessing, confidenceThreshold)) .def_readwrite("edgeThreshold", &NeuralDepthConfig::PostProcessing::edgeThreshold, DOC(dai, NeuralDepthConfig, PostProcessing, edgeThreshold)) .def_readwrite("temporalFilter", &NeuralDepthConfig::PostProcessing::temporalFilter, DOC(dai, NeuralDepthConfig, PostProcessing, temporalFilter)); } diff --git a/examples/cpp/NeuralDepth/neural_depth.cpp b/examples/cpp/NeuralDepth/neural_depth.cpp index 96535441cd..4d8bc12650 100644 --- a/examples/cpp/NeuralDepth/neural_depth.cpp +++ b/examples/cpp/NeuralDepth/neural_depth.cpp @@ -66,6 +66,7 @@ int main() { std::cout << " - 's': Decrease confidence threshold" << std::endl; std::cout << " - 'd': Increase edge threshold" << std::endl; std::cout << " - 'a': Decrease edge threshold" << std::endl; + std::cout << " - 't': Toggle temporal filtering" << std::endl; while(!quitEvent && pipeline.isRunning()) { // Get confidence data and display it @@ -122,6 +123,11 @@ int main() { currentConfig->setEdgeThreshold(currentThreshold - 1); // uint8_t will wrap around on underflow std::cout << "Setting edge threshold to: " << (int)currentConfig->getEdgeThreshold() << std::endl; configChanged = true; + } else if(key == 't') { + bool enable = !currentConfig->postProcessing.temporalFilter.enable; + currentConfig->postProcessing.temporalFilter.enable = enable; + std::cout << "Temporal filtering: " << (enable ? "on" : "off") << std::endl; + configChanged = true; } // Send the updated configuration to the device diff --git a/examples/python/NeuralDepth/neural_depth.py b/examples/python/NeuralDepth/neural_depth.py index 7906e3f4d3..e1c29cb91f 100644 --- a/examples/python/NeuralDepth/neural_depth.py +++ b/examples/python/NeuralDepth/neural_depth.py @@ -30,6 +30,7 @@ print(" - 's': Decrease confidence threshold") print(" - 'd': Increase edge threshold") print(" - 'a': Decrease edge threshold") + print(" - 't': Toggle temporal filtering") while pipeline.isRunning(): confidenceData = confidenceQueue.get() assert isinstance(confidenceData, dai.ImgFrame) @@ -75,6 +76,10 @@ currentConfig.setEdgeThreshold((currentThreshold - 1) % 255) print("Setting edge threshold to:", currentConfig.getEdgeThreshold()) inputConfigQueue.send(currentConfig) + if key == ord('t'): + currentConfig.postProcessing.temporalFilter.enable = not currentConfig.postProcessing.temporalFilter.enable + print("Temporal filtering:", "on" if currentConfig.postProcessing.temporalFilter.enable else "off") + inputConfigQueue.send(currentConfig) if cv2.waitKey(1) == ord('q'): break From fe7bf1d532b8551fbf3391a2684cdc5ed138890c Mon Sep 17 00:00:00 2001 From: lnotspotl Date: Tue, 2 Dec 2025 19:20:24 +0100 Subject: [PATCH 03/10] enable dynamic calibration for the Rectification node --- src/pipeline/node/Rectification.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pipeline/node/Rectification.cpp b/src/pipeline/node/Rectification.cpp index 514a460228..c31d22e779 100644 --- a/src/pipeline/node/Rectification.cpp +++ b/src/pipeline/node/Rectification.cpp @@ -101,17 +101,13 @@ CalibrationHandler Rectification::getCalibrationData() const { void Rectification::run() { auto& logger = pimpl->logger; using namespace std::chrono; - if(runOnHost()) { - auto device = getParentPipeline().getDefaultDevice(); - if(device && device->getPlatform() != Platform::RVC4) { - throw std::runtime_error("Rectification node is only supported on RVC4 platform"); - } - } bool initialized = false; cv::Mat cv_rectificationMap1X, cv_rectificationMap1Y; cv::Mat cv_rectificationMap2X, cv_rectificationMap2Y; + uint32_t latestEepromId = getParentPipeline().getEepromId(); + cv::Mat cv_targetCameraMatrix1, cv_targetCameraMatrix2; std::array, 3> targetM1, targetM2; dai::ImgTransformation output1ImgTransformation; @@ -136,6 +132,13 @@ void Rectification::run() { output2FrameHeight = input2Frame->getHeight(); } + // If the EEPROM identifier has changed, we need to re-initialize the rectification matrices + uint32_t currentEepromId = getParentPipeline().getEepromId(); + if(latestEepromId != currentEepromId) { + latestEepromId = currentEepromId; + initialized = false; + } + if(!initialized) { output1ImgTransformation = input1Frame->transformation; output2ImgTransformation = input2Frame->transformation; @@ -218,6 +221,8 @@ void Rectification::run() { logger->debug("TARGET_MATRIX1 = {}", matToString(cv_targetCameraMatrix1)); logger->debug("TARGET_MATRIX2 = {}", matToString(cv_targetCameraMatrix2)); + logger->warn("Rectification matrices initialized"); + initialized = true; } From 2e2f7f96ec206914ff3b91e099b90d6023bec376 Mon Sep 17 00:00:00 2001 From: lnotspotl Date: Tue, 2 Dec 2025 21:06:04 +0100 Subject: [PATCH 04/10] remove unused includes --- include/depthai/pipeline/node/ToF.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/depthai/pipeline/node/ToF.hpp b/include/depthai/pipeline/node/ToF.hpp index 2549d22566..1d779fd748 100644 --- a/include/depthai/pipeline/node/ToF.hpp +++ b/include/depthai/pipeline/node/ToF.hpp @@ -5,9 +5,6 @@ #include #include -// standard -#include - // shared #include From 3a8781148495a9831a05408336579792dee1d3e4 Mon Sep 17 00:00:00 2001 From: lnotspotl Date: Mon, 8 Dec 2025 23:52:19 +0100 Subject: [PATCH 05/10] remove debug warning --- src/pipeline/node/Rectification.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pipeline/node/Rectification.cpp b/src/pipeline/node/Rectification.cpp index c31d22e779..33db6a0b49 100644 --- a/src/pipeline/node/Rectification.cpp +++ b/src/pipeline/node/Rectification.cpp @@ -221,8 +221,6 @@ void Rectification::run() { logger->debug("TARGET_MATRIX1 = {}", matToString(cv_targetCameraMatrix1)); logger->debug("TARGET_MATRIX2 = {}", matToString(cv_targetCameraMatrix2)); - logger->warn("Rectification matrices initialized"); - initialized = true; } From 462bbfc69123de84f0c31f794d069180738f1b29 Mon Sep 17 00:00:00 2001 From: lnotspotl Date: Mon, 8 Dec 2025 23:58:01 +0100 Subject: [PATCH 06/10] bump rvc4 firmware hash --- cmake/Depthai/DepthaiDeviceRVC4Config.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Depthai/DepthaiDeviceRVC4Config.cmake b/cmake/Depthai/DepthaiDeviceRVC4Config.cmake index 799751d88e..c2980834e4 100644 --- a/cmake/Depthai/DepthaiDeviceRVC4Config.cmake +++ b/cmake/Depthai/DepthaiDeviceRVC4Config.cmake @@ -3,4 +3,4 @@ set(DEPTHAI_DEVICE_RVC4_MATURITY "snapshot") # "version if applicable" -set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+1b73e246ec52429322213dc932bd2e2d81539a66") +set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+b2ed47d59c2eb53b963ea88f0a75e60671488058") From 6fb1337df4cc47f0e878ad1b4a4025dd75aea46c Mon Sep 17 00:00:00 2001 From: lnotspotl Date: Sun, 14 Dec 2025 23:03:10 +0100 Subject: [PATCH 07/10] bump rvc4 fw hash --- cmake/Depthai/DepthaiDeviceRVC4Config.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Depthai/DepthaiDeviceRVC4Config.cmake b/cmake/Depthai/DepthaiDeviceRVC4Config.cmake index d3e05d7c61..ac35088692 100644 --- a/cmake/Depthai/DepthaiDeviceRVC4Config.cmake +++ b/cmake/Depthai/DepthaiDeviceRVC4Config.cmake @@ -3,4 +3,4 @@ set(DEPTHAI_DEVICE_RVC4_MATURITY "snapshot") # "version if applicable" -set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+b57ee6baaa7a488b185c0264a59f4477853c3c28") +set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+a4c929d0ea38e0988cd3197ef1a8c8f84e1cf472") From 9fea48d6de3f886f1a0ecda0174029a018027ccf Mon Sep 17 00:00:00 2001 From: lnotspotl Date: Mon, 5 Jan 2026 09:45:46 +0100 Subject: [PATCH 08/10] bump rvc4 fw hash --- cmake/Depthai/DepthaiDeviceRVC4Config.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Depthai/DepthaiDeviceRVC4Config.cmake b/cmake/Depthai/DepthaiDeviceRVC4Config.cmake index 2b9914d06f..71d1db029b 100644 --- a/cmake/Depthai/DepthaiDeviceRVC4Config.cmake +++ b/cmake/Depthai/DepthaiDeviceRVC4Config.cmake @@ -3,4 +3,4 @@ set(DEPTHAI_DEVICE_RVC4_MATURITY "snapshot") # "version if applicable" -set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+188af4f128888e9b5585b727625626a76e4096ea") +set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+84ab2a2fd22a1be83462f5e5651695ee95a9f763") From e2f2fade80db5ae1103c24ce364c3b3c6ffb3a64 Mon Sep 17 00:00:00 2001 From: lnotspotl Date: Mon, 2 Mar 2026 22:58:08 +0100 Subject: [PATCH 09/10] bump rvc4 commit hash --- cmake/Depthai/DepthaiDeviceRVC4Config.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Depthai/DepthaiDeviceRVC4Config.cmake b/cmake/Depthai/DepthaiDeviceRVC4Config.cmake index 695a5c487d..5d141f333d 100644 --- a/cmake/Depthai/DepthaiDeviceRVC4Config.cmake +++ b/cmake/Depthai/DepthaiDeviceRVC4Config.cmake @@ -3,4 +3,4 @@ set(DEPTHAI_DEVICE_RVC4_MATURITY "snapshot") # "version if applicable" -set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+619c87a0023757020150faf07ccbddb13af24533") +set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+1f1257211c64e4cb6476808f577954a34ebe75ee") From eb9180bd59bbcea09a699c86287fd5477de1cdbe Mon Sep 17 00:00:00 2001 From: lnotspotl Date: Mon, 2 Mar 2026 23:18:27 +0100 Subject: [PATCH 10/10] bump rvc4 commit hash --- cmake/Depthai/DepthaiDeviceRVC4Config.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Depthai/DepthaiDeviceRVC4Config.cmake b/cmake/Depthai/DepthaiDeviceRVC4Config.cmake index 5d141f333d..e47d0aefdc 100644 --- a/cmake/Depthai/DepthaiDeviceRVC4Config.cmake +++ b/cmake/Depthai/DepthaiDeviceRVC4Config.cmake @@ -3,4 +3,4 @@ set(DEPTHAI_DEVICE_RVC4_MATURITY "snapshot") # "version if applicable" -set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+1f1257211c64e4cb6476808f577954a34ebe75ee") +set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+3a19ee3e8dc838e417fa752567c282d92145d2dd")