Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -415,4 +416,4 @@ endif()
########################
if (DEPTHAI_PYTHON_ENABLE_EXAMPLES)
add_subdirectory(../../examples/python ${CMAKE_BINARY_DIR}/examples/python)
endif()
endif()
10 changes: 5 additions & 5 deletions bindings/python/generate_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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}')
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions bindings/python/src/DatatypeBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<StackFunction>& callstack) {
// Bind common datatypebindings
Expand Down Expand Up @@ -77,6 +78,7 @@ void DatatypeBindings::addToCallstack(std::deque<StackFunction>& 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);
Expand Down Expand Up @@ -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)
Expand Down
68 changes: 68 additions & 0 deletions bindings/python/src/pipeline/datatype/VppConfigBindings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include <memory>
#include <unordered_map>

#include "DatatypeBindings.hpp"
#include "pipeline/CommonBindings.hpp"

// depthai
#include "depthai/pipeline/datatype/VppConfig.hpp"

// pybind
#include <pybind11/chrono.h>
#include <pybind11/numpy.h>

void bind_vppconfig(pybind11::module& m, void* pCallstack) {
using namespace dai;
using namespace pybind11::literals;

// ---------------------------------------------------------------------
// ENUM: PatchColoringType
// ---------------------------------------------------------------------
py::enum_<VppConfig::PatchColoringType>(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_<VppConfig::InjectionParameters>(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 "<VppInjectionParameters useInjection=" + std::to_string(p.useInjection) + ", kernelSize=" + std::to_string(p.kernelSize)
+ ", textureThreshold=" + std::to_string(p.textureThreshold) + ", confidenceThreshold=" + std::to_string(p.confidenceThreshold)
+ ", morphologyIterations=" + std::to_string(p.morphologyIterations) + ", useMorphology=" + std::to_string(p.useMorphology) + ">";
});

// ---------------------------------------------------------------------
// CLASS: VppConfig
// ---------------------------------------------------------------------
py::class_<VppConfig, Py<VppConfig>, Buffer, std::shared_ptr<VppConfig>> 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))
.def_readwrite("maxNumThreads", &VppConfig::maxNumThreads, DOC(dai, VppConfig, maxNumThreads))
.def_readwrite("maxFPS", &VppConfig::maxFPS, DOC(dai, VppConfig, maxFPS));
}
2 changes: 2 additions & 0 deletions bindings/python/src/pipeline/node/NodeBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -214,6 +215,7 @@ void NodeBindings::addToCallstack(std::deque<StackFunction>& 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
Expand Down
56 changes: 56 additions & 0 deletions bindings/python/src/pipeline/node/VppBindings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#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> 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, "Rectified left input in full resolution.")
.def_property_readonly(
"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,
"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,
"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.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this compile with bindings enabled? DOC(dai, node, Vpp, syncedInputs) pulls the docstrings from the function dai::node::Vpp::syncedInputs So you can just update the docstrings there.

.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;
}
3 changes: 2 additions & 1 deletion cmake/Depthai/DepthaiDeviceRVC4Config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
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+3036e4e8d431eb81f3aa566bae5bc5d5ae92acef")

1 change: 1 addition & 0 deletions include/depthai/pipeline/datatype/DatatypeEnum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum class DatatypeEnum : std::int32_t {
DynamicCalibrationResult,
CalibrationQuality,
CoverageData,
VppConfig
};
bool isDatatypeSubclassOf(DatatypeEnum parent, DatatypeEnum children);

Expand Down
Loading
Loading