From c78c2d3938424aa8a2e5d60e1d0952fb23027519 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 3 Jul 2025 11:19:13 +0000 Subject: [PATCH 1/9] Vpp node added --- CMakeLists.txt | 2 + bindings/python/CMakeLists.txt | 5 +- bindings/python/generate_stubs.py | 10 +- bindings/python/src/DatatypeBindings.cpp | 3 + .../python/src/pipeline/PipelineBindings.cpp | 1 + .../pipeline/datatype/VppConfigBindings.cpp | 66 +++++ .../python/src/pipeline/node/NodeBindings.cpp | 2 + .../python/src/pipeline/node/VppBindings.cpp | 50 ++++ cmake/Depthai/DepthaiDeviceRVC4Config.cmake | 2 +- .../depthai/pipeline/datatype/ADatatype.hpp | 2 +- .../pipeline/datatype/DatatypeEnum.hpp | 1 + .../depthai/pipeline/datatype/VppConfig.hpp | 57 ++++ include/depthai/pipeline/datatypes.hpp | 1 + include/depthai/pipeline/node/Vpp.hpp | 67 +++++ include/depthai/pipeline/nodes.hpp | 1 + include/depthai/properties/VppProperties.hpp | 28 ++ src/pipeline/datatype/DatatypeEnum.cpp | 5 + src/pipeline/datatype/StreamMessageParser.cpp | 5 + src/pipeline/datatype/VppConfig.cpp | 5 + src/pipeline/node/Vpp.cpp | 33 +++ src/pipeline/node/host/Replay.cpp | 2 + src/properties/Properties.cpp | 4 +- src/utility/ProtoSerialize.cpp | 1 + tests/CMakeLists.txt | 4 + tests/src/ondevice_tests/vpp_test.cpp | 252 ++++++++++++++++++ 25 files changed, 599 insertions(+), 10 deletions(-) create mode 100644 bindings/python/src/pipeline/datatype/VppConfigBindings.cpp create mode 100644 bindings/python/src/pipeline/node/VppBindings.cpp create mode 100644 include/depthai/pipeline/datatype/VppConfig.hpp create mode 100644 include/depthai/pipeline/node/Vpp.hpp create mode 100644 include/depthai/properties/VppProperties.hpp create mode 100644 src/pipeline/datatype/VppConfig.cpp create mode 100644 src/pipeline/node/Vpp.cpp create mode 100644 tests/src/ondevice_tests/vpp_test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index cbe164a093..3248a801db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -319,6 +319,7 @@ set(TARGET_CORE_SOURCES src/pipeline/node/internal/XLinkOutHost.cpp src/pipeline/node/host/HostNode.cpp src/pipeline/node/host/RGBD.cpp + src/pipeline/node/Vpp.cpp src/pipeline/datatype/DatatypeEnum.cpp src/pipeline/datatype/ADataType.cpp src/pipeline/node/PointCloud.cpp @@ -362,6 +363,7 @@ set(TARGET_CORE_SOURCES src/pipeline/datatype/TransformData.cpp src/properties/Properties.cpp src/capabilities/Capabilities.cpp + src/pipeline/datatype/VppConfig.cpp src/utility/H26xParsers.cpp src/utility/ImageManipImpl.cpp src/utility/ObjectTrackerImpl.cpp diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index b0b01eed73..7b02a52671 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -109,7 +109,7 @@ set(SOURCE_LIST src/pipeline/node/RectificationBindings.cpp src/pipeline/node/NeuralDepthBindings.cpp src/pipeline/FilterParamsBindings.cpp - + src/pipeline/node/VppBindings.cpp src/pipeline/datatype/ADatatypeBindings.cpp src/pipeline/datatype/AprilTagConfigBindings.cpp src/pipeline/datatype/AprilTagsBindings.cpp @@ -142,6 +142,7 @@ set(SOURCE_LIST src/pipeline/datatype/TransformDataBindings.cpp src/pipeline/datatype/ImageAlignConfigBindings.cpp src/pipeline/datatype/ImgAnnotationsBindings.cpp + src/pipeline/datatype/VppConfigBindings.cpp src/remote_connection/RemoteConnectionBindings.cpp src/capabilities/CapabilityBindings.cpp @@ -415,4 +416,4 @@ endif() ######################## if (DEPTHAI_PYTHON_ENABLE_EXAMPLES) add_subdirectory(../../examples/python ${CMAKE_BINARY_DIR}/examples/python) -endif() \ No newline at end of file +endif() diff --git a/bindings/python/generate_stubs.py b/bindings/python/generate_stubs.py index c703eff716..e5da8c2910 100644 --- a/bindings/python/generate_stubs.py +++ b/bindings/python/generate_stubs.py @@ -60,7 +60,7 @@ open(f'{DIRECTORY}/depthai/py.typed', 'a').close() # imports and overloads - with open(f'{DIRECTORY}/depthai/__init__.pyi' ,'r+') as file: + with open(f'{DIRECTORY}/depthai/__init__.pyi' ,'r+', encoding='utf-8') as file: # Read contents = file.read() @@ -106,7 +106,7 @@ file.write(final_stubs) # node fixes - with open(f'{DIRECTORY}/depthai/node/__init__.pyi' ,'r+') as file: + with open(f'{DIRECTORY}/depthai/node/__init__.pyi', 'r+', encoding='utf-8') as file: # Read contents = file.read() @@ -138,7 +138,7 @@ # Windows limitation - another process cannot normally read temporary file that is opened by this process # Close first and delete manually afterwards try: - config = tempfile.NamedTemporaryFile(mode='w', delete=False) + config = tempfile.NamedTemporaryFile(mode='w', delete=False, encoding='utf-8') config.write('[mypy]\nignore_errors = True\n') config.close() print(f'Mypy config file: {config.name}') @@ -151,7 +151,7 @@ def process_init_pyi(file_path, is_depthai_root=False): # Read old __init__.pyi - with open(file_path, 'r+') as file: + with open(file_path, 'r+', encoding='utf-8') as file: contents = file.read() # Prepare imports @@ -172,7 +172,7 @@ def process_init_pyi(file_path, is_depthai_root=False): new_contents = imports + '\n' + contents # Writeout changes - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding='utf-8') as file: file.write(new_contents) # Process all __init__.pyi files diff --git a/bindings/python/src/DatatypeBindings.cpp b/bindings/python/src/DatatypeBindings.cpp index d5c92c840f..9e126601ff 100644 --- a/bindings/python/src/DatatypeBindings.cpp +++ b/bindings/python/src/DatatypeBindings.cpp @@ -39,6 +39,7 @@ void bind_imageannotations(pybind11::module& m, void* pCallstack); void bind_dynamic_calibration_results(pybind11::module& m, void* pCallstack); void bind_dynamic_calibration_control(pybind11::module& m, void* pCallstack); #endif // DEPTHAI_HAVE_DYNAMIC_CALIBRATION_SUPPORT +void bind_vppconfig(pybind11::module& m, void* pCallstack); void DatatypeBindings::addToCallstack(std::deque& callstack) { // Bind common datatypebindings @@ -77,6 +78,7 @@ void DatatypeBindings::addToCallstack(std::deque& callstack) { callstack.push_front(bind_imagealignconfig); callstack.push_front(bind_imageannotations); callstack.push_front(bind_rgbddata); + callstack.push_front(bind_vppconfig); #ifdef DEPTHAI_HAVE_DYNAMIC_CALIBRATION_SUPPORT callstack.push_front(bind_dynamic_calibration_results); callstack.push_front(bind_dynamic_calibration_control); @@ -125,6 +127,7 @@ void DatatypeBindings::bind(pybind11::module& m, void* pCallstack) { .value("FeatureTrackerConfig", DatatypeEnum::FeatureTrackerConfig) .value("ThermalConfig", DatatypeEnum::ThermalConfig) .value("ToFConfig", DatatypeEnum::ToFConfig) + .value("VppConfig", DatatypeEnum::VppConfig) .value("TrackedFeatures", DatatypeEnum::TrackedFeatures) .value("BenchmarkReport", DatatypeEnum::BenchmarkReport) .value("MessageGroup", DatatypeEnum::MessageGroup) diff --git a/bindings/python/src/pipeline/PipelineBindings.cpp b/bindings/python/src/pipeline/PipelineBindings.cpp index 5652ce0f18..8adc9c011a 100644 --- a/bindings/python/src/pipeline/PipelineBindings.cpp +++ b/bindings/python/src/pipeline/PipelineBindings.cpp @@ -40,6 +40,7 @@ #include "depthai/pipeline/node/Warp.hpp" #include "depthai/pipeline/node/internal/XLinkIn.hpp" #include "depthai/pipeline/node/internal/XLinkOut.hpp" +#include "depthai/pipeline/node/Vpp.hpp" // depthai/ #include diff --git a/bindings/python/src/pipeline/datatype/VppConfigBindings.cpp b/bindings/python/src/pipeline/datatype/VppConfigBindings.cpp new file mode 100644 index 0000000000..b0efde5598 --- /dev/null +++ b/bindings/python/src/pipeline/datatype/VppConfigBindings.cpp @@ -0,0 +1,66 @@ +#include +#include + +#include "DatatypeBindings.hpp" +#include "pipeline/CommonBindings.hpp" + +// depthai +#include "depthai/pipeline/datatype/VppConfig.hpp" + +// pybind +#include +#include + +void bind_vppconfig(pybind11::module& m, void* pCallstack) { + using namespace dai; + using namespace pybind11::literals; + + // --------------------------------------------------------------------- + // ENUM: PatchColoringType + // --------------------------------------------------------------------- + py::enum_(m, "VppPatchColoringType", DOC(dai, VppConfig, PatchColoringType)) + .value("RANDOM", VppConfig::PatchColoringType::RANDOM, "Random patch coloring") + .value("MAXDIST", VppConfig::PatchColoringType::MAXDIST, "Color with most distant color"); + + // --------------------------------------------------------------------- + // STRUCT: InjectionParameters + // --------------------------------------------------------------------- + py::class_(m, "VppInjectionParameters", DOC(dai, VppConfig, InjectionParameters)) + .def(py::init<>()) + .def_readwrite("useInjection", &VppConfig::InjectionParameters::useInjection, DOC(dai, VppConfig, InjectionParameters, useInjection)) + .def_readwrite("kernelSize", &VppConfig::InjectionParameters::kernelSize, DOC(dai, VppConfig, InjectionParameters, kernelSize)) + .def_readwrite("textureThreshold", &VppConfig::InjectionParameters::textureThreshold, DOC(dai, VppConfig, InjectionParameters, textureThreshold)) + .def_readwrite( + "confidenceThreshold", &VppConfig::InjectionParameters::confidenceThreshold, DOC(dai, VppConfig, InjectionParameters, confidenceThreshold)) + .def_readwrite( + "morphologyIterations", &VppConfig::InjectionParameters::morphologyIterations, DOC(dai, VppConfig, InjectionParameters, morphologyIterations)) + .def_readwrite("useMorphology", &VppConfig::InjectionParameters::useMorphology, DOC(dai, VppConfig, InjectionParameters, useMorphology)) + .def("__repr__", [](const VppConfig::InjectionParameters& p) { + return ""; + }); + + // --------------------------------------------------------------------- + // CLASS: VppConfig + // --------------------------------------------------------------------- + py::class_, Buffer, std::shared_ptr> vppConfig(m, "VppConfig", DOC(dai, VppConfig)); + + // Bindings setup continuation (DepthAI callstack pattern) + Callstack* callstack = (Callstack*)pCallstack; + auto cb = callstack->top(); + callstack->pop(); + cb(m, pCallstack); + + // --------------------------------------------------------------------- + // Actual bindings + // --------------------------------------------------------------------- + vppConfig.def(py::init<>()) + .def("__repr__", &VppConfig::str) + .def_readwrite("blending", &VppConfig::blending, DOC(dai, VppConfig, blending)) + .def_readwrite("distanceGamma", &VppConfig::distanceGamma, DOC(dai, VppConfig, distanceGamma)) + .def_readwrite("maxPatchSize", &VppConfig::maxPatchSize, DOC(dai, VppConfig, maxPatchSize)) + .def_readwrite("patchColoringType", &VppConfig::patchColoringType, DOC(dai, VppConfig, patchColoringType)) + .def_readwrite("uniformPatch", &VppConfig::uniformPatch, DOC(dai, VppConfig, uniformPatch)) + .def_readwrite("injectionParameters", &VppConfig::injectionParameters, DOC(dai, VppConfig, injectionParameters)); +} diff --git a/bindings/python/src/pipeline/node/NodeBindings.cpp b/bindings/python/src/pipeline/node/NodeBindings.cpp index 0f1f67190a..c8187ab008 100644 --- a/bindings/python/src/pipeline/node/NodeBindings.cpp +++ b/bindings/python/src/pipeline/node/NodeBindings.cpp @@ -163,6 +163,7 @@ void bind_imagealign(pybind11::module& m, void* pCallstack); void bind_rgbd(pybind11::module& m, void* pCallstack); void bind_rectification(pybind11::module& m, void* pCallstack); void bind_neuraldepth(pybind11::module& m, void* pCallstack); +void bind_vpp(pybind11::module& m, void* pCallstack); #ifdef DEPTHAI_HAVE_BASALT_SUPPORT void bind_basaltnode(pybind11::module& m, void* pCallstack); #endif @@ -214,6 +215,7 @@ void NodeBindings::addToCallstack(std::deque& callstack) { callstack.push_front(bind_rgbd); callstack.push_front(bind_rectification); callstack.push_front(bind_neuraldepth); + callstack.push_front(bind_vpp); #ifdef DEPTHAI_HAVE_BASALT_SUPPORT callstack.push_front(bind_basaltnode); #endif diff --git a/bindings/python/src/pipeline/node/VppBindings.cpp b/bindings/python/src/pipeline/node/VppBindings.cpp new file mode 100644 index 0000000000..32a9a0e193 --- /dev/null +++ b/bindings/python/src/pipeline/node/VppBindings.cpp @@ -0,0 +1,50 @@ +#include "Common.hpp" +#include "NodeBindings.hpp" +#include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" +#include "depthai/pipeline/node/Vpp.hpp" + +void bind_vpp(pybind11::module& m, void* pCallstack) { + using namespace dai; + using namespace dai::node; + using namespace pybind11::literals; + + // Node and Properties declare upfront (no duplicate VppConfig or VppMethod bindings) + py::class_ vppProperties(m, "VppProperties", DOC(dai, VppProperties)); + auto vpp = ADD_NODE(Vpp); + + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + // Call the rest of the type defines, then perform the actual bindings + Callstack* callstack = (Callstack*)pCallstack; + auto cb = callstack->top(); + callstack->pop(); + cb(m, pCallstack); + // Actual bindings + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + + // Properties + vppProperties.def_readwrite("initialConfig", &VppProperties::initialConfig, DOC(dai, VppProperties, initialConfig)) + .def_readwrite("numFramesPool", &VppProperties::numFramesPool, DOC(dai, VppProperties, numFramesPool)); + + // Node + vpp.def_readonly("inputConfig", &Vpp::inputConfig, DOC(dai, node, Vpp, inputConfig)) + .def_property_readonly( + "left", [](Vpp& node) { return node.left; }, py::return_value_policy::reference_internal) + .def_property_readonly( + "right", [](Vpp& node) { return node.right; }, py::return_value_policy::reference_internal) + .def_property_readonly( + "disparity", [](Vpp& node) { return node.disparity; }, py::return_value_policy::reference_internal) + .def_property_readonly( + "confidence", [](Vpp& node) { return node.confidence; }, py::return_value_policy::reference_internal) + .def_readonly("syncedInputs", &Vpp::syncedInputs, DOC(dai, node, Vpp, syncedInputs)) + .def_readonly("leftOut", &Vpp::leftOut, DOC(dai, node, Vpp, leftOut)) + .def_readonly("rightOut", &Vpp::rightOut, DOC(dai, node, Vpp, rightOut)) + .def_readonly("initialConfig", &Vpp::initialConfig, DOC(dai, node, Vpp, initialConfig)); + + // ALIAS + daiNodeModule.attr("Vpp").attr("Properties") = vppProperties; +} diff --git a/cmake/Depthai/DepthaiDeviceRVC4Config.cmake b/cmake/Depthai/DepthaiDeviceRVC4Config.cmake index 78b734802d..943aa9cebf 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+098f664d24dc72bce0589a9f81f18ceb285b0f8f") +set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+557d00a27535a643ba4d75bc0e0ef5d1db87e610") diff --git a/include/depthai/pipeline/datatype/ADatatype.hpp b/include/depthai/pipeline/datatype/ADatatype.hpp index 4b00e2c4cd..9e53adef9b 100644 --- a/include/depthai/pipeline/datatype/ADatatype.hpp +++ b/include/depthai/pipeline/datatype/ADatatype.hpp @@ -36,4 +36,4 @@ class ADatatype { std::shared_ptr data; }; -} // namespace dai +} // namespace dai \ No newline at end of file diff --git a/include/depthai/pipeline/datatype/DatatypeEnum.hpp b/include/depthai/pipeline/datatype/DatatypeEnum.hpp index 949d7bd631..f849003133 100644 --- a/include/depthai/pipeline/datatype/DatatypeEnum.hpp +++ b/include/depthai/pipeline/datatype/DatatypeEnum.hpp @@ -44,6 +44,7 @@ enum class DatatypeEnum : std::int32_t { DynamicCalibrationResult, CalibrationQuality, CoverageData, + VppConfig }; bool isDatatypeSubclassOf(DatatypeEnum parent, DatatypeEnum children); diff --git a/include/depthai/pipeline/datatype/VppConfig.hpp b/include/depthai/pipeline/datatype/VppConfig.hpp new file mode 100644 index 0000000000..414b136313 --- /dev/null +++ b/include/depthai/pipeline/datatype/VppConfig.hpp @@ -0,0 +1,57 @@ +#pragma once +#include "depthai/pipeline/datatype/Buffer.hpp" +#include "depthai/utility/Serialization.hpp" + +namespace dai { + +/** + * VppConfig message. Carries config for Virtual Projection Pattern algorithm + */ +class VppConfig : public Buffer { + public: + enum PatchColoringType : int { + RANDOM = 0, + MAXDIST = 1 // color the patch with the most distant color + }; + + struct InjectionParameters { + bool useInjection = true; + int kernelSize = 3; + float textureThreshold = 0.5; + float confidenceThreshold = 0.5; + int morphologyIterations = 5; + bool useMorphology = true; + + // clang-format off + DEPTHAI_SERIALIZE( + InjectionParameters, + useInjection, + kernelSize, + textureThreshold, + confidenceThreshold, + morphologyIterations, + useMorphology); + // clang-format on + }; + + float blending = 0.5; + float distanceGamma = 0.3; + uint8_t maxPatchSize = 3; + PatchColoringType patchColoringType = PatchColoringType::RANDOM; + bool uniformPatch = true; + InjectionParameters injectionParameters; + int maxNumThreads = 8; + int maxFPS = 0; + + VppConfig() = default; + virtual ~VppConfig(); + + void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { + metadata = utility::serialize(*this); + datatype = DatatypeEnum::VppConfig; + }; + + DEPTHAI_SERIALIZE(VppConfig, blending, distanceGamma, maxPatchSize, patchColoringType, uniformPatch, injectionParameters, maxNumThreads, maxFPS); +}; + +} // namespace dai diff --git a/include/depthai/pipeline/datatypes.hpp b/include/depthai/pipeline/datatypes.hpp index 979f7ed77d..e8c40e1b81 100644 --- a/include/depthai/pipeline/datatypes.hpp +++ b/include/depthai/pipeline/datatypes.hpp @@ -37,3 +37,4 @@ #include "datatype/DynamicCalibrationControl.hpp" #include "datatype/DynamicCalibrationResults.hpp" #endif +#include "datatype/VppConfig.hpp" diff --git a/include/depthai/pipeline/node/Vpp.hpp b/include/depthai/pipeline/node/Vpp.hpp new file mode 100644 index 0000000000..99c5c11c80 --- /dev/null +++ b/include/depthai/pipeline/node/Vpp.hpp @@ -0,0 +1,67 @@ +#pragma once + +#include +#include + +// shared +#include "depthai/pipeline/Subnode.hpp" +#include "depthai/pipeline/datatype/VppConfig.hpp" +#include "depthai/pipeline/node/Sync.hpp" +#include "depthai/properties/VppProperties.hpp" + +namespace dai { +namespace node { + +/** + * @brief Vpp node. Apply Virtual Projection Pattern algorithm to stereo images based on disparity. + */ +class Vpp : public DeviceNodeCRTP { + protected: + Properties& getProperties() override; + + public: + constexpr static const char* NAME = "Vpp"; + + using DeviceNodeCRTP::DeviceNodeCRTP; + + Vpp(); + + Vpp(std::unique_ptr props); + + virtual ~Vpp(); + + void buildInternal() override; + + /** + * Initial config to use for VPP. + */ + std::shared_ptr initialConfig = std::make_shared(); + + Subnode sync{*this, "sync"}; + Input syncedInputs{*this, {"syncedInputs", DEFAULT_GROUP, false, 4, {{{DatatypeEnum::MessageGroup, false}}}, DEFAULT_WAIT_FOR_MESSAGE}}; + + const std::string leftInputName = "left"; + const std::string rightInputName = "right"; + const std::string disparityName = "disparity"; + const std::string confidenceName = "confidence"; + + Input* left; + Input* right; + Input* disparity; + Input* confidence; + + Input inputConfig{*this, {"inputConfig", DEFAULT_GROUP, false, 4, {{{DatatypeEnum::VppConfig, false}}}, DEFAULT_WAIT_FOR_MESSAGE}}; + + /** + * Output ImgFrame message that carries the processed left image with virtual projection pattern applied. + */ + Output leftOut{*this, {"leftOut", DEFAULT_GROUP, {{{DatatypeEnum::ImgFrame, false}}}}}; + + /** + * Output ImgFrame message that carries the processed right image with virtual projection pattern applied. + */ + Output rightOut{*this, {"rightOut", DEFAULT_GROUP, {{{DatatypeEnum::ImgFrame, false}}}}}; +}; + +} // namespace node +} // namespace dai diff --git a/include/depthai/pipeline/nodes.hpp b/include/depthai/pipeline/nodes.hpp index 466a71ac30..f82317850a 100644 --- a/include/depthai/pipeline/nodes.hpp +++ b/include/depthai/pipeline/nodes.hpp @@ -42,6 +42,7 @@ #include "node/host/HostNode.hpp" #include "node/host/Record.hpp" #include "node/host/Replay.hpp" + #include "node/Vpp.hpp" #endif #include "ThreadedHostNode.hpp" #include "node/ImageAlign.hpp" diff --git a/include/depthai/properties/VppProperties.hpp b/include/depthai/properties/VppProperties.hpp new file mode 100644 index 0000000000..64566a6fb4 --- /dev/null +++ b/include/depthai/properties/VppProperties.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include "depthai/pipeline/datatype/VppConfig.hpp" +#include "depthai/properties/Properties.hpp" +#include "depthai/utility/Serialization.hpp" + +namespace dai { + +/** + * Specify properties for Vpp node + */ +struct VppProperties : PropertiesSerializable { + /** + * Initial VPP configuration + */ + VppConfig initialConfig; + + /** + * Number of frames in pool for output frames + */ + int numFramesPool = 4; + + virtual ~VppProperties(); +}; + +DEPTHAI_SERIALIZE_EXT(VppProperties, initialConfig, numFramesPool); + +} // namespace dai diff --git a/src/pipeline/datatype/DatatypeEnum.cpp b/src/pipeline/datatype/DatatypeEnum.cpp index 5c116c77bc..4662367163 100644 --- a/src/pipeline/datatype/DatatypeEnum.cpp +++ b/src/pipeline/datatype/DatatypeEnum.cpp @@ -6,6 +6,8 @@ #include #include +#include "spdlog/spdlog.h" + namespace dai { const std::unordered_map> hierarchy = { @@ -42,6 +44,7 @@ const std::unordered_map> hierarchy = { DatatypeEnum::RGBDData, DatatypeEnum::TransformData, DatatypeEnum::ImgAnnotations, + DatatypeEnum::VppConfig, DatatypeEnum::ImageFiltersConfig, DatatypeEnum::ToFDepthConfidenceFilterConfig, DatatypeEnum::ObjectTrackerConfig, @@ -84,6 +87,7 @@ const std::unordered_map> hierarchy = { DatatypeEnum::TransformData, DatatypeEnum::ImgAnnotations, DatatypeEnum::ImageFiltersConfig, + DatatypeEnum::VppConfig, DatatypeEnum::ToFDepthConfidenceFilterConfig, DatatypeEnum::ObjectTrackerConfig, DatatypeEnum::DynamicCalibrationControl, @@ -121,6 +125,7 @@ const std::unordered_map> hierarchy = { {DatatypeEnum::RGBDData, {}}, {DatatypeEnum::TransformData, {}}, {DatatypeEnum::ImgAnnotations, {}}, + {DatatypeEnum::VppConfig, {}}, {DatatypeEnum::ImageFiltersConfig, {}}, {DatatypeEnum::ToFDepthConfidenceFilterConfig, {}}, {DatatypeEnum::ObjectTrackerConfig, {}}, diff --git a/src/pipeline/datatype/StreamMessageParser.cpp b/src/pipeline/datatype/StreamMessageParser.cpp index d32bf34269..b7169a157e 100644 --- a/src/pipeline/datatype/StreamMessageParser.cpp +++ b/src/pipeline/datatype/StreamMessageParser.cpp @@ -47,6 +47,7 @@ #include "depthai/pipeline/datatype/TrackedFeatures.hpp" #include "depthai/pipeline/datatype/Tracklets.hpp" #include "depthai/pipeline/datatype/TransformData.hpp" +#include "depthai/pipeline/datatype/VppConfig.hpp" // shared #include "depthai/pipeline/datatype/DatatypeEnum.hpp" #include "depthai/utility/Serialization.hpp" @@ -265,6 +266,10 @@ std::shared_ptr StreamMessageParser::parseMessage(streamPacketDesc_t* case DatatypeEnum::ObjectTrackerConfig: return parseDatatype(metadataStart, serializedObjectSize, data, fd); break; + case DatatypeEnum::VppConfig: { + return parseDatatype(metadataStart, serializedObjectSize, data, fd); + break; + } #ifdef DEPTHAI_HAVE_DYNAMIC_CALIBRATION_SUPPORT case DatatypeEnum::DynamicCalibrationControl: return parseDatatype(metadataStart, serializedObjectSize, data, fd); diff --git a/src/pipeline/datatype/VppConfig.cpp b/src/pipeline/datatype/VppConfig.cpp new file mode 100644 index 0000000000..4fa069481f --- /dev/null +++ b/src/pipeline/datatype/VppConfig.cpp @@ -0,0 +1,5 @@ +#include "depthai/pipeline/datatype/VppConfig.hpp" + +namespace dai { +VppConfig::~VppConfig() = default; +} // namespace dai diff --git a/src/pipeline/node/Vpp.cpp b/src/pipeline/node/Vpp.cpp new file mode 100644 index 0000000000..bf2c6b25b1 --- /dev/null +++ b/src/pipeline/node/Vpp.cpp @@ -0,0 +1,33 @@ +#include "depthai/pipeline/node/Vpp.hpp" + +#include "depthai/pipeline/datatype/VppConfig.hpp" +#include "utility/Logging.hpp" + +namespace dai { +namespace node { + +Vpp::~Vpp() = default; + +Vpp::Vpp(std::unique_ptr props) + : DeviceNodeCRTP(std::move(props)), + initialConfig(std::make_shared(properties.initialConfig)) {} + +Vpp::Vpp() + : DeviceNodeCRTP(std::make_unique()), + initialConfig(std::make_shared(properties.initialConfig)) {} + +Vpp::Properties& Vpp::getProperties() { + properties.initialConfig = *initialConfig; + return properties; +} + +void Vpp::buildInternal() { + left = &sync->inputs[leftInputName]; + right = &sync->inputs[rightInputName]; + disparity = &sync->inputs[disparityName]; + confidence = &sync->inputs[confidenceName]; + sync->out.link(syncedInputs); +} + +} // namespace node +} // namespace dai diff --git a/src/pipeline/node/host/Replay.cpp b/src/pipeline/node/host/Replay.cpp index f3d5400550..f82828433e 100644 --- a/src/pipeline/node/host/Replay.cpp +++ b/src/pipeline/node/host/Replay.cpp @@ -98,6 +98,7 @@ inline std::shared_ptr getMessage(const std::shared_ptr getProtoMessage(utility::ByteP case DatatypeEnum::CalibrationQuality: case DatatypeEnum::CoverageData: case DatatypeEnum::NeuralDepthConfig: + case DatatypeEnum::VppConfig: throw std::runtime_error("Cannot replay message type: " + std::to_string((int)datatype)); } return {}; diff --git a/src/properties/Properties.cpp b/src/properties/Properties.cpp index df09bfe7ce..7cf8d119f1 100644 --- a/src/properties/Properties.cpp +++ b/src/properties/Properties.cpp @@ -33,6 +33,7 @@ #include "depthai/properties/ToFProperties.hpp" #include "depthai/properties/UVCProperties.hpp" #include "depthai/properties/VideoEncoderProperties.hpp" +#include "depthai/properties/VppProperties.hpp" #include "depthai/properties/WarpProperties.hpp" #include "depthai/properties/internal/XLinkInProperties.hpp" #include "depthai/properties/internal/XLinkOutProperties.hpp" @@ -89,6 +90,7 @@ VideoEncoderProperties::~VideoEncoderProperties() = default; WarpProperties::~WarpProperties() = default; GlobalProperties::~GlobalProperties() = default; CastProperties::~CastProperties() = default; +VppProperties::~VppProperties() = default; // RVC2_FW does not need these properties #ifndef RVC2_FW @@ -102,4 +104,4 @@ DynamicCalibrationProperties::~DynamicCalibrationProperties() = default; #endif -} // namespace dai \ No newline at end of file +} // namespace dai diff --git a/src/utility/ProtoSerialize.cpp b/src/utility/ProtoSerialize.cpp index fe61843079..0b86c908a0 100644 --- a/src/utility/ProtoSerialize.cpp +++ b/src/utility/ProtoSerialize.cpp @@ -171,6 +171,7 @@ bool deserializationSupported(DatatypeEnum datatype) { case DatatypeEnum::ToFDepthConfidenceFilterConfig: case DatatypeEnum::RGBDData: case DatatypeEnum::ObjectTrackerConfig: + case DatatypeEnum::VppConfig: case DatatypeEnum::DynamicCalibrationControl: case DatatypeEnum::DynamicCalibrationResult: case DatatypeEnum::CalibrationQuality: diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8d3579ccf7..58039b239b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -455,6 +455,10 @@ target_compile_definitions(openvino_blob_test PRIVATE ) dai_set_test_labels(openvino_blob_test ondevice rvc2_all ci) +# Vpp node tests +dai_add_test(vpp_test src/ondevice_tests/vpp_test.cpp) +dai_set_test_labels(vpp_test ondevice rvc4 ci) + # Dynamic calibration tests dai_add_test(dynamic_calibration_test src/ondevice_tests/dynamic_calibration_test.cpp) dai_set_test_labels(dynamic_calibration_test ondevice rvc2_all ci) diff --git a/tests/src/ondevice_tests/vpp_test.cpp b/tests/src/ondevice_tests/vpp_test.cpp new file mode 100644 index 0000000000..4c27518988 --- /dev/null +++ b/tests/src/ondevice_tests/vpp_test.cpp @@ -0,0 +1,252 @@ +#include "depthai/pipeline/node/Vpp.hpp" + +#include +#include +#include + +#include "depthai/depthai.hpp" + +using namespace dai; + +std::shared_ptr openCvToFrame(const cv::Mat& mat, ImgFrame::Type type) { + auto frame = std::make_shared(); + frame->setType(type); + + // Set width and height + frame->setWidth(mat.cols); + frame->setHeight(mat.rows); + + // Determine number of bytes per pixel + size_t totalBytes = mat.total() * mat.elemSize(); + + // Copy data + if(mat.isContinuous()) { + frame->setData(std::vector(reinterpret_cast(mat.data), reinterpret_cast(mat.data) + totalBytes)); + } else { + std::vector data; + data.reserve(totalBytes); + for(int i = 0; i < mat.rows; ++i) { + const uint8_t* rowPtr = reinterpret_cast(mat.ptr(i)); + data.insert(data.end(), rowPtr, rowPtr + mat.cols * mat.elemSize()); + } + frame->setData(data); + } + + return frame; +} + +TEST_CASE("DepthAI VPP RAW8") { + // Connect to the device + auto device = std::make_shared(); + // Configure VPP + auto vppConfig = std::make_shared(); + vppConfig->maxPatchSize = 20; + vppConfig->patchColoringType = VppConfig::PatchColoringType::MAXDIST; + vppConfig->blending = 0.5f; + vppConfig->uniformPatch = true; + + // Modify nested injection parameters + vppConfig->injectionParameters.textureThreshold = 4.0; + vppConfig->injectionParameters.useInjection = true; + + // Build the pipeline + Pipeline pipeline; + auto vpp = pipeline.create(); + auto syncQueue = vpp->syncedInputs.createInputQueue(); + auto configQueue = vpp->inputConfig.createInputQueue(); + auto outLeftQueue = vpp->leftOut.createOutputQueue(); + auto outRightQueue = vpp->rightOut.createOutputQueue(); + + // Send config + configQueue->send(vppConfig); + + // Create fake disparity and confidence frames + cv::Mat disparity(16, 16, CV_16UC1, cv::Scalar(32)); + cv::Mat confidence(16, 16, CV_16UC1, cv::Scalar(0)); + + cv::Mat left(1280, 800, CV_8UC1, cv::Scalar(0)); + cv::Mat right(1280, 800, CV_8UC1, cv::Scalar(0)); + + auto leftFrame = std::make_shared(); + leftFrame->setCvFrame(left, ImgFrame::Type::RAW8); + + auto rightFrame = std::make_shared(); + rightFrame->setCvFrame(right, ImgFrame::Type::RAW8); + + auto disparityFrame = std::make_shared(); + disparityFrame->setCvFrame(disparity, ImgFrame::Type::RAW16); + + auto confidenceFrame = std::make_shared(); + confidenceFrame->setCvFrame(confidence, ImgFrame::Type::RAW16); + + pipeline.start(); + // Send message group + auto messageGroup = std::make_shared(); + messageGroup->add("left", leftFrame); + messageGroup->add("right", rightFrame); + messageGroup->add("disparity", disparityFrame); + messageGroup->add("confidence", confidenceFrame); + syncQueue->send(messageGroup); + + // Try to read outputs + auto leftOut = outLeftQueue->get(); + auto rightOut = outRightQueue->get(); + + bool gotOutput = (leftOut && rightOut); + + REQUIRE(gotOutput); // ✅ Pass if any output frame was received + + pipeline.stop(); + pipeline.wait(); +} + +TEST_CASE("DepthAI VPP gray8") { + using namespace dai; + + // Connect to the device + auto device = std::make_shared(); + // Configure VPP + auto vppConfig = std::make_shared(); + vppConfig->maxPatchSize = 20; + vppConfig->patchColoringType = VppConfig::PatchColoringType::MAXDIST; + vppConfig->blending = 0.5f; + vppConfig->uniformPatch = true; + + // Modify nested injection parameters + vppConfig->injectionParameters.textureThreshold = 4.0; + vppConfig->injectionParameters.useInjection = true; + + // Build the pipeline + Pipeline pipeline; + auto vpp = pipeline.create(); + auto syncQueue = vpp->syncedInputs.createInputQueue(); + auto configQueue = vpp->inputConfig.createInputQueue(); + auto outLeftQueue = vpp->leftOut.createOutputQueue(); + auto outRightQueue = vpp->rightOut.createOutputQueue(); + + // Send config + configQueue->send(vppConfig); + + // Create fake disparity and confidence frames + cv::Mat disparity(16, 16, CV_16UC1, cv::Scalar(32)); + cv::Mat confidence(16, 16, CV_16UC1, cv::Scalar(0)); + + cv::Mat left(1280, 800, CV_8UC1, cv::Scalar(0)); + cv::Mat right(1280, 800, CV_8UC1, cv::Scalar(0)); + + auto leftFrame = std::make_shared(); + leftFrame->setCvFrame(left, ImgFrame::Type::GRAY8); + + auto rightFrame = std::make_shared(); + rightFrame->setCvFrame(right, ImgFrame::Type::GRAY8); + + auto disparityFrame = std::make_shared(); + disparityFrame->setCvFrame(disparity, ImgFrame::Type::RAW16); + + auto confidenceFrame = std::make_shared(); + confidenceFrame->setCvFrame(confidence, ImgFrame::Type::RAW16); + + pipeline.start(); + // Send message group + auto messageGroup = std::make_shared(); + messageGroup->add("left", leftFrame); + messageGroup->add("right", rightFrame); + messageGroup->add("disparity", disparityFrame); + messageGroup->add("confidence", confidenceFrame); + syncQueue->send(messageGroup); + + // Try to read outputs + auto leftOut = outLeftQueue->get(); + auto rightOut = outRightQueue->get(); + + bool gotOutput = (leftOut && rightOut); + + REQUIRE(gotOutput); // ✅ Pass if any output frame was received + + pipeline.stop(); + pipeline.wait(); +} + +TEST_CASE("DepthAI VPP multiple configs without recreating pipeline") { + using namespace dai; + + // Create pipeline once + Pipeline pipeline; + auto vpp = pipeline.create(); + auto syncQueue = vpp->syncedInputs.createInputQueue(); + auto configQueue = vpp->inputConfig.createInputQueue(); + auto outLeftQueue = vpp->leftOut.createOutputQueue(); + auto outRightQueue = vpp->rightOut.createOutputQueue(); + pipeline.start(); + + // Define parameter combinations + struct VppParams { + int maxPatchSize; + float blending; + bool uniformPatch; + float textureThreshold; + bool useInjection; + VppConfig::PatchColoringType patchColoring; + }; + + std::vector paramSets = { + {10, 0.1f, true, 1.0f, false, VppConfig::PatchColoringType::RANDOM}, + {20, 0.5f, false, 4.0f, false, VppConfig::PatchColoringType::MAXDIST}, + {30, 1.0f, true, 8.0f, true, VppConfig::PatchColoringType::MAXDIST}, + {100, 1.0f, true, 8.0f, false, VppConfig::PatchColoringType::MAXDIST}, + }; + + for(auto& params : paramSets) { + // Configure VPP + auto vppConfig = std::make_shared(); + vppConfig->maxPatchSize = params.maxPatchSize; + vppConfig->blending = params.blending; + vppConfig->uniformPatch = params.uniformPatch; + vppConfig->patchColoringType = params.patchColoring; + vppConfig->injectionParameters.textureThreshold = params.textureThreshold; + vppConfig->injectionParameters.useInjection = params.useInjection; + + // Fake input frames + cv::Mat left(800, 1280, CV_8UC1, cv::Scalar(0)); + cv::Mat right(800, 1280, CV_8UC1, cv::Scalar(0)); + cv::Mat disparity(16, 16, CV_16UC1, cv::Scalar(32)); + cv::Mat confidence(16, 16, CV_16UC1, cv::Scalar(1)); + + // Send config and frames + configQueue->send(vppConfig); + auto leftFrame = openCvToFrame(left, ImgFrame::Type::GRAY8); + auto rightFrame = openCvToFrame(right, ImgFrame::Type::GRAY8); + auto disparityFrame = openCvToFrame(disparity, ImgFrame::Type::RAW16); + auto confidenceFrame = openCvToFrame(confidence, ImgFrame::Type::RAW16); + + auto messageGroup = std::make_shared(); + messageGroup->add("left", leftFrame); + messageGroup->add("right", rightFrame); + messageGroup->add("disparity", disparityFrame); + messageGroup->add("confidence", confidenceFrame); + + syncQueue->send(messageGroup); + + // Check outputs + auto leftOut = outLeftQueue->get(); + auto rightOut = outRightQueue->get(); + REQUIRE(leftOut != nullptr); + REQUIRE(rightOut != nullptr); + auto leftOutCV = leftOut->getCvFrame(); + auto rightOutCV = rightOut->getCvFrame(); + + REQUIRE(leftOutCV.rows == left.rows); + REQUIRE(leftOutCV.cols == left.cols); + REQUIRE(rightOutCV.rows == right.rows); + REQUIRE(rightOutCV.cols == right.cols); + + // Assert that output types match the input frames + REQUIRE(leftOutCV.type() == left.type()); + REQUIRE(rightOutCV.type() == right.type()); + REQUIRE(cv::countNonZero(leftOutCV) > 0); + REQUIRE(cv::countNonZero(rightOutCV) > 0); + } + + pipeline.stop(); + pipeline.wait(); +} From 43d464fc0734466de15025ede04dd6dd4e8aef87 Mon Sep 17 00:00:00 2001 From: Jakub Fara Date: Tue, 18 Nov 2025 09:42:29 +0100 Subject: [PATCH 2/9] Change depthai-device commit --- cmake/Depthai/DepthaiDeviceRVC4Config.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/Depthai/DepthaiDeviceRVC4Config.cmake b/cmake/Depthai/DepthaiDeviceRVC4Config.cmake index 943aa9cebf..cd6f867d28 100644 --- a/cmake/Depthai/DepthaiDeviceRVC4Config.cmake +++ b/cmake/Depthai/DepthaiDeviceRVC4Config.cmake @@ -3,4 +3,5 @@ set(DEPTHAI_DEVICE_RVC4_MATURITY "snapshot") # "version if applicable" -set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+557d00a27535a643ba4d75bc0e0ef5d1db87e610") +set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+03f9007fc78d0e5635c888903387485a234b6e32") + From 3b9e14a44fd9e84a98b176fc5ec919a45d13d4d1 Mon Sep 17 00:00:00 2001 From: Jakub Fara Date: Thu, 20 Nov 2025 11:57:01 +0100 Subject: [PATCH 3/9] Add missing bindings --- bindings/python/src/pipeline/datatype/VppConfigBindings.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bindings/python/src/pipeline/datatype/VppConfigBindings.cpp b/bindings/python/src/pipeline/datatype/VppConfigBindings.cpp index b0efde5598..e2155082a8 100644 --- a/bindings/python/src/pipeline/datatype/VppConfigBindings.cpp +++ b/bindings/python/src/pipeline/datatype/VppConfigBindings.cpp @@ -62,5 +62,7 @@ void bind_vppconfig(pybind11::module& m, void* pCallstack) { .def_readwrite("maxPatchSize", &VppConfig::maxPatchSize, DOC(dai, VppConfig, maxPatchSize)) .def_readwrite("patchColoringType", &VppConfig::patchColoringType, DOC(dai, VppConfig, patchColoringType)) .def_readwrite("uniformPatch", &VppConfig::uniformPatch, DOC(dai, VppConfig, uniformPatch)) - .def_readwrite("injectionParameters", &VppConfig::injectionParameters, DOC(dai, VppConfig, injectionParameters)); + .def_readwrite("injectionParameters", &VppConfig::injectionParameters, DOC(dai, VppConfig, injectionParameters)) + .def_readwrite("maxNumThreads", &VppConfig::maxNumThreads, DOC(dai, VppConfig, maxNumThreads)) + .def_readwrite("maxFPS", &VppConfig::maxFPS, DOC(dai, VppConfig, maxFPS)); } From fd79ed3024df6d584bdc4d8b292685880b90e060 Mon Sep 17 00:00:00 2001 From: Jakub Fara Date: Thu, 20 Nov 2025 11:57:58 +0100 Subject: [PATCH 4/9] Add setters and docstrings for VppConfig --- .../depthai/pipeline/datatype/VppConfig.hpp | 227 ++++++++++++++++++ 1 file changed, 227 insertions(+) diff --git a/include/depthai/pipeline/datatype/VppConfig.hpp b/include/depthai/pipeline/datatype/VppConfig.hpp index 414b136313..1e56517004 100644 --- a/include/depthai/pipeline/datatype/VppConfig.hpp +++ b/include/depthai/pipeline/datatype/VppConfig.hpp @@ -21,6 +21,103 @@ class VppConfig : public Buffer { float confidenceThreshold = 0.5; int morphologyIterations = 5; bool useMorphology = true; + // Getters and setters with docstrings + /** + * @brief Check if injection is enabled + * False: all passible pixels will be used. + * @return True if injection is used + */ + bool getUseInjection() const { + return useInjection; + } + + /** + * @brief Enable or disable injection + * @param value True to use injection, false to disable + */ + void setUseInjection(bool value) { + useInjection = value; + } + + /** + * @brief Get kernel size for injection + * @return Kernel size + */ + int getKernelSize() const { + return kernelSize; + } + + /** + * @brief Set kernel size for injection + * @param value Kernel size to set + */ + void setKernelSize(int value) { + kernelSize = value; + } + + /** + * @brief Get texture threshold + * @return Texture threshold value + */ + float getTextureThreshold() const { + return textureThreshold; + } + + /** + * @brief Set texture threshold + * @param value Texture threshold to set + */ + void setTextureThreshold(float value) { + textureThreshold = value; + } + + /** + * @brief Get confidence threshold + * @return Confidence threshold value + */ + float getConfidenceThreshold() const { + return confidenceThreshold; + } + + /** + * @brief Set confidence threshold + * @param value Confidence threshold to set + */ + void setConfidenceThreshold(float value) { + confidenceThreshold = value; + } + + /** + * @brief Get number of morphology iterations + * @return Number of iterations + */ + int getMorphologyIterations() const { + return morphologyIterations; + } + + /** + * @brief Set number of morphology iterations + * @param value Number of iterations + */ + void setMorphologyIterations(int value) { + morphologyIterations = value; + } + + /** + * @brief Check if morphology is used + * @return True if morphology is applied + */ + bool isUseMorphology() const { + return useMorphology; + } + + /** + * @brief Enable or disable morphology + * @param value True to use morphology, false to disable + */ + void setUseMorphology(bool value) { + useMorphology = value; + } // clang-format off DEPTHAI_SERIALIZE( @@ -46,6 +143,136 @@ class VppConfig : public Buffer { VppConfig() = default; virtual ~VppConfig(); + // Getters and setters with docstrings + /** + * @brief Get blending factor between 0 and 1 + * @return Current blending value + */ + float getBlending() const { + return blending; + } + + /** + * @brief Set blending factor between 0 and 1: + * resulting fixel: patchColor * blending + (1 - blending) * imgFrame + * @param value Blending value to set + */ + void setBlending(float value) { + blending = value; + } + + /** + * @brief Get distance gamma + * @return Current distance gamma + */ + float getDistanceGamma() const { + return distanceGamma; + } + + /** + * @brief Set distance gamma + * @param value Distance gamma to set + */ + void setDistanceGamma(float value) { + distanceGamma = value; + } + + /** + * @brief Get maximum patch size + * @return Maximum patch size + */ + uint8_t getMaxPatchSize() const { + return maxPatchSize; + } + + /** + * @brief Set maximum patch size + * @param value Patch size to set + */ + void setMaxPatchSize(uint8_t value) { + maxPatchSize = value; + } + + /** + * @brief Get patch coloring type: UNIFORM/MAXDIST + * @return Current patch coloring type + */ + PatchColoringType getPatchColoringType() const { + return patchColoringType; + } + + /** + * @brief Set patch coloring type: UNIFORM/MAXDIST + * @param type Patch coloring type to set + */ + void setPatchColoringType(PatchColoringType type) { + patchColoringType = type; + } + + /** + * @brief Check if uniform patching is enabled + * @return True if uniform patching is enabled + */ + bool getUniformPatch() const { + return uniformPatch; + } + + /** + * @brief Enable or disable uniform patching + * @param value True to enable, false to disable + */ + void setUniformPatch(bool value) { + uniformPatch = value; + } + + /** + * @brief Get injection parameters + * @return Current injection parameters + */ + InjectionParameters getInjectionParameters() const { + return injectionParameters; + } + + /** + * @brief Set injection parameters + * @param params Injection parameters to set + */ + void setInjectionParameters(const InjectionParameters& params) { + injectionParameters = params; + } + + /** + * @brief Get maximum number of threads + * @return Maximum number of threads + */ + int getMaxNumThreads() const { + return maxNumThreads; + } + + /** + * @brief Set maximum number of threads + * @param value Number of threads to set + */ + void setMaxNumThreads(int value) { + maxNumThreads = value; + } + + /** + * @brief Get maximum FPS + * @return Maximum FPS + */ + int getMaxFPS() const { + return maxFPS; + } + + /** + * @brief Set maximum FPS + * @param value Maximum FPS to set + */ + void setMaxFPS(int value) { + maxFPS = value; + } + void serialize(std::vector& metadata, DatatypeEnum& datatype) const override { metadata = utility::serialize(*this); datatype = DatatypeEnum::VppConfig; From 59d7650137193e1c6b01fda78e82c10a9dbe3954 Mon Sep 17 00:00:00 2001 From: Jakub Fara Date: Thu, 20 Nov 2025 13:11:18 +0100 Subject: [PATCH 5/9] Remove redundant includes --- bindings/python/src/pipeline/PipelineBindings.cpp | 1 - src/pipeline/datatype/DatatypeEnum.cpp | 2 -- 2 files changed, 3 deletions(-) diff --git a/bindings/python/src/pipeline/PipelineBindings.cpp b/bindings/python/src/pipeline/PipelineBindings.cpp index 8adc9c011a..5652ce0f18 100644 --- a/bindings/python/src/pipeline/PipelineBindings.cpp +++ b/bindings/python/src/pipeline/PipelineBindings.cpp @@ -40,7 +40,6 @@ #include "depthai/pipeline/node/Warp.hpp" #include "depthai/pipeline/node/internal/XLinkIn.hpp" #include "depthai/pipeline/node/internal/XLinkOut.hpp" -#include "depthai/pipeline/node/Vpp.hpp" // depthai/ #include diff --git a/src/pipeline/datatype/DatatypeEnum.cpp b/src/pipeline/datatype/DatatypeEnum.cpp index 4662367163..9f87b8d8dc 100644 --- a/src/pipeline/datatype/DatatypeEnum.cpp +++ b/src/pipeline/datatype/DatatypeEnum.cpp @@ -6,8 +6,6 @@ #include #include -#include "spdlog/spdlog.h" - namespace dai { const std::unordered_map> hierarchy = { From d4e85db95b82a76809f50fa8caa1480253c322d2 Mon Sep 17 00:00:00 2001 From: Jakub Fara Date: Thu, 20 Nov 2025 13:33:45 +0100 Subject: [PATCH 6/9] Add docstirngs to python bindings. --- .../python/src/pipeline/node/VppBindings.cpp | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/bindings/python/src/pipeline/node/VppBindings.cpp b/bindings/python/src/pipeline/node/VppBindings.cpp index 32a9a0e193..243c14258d 100644 --- a/bindings/python/src/pipeline/node/VppBindings.cpp +++ b/bindings/python/src/pipeline/node/VppBindings.cpp @@ -33,17 +33,23 @@ void bind_vpp(pybind11::module& m, void* pCallstack) { // Node vpp.def_readonly("inputConfig", &Vpp::inputConfig, DOC(dai, node, Vpp, inputConfig)) .def_property_readonly( - "left", [](Vpp& node) { return node.left; }, py::return_value_policy::reference_internal) + "left", [](Vpp& node) { return node.left; }, py::return_value_policy::reference_internal, "Rectified left input in full resolution.") .def_property_readonly( - "right", [](Vpp& node) { return node.right; }, py::return_value_policy::reference_internal) + "right", [](Vpp& node) { return node.right; }, py::return_value_policy::reference_internal, "Rectified right input in full resolution.") .def_property_readonly( - "disparity", [](Vpp& node) { return node.disparity; }, py::return_value_policy::reference_internal) + "disparity", + [](Vpp& node) { return node.disparity; }, + py::return_value_policy::reference_internal, + "Low resolution disparity input in pixels (in integers - 16 times bigger).") .def_property_readonly( - "confidence", [](Vpp& node) { return node.confidence; }, py::return_value_policy::reference_internal) - .def_readonly("syncedInputs", &Vpp::syncedInputs, DOC(dai, node, Vpp, syncedInputs)) - .def_readonly("leftOut", &Vpp::leftOut, DOC(dai, node, Vpp, leftOut)) - .def_readonly("rightOut", &Vpp::rightOut, DOC(dai, node, Vpp, rightOut)) - .def_readonly("initialConfig", &Vpp::initialConfig, DOC(dai, node, Vpp, initialConfig)); + "confidence", + [](Vpp& node) { return node.confidence; }, + py::return_value_policy::reference_internal, + "Confidence of the dispatiry (in integers - 16 times bigger).") + .def_readonly("syncedInputs", &Vpp::syncedInputs, DOC(dai, node, Vpp, syncedInputs), "Synchronised Left Img, Right Img, Dispatiy and confidence input.") + .def_readonly("leftOut", &Vpp::leftOut, DOC(dai, node, Vpp, leftOut), "Left output with same resolution as input.") + .def_readonly("rightOut", &Vpp::rightOut, DOC(dai, node, Vpp, rightOut), "Right output with same resolution as input.") + .def_readonly("initialConfig", &Vpp::initialConfig, DOC(dai, node, Vpp, initialConfig), "Input config of the node."); // ALIAS daiNodeModule.attr("Vpp").attr("Properties") = vppProperties; From 4ee081e8db035587b1bbbaa92525a27ee66d33fc Mon Sep 17 00:00:00 2001 From: Jakub Fara Date: Thu, 20 Nov 2025 13:45:45 +0100 Subject: [PATCH 7/9] Formating change --- include/depthai/pipeline/datatype/ADatatype.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/depthai/pipeline/datatype/ADatatype.hpp b/include/depthai/pipeline/datatype/ADatatype.hpp index 9e53adef9b..4b00e2c4cd 100644 --- a/include/depthai/pipeline/datatype/ADatatype.hpp +++ b/include/depthai/pipeline/datatype/ADatatype.hpp @@ -36,4 +36,4 @@ class ADatatype { std::shared_ptr data; }; -} // namespace dai \ No newline at end of file +} // namespace dai From 361c95f1afc8e1c8259f252282a7d24ee3f45211 Mon Sep 17 00:00:00 2001 From: Jakub Fara Date: Tue, 25 Nov 2025 10:29:53 +0100 Subject: [PATCH 8/9] Add RVC4 check --- src/pipeline/node/Vpp.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pipeline/node/Vpp.cpp b/src/pipeline/node/Vpp.cpp index bf2c6b25b1..7294132328 100644 --- a/src/pipeline/node/Vpp.cpp +++ b/src/pipeline/node/Vpp.cpp @@ -22,6 +22,12 @@ Vpp::Properties& Vpp::getProperties() { } void Vpp::buildInternal() { + if(device) { + auto platform = device->getPlatform(); + if(platform != Platform::RVC4) { + throw std::runtime_error("Vpp node is supported only on RVC4 devices."); + } + } left = &sync->inputs[leftInputName]; right = &sync->inputs[rightInputName]; disparity = &sync->inputs[disparityName]; From 9f14311faca1ce5c5204b0af9914137b52f10372 Mon Sep 17 00:00:00 2001 From: Jakub Fara Date: Thu, 27 Nov 2025 13:28:03 +0100 Subject: [PATCH 9/9] Change depthai-device commit --- 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 cd6f867d28..35c3d89bdb 100644 --- a/cmake/Depthai/DepthaiDeviceRVC4Config.cmake +++ b/cmake/Depthai/DepthaiDeviceRVC4Config.cmake @@ -3,5 +3,5 @@ set(DEPTHAI_DEVICE_RVC4_MATURITY "snapshot") # "version if applicable" -set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+03f9007fc78d0e5635c888903387485a234b6e32") +set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+3036e4e8d431eb81f3aa566bae5bc5d5ae92acef")