From f7a092431c47715c88a3c6a8a7bfdde14318f317 Mon Sep 17 00:00:00 2001 From: Matevz Morato Date: Sun, 26 Jan 2025 13:00:47 +0100 Subject: [PATCH] Apply formatting --- .../python/external/pybind11_opencv_numpy | 2 +- .../python/src/CalibrationHandlerBindings.cpp | 199 ++- bindings/python/src/DatatypeBindings.cpp | 12 +- bindings/python/src/DatatypeBindings.hpp | 3 +- bindings/python/src/DeviceBindings.cpp | 1106 ++++++++++++----- .../python/src/DeviceBootloaderBindings.cpp | 437 +++++-- bindings/python/src/MessageQueueBindings.cpp | 8 +- bindings/python/src/VersionBindings.cpp | 12 +- bindings/python/src/XLinkBindings.cpp | 107 +- bindings/python/src/XLinkBindings.hpp | 5 +- .../python/src/common/ModelTypeBindings.cpp | 1 - bindings/python/src/log/LogBindings.cpp | 20 +- .../modelzoo/NNModelDescriptionBindings.cpp | 2 +- .../src/nn_archive/NNArchiveBindings.cpp | 27 +- .../python/src/openvino/OpenVINOBindings.cpp | 51 +- .../src/pipeline/AssetManagerBindings.cpp | 69 +- .../python/src/pipeline/CommonBindings.cpp | 252 ++-- .../python/src/pipeline/PipelineBindings.cpp | 138 +- .../pipeline/datatype/ADatatypeBindings.cpp | 17 +- .../datatype/AprilTagConfigBindings.cpp | 35 +- .../pipeline/datatype/AprilTagsBindings.cpp | 25 +- .../src/pipeline/datatype/BufferBindings.cpp | 53 +- .../datatype/CameraControlBindings.cpp | 151 ++- .../datatype/EdgeDetectorConfigBindings.cpp | 45 +- .../datatype/FeatureTrackerConfigBindings.cpp | 172 ++- .../src/pipeline/datatype/IMUDataBindings.cpp | 71 +- .../datatype/ImageAlignConfigBindings.cpp | 22 +- .../datatype/ImageManipConfigBindings.cpp | 3 +- .../datatype/ImageManipConfigV2Bindings.cpp | 24 +- .../datatype/ImgAnnotationsBindings.cpp | 123 +- .../datatype/ImgDetectionsBindings.cpp | 33 +- .../pipeline/datatype/ImgFrameBindings.cpp | 4 +- .../datatype/MessageGroupBindings.cpp | 30 +- .../src/pipeline/datatype/NNDataBindings.cpp | 283 +++-- .../datatype/PointCloudConfigBindings.cpp | 31 +- .../datatype/PointCloudDataBindings.cpp | 131 +- .../datatype/SpatialImgDetectionsBindings.cpp | 40 +- ...patialLocationCalculatorConfigBindings.cpp | 48 +- .../SpatialLocationCalculatorDataBindings.cpp | 32 +- .../datatype/StereoDepthConfigBindings.cpp | 512 ++++---- .../datatype/SystemInformationBindings.cpp | 58 +- .../datatype/ThermalConfigBindings.cpp | 22 +- .../pipeline/datatype/ToFConfigBindings.cpp | 16 +- .../datatype/TrackedFeaturesBindings.cpp | 30 +- .../pipeline/datatype/TrackletsBindings.cpp | 34 +- .../datatype/TransformDataBindings.cpp | 15 +- .../src/pipeline/node/AprilTagBindings.cpp | 22 +- .../src/pipeline/node/BasaltVIOBindings.cpp | 147 +-- .../src/pipeline/node/BenchmarkBindings.cpp | 5 +- .../src/pipeline/node/ColorCameraBindings.cpp | 191 +-- bindings/python/src/pipeline/node/Common.hpp | 19 +- .../node/DetectionNetworkBindings.cpp | 41 +- .../pipeline/node/DetectionParserBindings.cpp | 16 +- .../pipeline/node/EdgeDetectorBindings.cpp | 62 +- .../pipeline/node/FeatureTrackerBindings.cpp | 67 +- .../src/pipeline/node/HostNodeBindings.cpp | 10 +- .../python/src/pipeline/node/IMUBindings.cpp | 59 +- .../src/pipeline/node/ImageAlignBindings.cpp | 34 +- .../src/pipeline/node/ImageManipBindings.cpp | 170 +-- .../pipeline/node/ImageManipV2Bindings.cpp | 17 +- .../pipeline/node/MessageDemuxBindings.cpp | 53 +- .../src/pipeline/node/MonoCameraBindings.cpp | 79 +- .../pipeline/node/NeuralNetworkBindings.cpp | 75 +- .../python/src/pipeline/node/NodeBindings.cpp | 41 +- .../python/src/pipeline/node/NodeBindings.hpp | 4 +- .../pipeline/node/ObjectTrackerBindings.cpp | 46 +- .../src/pipeline/node/PointCloudBindings.cpp | 29 +- .../src/pipeline/node/RTABMapSLAMBindings.cpp | 17 +- .../src/pipeline/node/RTABMapVIOBindings.cpp | 14 +- .../src/pipeline/node/RecordBindings.cpp | 10 +- .../src/pipeline/node/ReplayBindings.cpp | 4 +- .../src/pipeline/node/SPIInBindings.cpp | 25 +- .../src/pipeline/node/SPIOutBindings.cpp | 24 +- .../src/pipeline/node/ScriptBindings.cpp | 35 +- .../node/SpatialDetectionNetworkBindings.cpp | 71 +- .../SpatialLocationCalculatorBindings.cpp | 61 +- .../src/pipeline/node/StereoDepthBindings.cpp | 96 +- .../python/src/pipeline/node/SyncBindings.cpp | 21 +- .../pipeline/node/SystemLoggerBindings.cpp | 23 +- .../src/pipeline/node/ThermalBindings.cpp | 23 +- .../python/src/pipeline/node/ToFBindings.cpp | 22 +- .../python/src/pipeline/node/UVCBindings.cpp | 24 +- .../pipeline/node/VideoEncoderBindings.cpp | 232 ++-- .../python/src/pipeline/node/WarpBindings.cpp | 20 +- .../src/pipeline/node/XLinkInBindings.cpp | 25 +- .../src/pipeline/node/XLinkOutBindings.cpp | 23 +- bindings/python/src/py_bindings.cpp | 56 +- bindings/python/src/pybind11_common.hpp | 89 +- .../RemoteConnectionBindings.cpp | 18 +- .../src/utility/EventsManagerBindings.cpp | 6 +- bindings/python/src/utility/SpanBindings.hpp | 254 ++-- src/device/DeviceLogger.hpp | 44 +- src/nn_archive/v1/Generators.hpp | 495 ++++---- src/nn_archive/v1/helper.hpp | 109 +- src/openvino/BlobFormat.hpp | 11 +- src/openvino/BlobReader.hpp | 55 +- .../RemoteConnectionImpl.hpp | 20 +- src/utility/EepromDataParser.hpp | 10 +- src/utility/Environment.hpp | 14 +- src/utility/HolisticRecordReplay.hpp | 5 +- src/utility/Logging.hpp | 103 +- src/utility/PimplImpl.hpp | 29 +- src/utility/Platform.hpp | 5 +- src/utility/ProtoSerialize.hpp | 3 +- src/utility/Resources.hpp | 15 +- src/utility/XLinkGlobalProfilingLogger.hpp | 10 +- src/utility/sha1.hpp | 219 ++-- src/utility/spdlog-fmt.hpp | 22 +- 108 files changed, 4523 insertions(+), 3537 deletions(-) mode change 100755 => 100644 src/utility/spdlog-fmt.hpp diff --git a/bindings/python/external/pybind11_opencv_numpy b/bindings/python/external/pybind11_opencv_numpy index 45594f898..b813d0503 160000 --- a/bindings/python/external/pybind11_opencv_numpy +++ b/bindings/python/external/pybind11_opencv_numpy @@ -1 +1 @@ -Subproject commit 45594f898d10cee6d94b693ed8076d5b564c2ed5 +Subproject commit b813d05032b5058ab3a19dc9f7cf8aa3dd74987d diff --git a/bindings/python/src/CalibrationHandlerBindings.cpp b/bindings/python/src/CalibrationHandlerBindings.cpp index be4ab676f..5eeaeaf1c 100644 --- a/bindings/python/src/CalibrationHandlerBindings.cpp +++ b/bindings/python/src/CalibrationHandlerBindings.cpp @@ -1,10 +1,11 @@ #include "CalibrationHandlerBindings.hpp" -#include "depthai/common/Point2f.hpp" -#include "depthai/device/CalibrationHandler.hpp" + #include -void CalibrationHandlerBindings::bind(pybind11::module& m, void* pCallstack){ +#include "depthai/common/Point2f.hpp" +#include "depthai/device/CalibrationHandler.hpp" +void CalibrationHandlerBindings::bind(pybind11::module& m, void* pCallstack) { using namespace dai; // Type definitions @@ -14,7 +15,7 @@ void CalibrationHandlerBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -23,8 +24,7 @@ void CalibrationHandlerBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Bindings - calibrationHandler - .def(py::init<>(), DOC(dai, CalibrationHandler, CalibrationHandler)) + calibrationHandler.def(py::init<>(), DOC(dai, CalibrationHandler, CalibrationHandler)) .def(py::init(), DOC(dai, CalibrationHandler, CalibrationHandler, 2)) .def(py::init(), DOC(dai, CalibrationHandler, CalibrationHandler, 3)) .def(py::init(), DOC(dai, CalibrationHandler, CalibrationHandler, 4)) @@ -33,56 +33,181 @@ void CalibrationHandlerBindings::bind(pybind11::module& m, void* pCallstack){ .def("getEepromData", &CalibrationHandler::getEepromData, DOC(dai, CalibrationHandler, getEepromData)) - .def("getCameraIntrinsics", py::overload_cast(&CalibrationHandler::getCameraIntrinsics, py::const_), py::arg("cameraId"), py::arg("resizeWidth") = -1, py::arg("resizeHeight") = -1, py::arg("topLeftPixelId") = Point2f(), py::arg("bottomRightPixelId") = Point2f(), py::arg("keepAspectRatio") = true, DOC(dai, CalibrationHandler, getCameraIntrinsics)) - .def("getCameraIntrinsics", py::overload_cast(&CalibrationHandler::getCameraIntrinsics, py::const_), py::arg("cameraId"), py::arg("destShape"), py::arg("topLeftPixelId") = Point2f(), py::arg("bottomRightPixelId") = Point2f(), py::arg("keepAspectRatio") = true, DOC(dai, CalibrationHandler, getCameraIntrinsics, 2)) - .def("getCameraIntrinsics", py::overload_cast, Point2f, Point2f, bool>(&CalibrationHandler::getCameraIntrinsics, py::const_), py::arg("cameraId"), py::arg("destShape"), py::arg("topLeftPixelId") = Point2f(), py::arg("bottomRightPixelId") = Point2f(), py::arg("keepAspectRatio") = true, DOC(dai, CalibrationHandler, getCameraIntrinsics, 3)) + .def("getCameraIntrinsics", + py::overload_cast(&CalibrationHandler::getCameraIntrinsics, py::const_), + py::arg("cameraId"), + py::arg("resizeWidth") = -1, + py::arg("resizeHeight") = -1, + py::arg("topLeftPixelId") = Point2f(), + py::arg("bottomRightPixelId") = Point2f(), + py::arg("keepAspectRatio") = true, + DOC(dai, CalibrationHandler, getCameraIntrinsics)) + .def("getCameraIntrinsics", + py::overload_cast(&CalibrationHandler::getCameraIntrinsics, py::const_), + py::arg("cameraId"), + py::arg("destShape"), + py::arg("topLeftPixelId") = Point2f(), + py::arg("bottomRightPixelId") = Point2f(), + py::arg("keepAspectRatio") = true, + DOC(dai, CalibrationHandler, getCameraIntrinsics, 2)) + .def("getCameraIntrinsics", + py::overload_cast, Point2f, Point2f, bool>(&CalibrationHandler::getCameraIntrinsics, py::const_), + py::arg("cameraId"), + py::arg("destShape"), + py::arg("topLeftPixelId") = Point2f(), + py::arg("bottomRightPixelId") = Point2f(), + py::arg("keepAspectRatio") = true, + DOC(dai, CalibrationHandler, getCameraIntrinsics, 3)) .def("getDefaultIntrinsics", &CalibrationHandler::getDefaultIntrinsics, py::arg("cameraId"), DOC(dai, CalibrationHandler, getDefaultIntrinsics)) - .def("getDistortionCoefficients", &CalibrationHandler::getDistortionCoefficients, py::arg("cameraId"), DOC(dai, CalibrationHandler, getDistortionCoefficients)) + .def("getDistortionCoefficients", + &CalibrationHandler::getDistortionCoefficients, + py::arg("cameraId"), + DOC(dai, CalibrationHandler, getDistortionCoefficients)) .def("getFov", &CalibrationHandler::getFov, py::arg("cameraId"), py::arg("useSpec") = true, DOC(dai, CalibrationHandler, getFov)) .def("getLensPosition", &CalibrationHandler::getLensPosition, py::arg("cameraId"), DOC(dai, CalibrationHandler, getLensPosition)) .def("getDistortionModel", &CalibrationHandler::getDistortionModel, py::arg("cameraId"), DOC(dai, CalibrationHandler, getDistortionModel)) - .def("getCameraExtrinsics", &CalibrationHandler::getCameraExtrinsics, py::arg("srcCamera"), py::arg("dstCamera"), py::arg("useSpecTranslation") = false, DOC(dai, CalibrationHandler, getCameraExtrinsics)) - - .def("getCameraTranslationVector", &CalibrationHandler::getCameraTranslationVector, py::arg("srcCamera"), py::arg("dstCamera"), py::arg("useSpecTranslation") = true, DOC(dai, CalibrationHandler, getCameraTranslationVector)) - .def("getCameraRotationMatrix", &CalibrationHandler::getCameraRotationMatrix, py::arg("srcCamera"), py::arg("dstCamera"), DOC(dai, CalibrationHandler, getCameraRotationMatrix)) - .def("getBaselineDistance", &CalibrationHandler::getBaselineDistance, py::arg("cam1") = dai::CameraBoardSocket::CAM_C, py::arg("cam2") = dai::CameraBoardSocket::CAM_B, py::arg("useSpecTranslation") = true, DOC(dai, CalibrationHandler, getBaselineDistance)) - - .def("getCameraToImuExtrinsics", &CalibrationHandler::getCameraToImuExtrinsics, py::arg("cameraId"), py::arg("useSpecTranslation") = false, DOC(dai, CalibrationHandler, getCameraToImuExtrinsics)) - .def("getImuToCameraExtrinsics", &CalibrationHandler::getImuToCameraExtrinsics, py::arg("cameraId"), py::arg("useSpecTranslation") = false, DOC(dai, CalibrationHandler, getImuToCameraExtrinsics)) - - .def("getStereoRightRectificationRotation", &CalibrationHandler::getStereoRightRectificationRotation, DOC(dai, CalibrationHandler, getStereoRightRectificationRotation)) - .def("getStereoLeftRectificationRotation", &CalibrationHandler::getStereoLeftRectificationRotation, DOC(dai, CalibrationHandler, getStereoLeftRectificationRotation)) + .def("getCameraExtrinsics", + &CalibrationHandler::getCameraExtrinsics, + py::arg("srcCamera"), + py::arg("dstCamera"), + py::arg("useSpecTranslation") = false, + DOC(dai, CalibrationHandler, getCameraExtrinsics)) + + .def("getCameraTranslationVector", + &CalibrationHandler::getCameraTranslationVector, + py::arg("srcCamera"), + py::arg("dstCamera"), + py::arg("useSpecTranslation") = true, + DOC(dai, CalibrationHandler, getCameraTranslationVector)) + .def("getCameraRotationMatrix", + &CalibrationHandler::getCameraRotationMatrix, + py::arg("srcCamera"), + py::arg("dstCamera"), + DOC(dai, CalibrationHandler, getCameraRotationMatrix)) + .def("getBaselineDistance", + &CalibrationHandler::getBaselineDistance, + py::arg("cam1") = dai::CameraBoardSocket::CAM_C, + py::arg("cam2") = dai::CameraBoardSocket::CAM_B, + py::arg("useSpecTranslation") = true, + DOC(dai, CalibrationHandler, getBaselineDistance)) + + .def("getCameraToImuExtrinsics", + &CalibrationHandler::getCameraToImuExtrinsics, + py::arg("cameraId"), + py::arg("useSpecTranslation") = false, + DOC(dai, CalibrationHandler, getCameraToImuExtrinsics)) + .def("getImuToCameraExtrinsics", + &CalibrationHandler::getImuToCameraExtrinsics, + py::arg("cameraId"), + py::arg("useSpecTranslation") = false, + DOC(dai, CalibrationHandler, getImuToCameraExtrinsics)) + + .def("getStereoRightRectificationRotation", + &CalibrationHandler::getStereoRightRectificationRotation, + DOC(dai, CalibrationHandler, getStereoRightRectificationRotation)) + .def("getStereoLeftRectificationRotation", + &CalibrationHandler::getStereoLeftRectificationRotation, + DOC(dai, CalibrationHandler, getStereoLeftRectificationRotation)) .def("getStereoLeftCameraId", &CalibrationHandler::getStereoLeftCameraId, DOC(dai, CalibrationHandler, getStereoLeftCameraId)) .def("getStereoRightCameraId", &CalibrationHandler::getStereoRightCameraId, DOC(dai, CalibrationHandler, getStereoRightCameraId)) .def("eepromToJsonFile", &CalibrationHandler::eepromToJsonFile, py::arg("destPath"), DOC(dai, CalibrationHandler, eepromToJsonFile)) .def("eepromToJson", &CalibrationHandler::eepromToJson, DOC(dai, CalibrationHandler, eepromToJson)) - .def("setBoardInfo", py::overload_cast(&CalibrationHandler::setBoardInfo), py::arg("boardName"), py::arg("boardRev"), DOC(dai, CalibrationHandler, setBoardInfo)) - .def("setBoardInfo", py::overload_cast(&CalibrationHandler::setBoardInfo), py::arg("productName"), py::arg("boardName"), py::arg("boardRev"), py::arg("boardConf"), py::arg("hardwareConf"), py::arg("batchName"), py::arg("batchTime"), py::arg("boardOptions"), py::arg("boardCustom") = "", DOC(dai, CalibrationHandler, setBoardInfo, 2)) - .def("setBoardInfo", py::overload_cast(&CalibrationHandler::setBoardInfo), py::arg("deviceName"), py::arg("productName"), py::arg("boardName"), py::arg("boardRev"), py::arg("boardConf"), py::arg("hardwareConf"), py::arg("batchName"), py::arg("batchTime"), py::arg("boardOptions"), py::arg("boardCustom") = "", DOC(dai, CalibrationHandler, setBoardInfo, 3)) + .def("setBoardInfo", + py::overload_cast(&CalibrationHandler::setBoardInfo), + py::arg("boardName"), + py::arg("boardRev"), + DOC(dai, CalibrationHandler, setBoardInfo)) + .def("setBoardInfo", + py::overload_cast( + &CalibrationHandler::setBoardInfo), + py::arg("productName"), + py::arg("boardName"), + py::arg("boardRev"), + py::arg("boardConf"), + py::arg("hardwareConf"), + py::arg("batchName"), + py::arg("batchTime"), + py::arg("boardOptions"), + py::arg("boardCustom") = "", + DOC(dai, CalibrationHandler, setBoardInfo, 2)) + .def("setBoardInfo", + py::overload_cast( + &CalibrationHandler::setBoardInfo), + py::arg("deviceName"), + py::arg("productName"), + py::arg("boardName"), + py::arg("boardRev"), + py::arg("boardConf"), + py::arg("hardwareConf"), + py::arg("batchName"), + py::arg("batchTime"), + py::arg("boardOptions"), + py::arg("boardCustom") = "", + DOC(dai, CalibrationHandler, setBoardInfo, 3)) .def("setDeviceName", &CalibrationHandler::setDeviceName, py::arg("deviceName"), DOC(dai, CalibrationHandler, setDeviceName)) .def("setProductName", &CalibrationHandler::setProductName, py::arg("productName"), DOC(dai, CalibrationHandler, setProductName)) - .def("setCameraIntrinsics", py::overload_cast>, Size2f>(&CalibrationHandler::setCameraIntrinsics), py::arg("cameraId"), py::arg("intrinsics"), py::arg("frameSize"), DOC(dai, CalibrationHandler, setCameraIntrinsics)) - .def("setCameraIntrinsics", py::overload_cast>, int, int>(&CalibrationHandler::setCameraIntrinsics), py::arg("cameraId"), py::arg("intrinsics"), py::arg("width"), py::arg("height"), DOC(dai, CalibrationHandler, setCameraIntrinsics, 2)) - .def("setCameraIntrinsics", py::overload_cast>, std::tuple>(&CalibrationHandler::setCameraIntrinsics), py::arg("cameraId"), py::arg("intrinsics"), py::arg("frameSize"), DOC(dai, CalibrationHandler, setCameraIntrinsics, 3)) - - .def("setDistortionCoefficients", &CalibrationHandler::setDistortionCoefficients, py::arg("cameraId"), py::arg("distortionCoefficients"), DOC(dai, CalibrationHandler, setDistortionCoefficients)) + .def("setCameraIntrinsics", + py::overload_cast>, Size2f>(&CalibrationHandler::setCameraIntrinsics), + py::arg("cameraId"), + py::arg("intrinsics"), + py::arg("frameSize"), + DOC(dai, CalibrationHandler, setCameraIntrinsics)) + .def("setCameraIntrinsics", + py::overload_cast>, int, int>(&CalibrationHandler::setCameraIntrinsics), + py::arg("cameraId"), + py::arg("intrinsics"), + py::arg("width"), + py::arg("height"), + DOC(dai, CalibrationHandler, setCameraIntrinsics, 2)) + .def("setCameraIntrinsics", + py::overload_cast>, std::tuple>(&CalibrationHandler::setCameraIntrinsics), + py::arg("cameraId"), + py::arg("intrinsics"), + py::arg("frameSize"), + DOC(dai, CalibrationHandler, setCameraIntrinsics, 3)) + + .def("setDistortionCoefficients", + &CalibrationHandler::setDistortionCoefficients, + py::arg("cameraId"), + py::arg("distortionCoefficients"), + DOC(dai, CalibrationHandler, setDistortionCoefficients)) .def("setFov", &CalibrationHandler::setFov, py::arg("cameraId"), py::arg("hfov"), DOC(dai, CalibrationHandler, setFov)) - .def("setLensPosition", &CalibrationHandler::setLensPosition, py::arg("cameraId"), py::arg("lensPosition"), DOC(dai, CalibrationHandler, setLensPosition)) + .def("setLensPosition", + &CalibrationHandler::setLensPosition, + py::arg("cameraId"), + py::arg("lensPosition"), + DOC(dai, CalibrationHandler, setLensPosition)) .def("setCameraType", &CalibrationHandler::setCameraType, py::arg("cameraId"), py::arg("cameraModel"), DOC(dai, CalibrationHandler, setCameraType)) - .def("setCameraExtrinsics", &CalibrationHandler::setCameraExtrinsics, py::arg("srcCameraId"), py::arg("destCameraId"), py::arg("rotationMatrix"), py::arg("translation"), py::arg("specTranslation") = std::vector(3,0), DOC(dai, CalibrationHandler, setCameraExtrinsics)) - .def("setImuExtrinsics", &CalibrationHandler::setImuExtrinsics, py::arg("destCameraId"), py::arg("rotationMatrix"), py::arg("translation"), py::arg("specTranslation") = std::vector(3,0), DOC(dai, CalibrationHandler, setImuExtrinsics)) - - .def("setStereoLeft", &CalibrationHandler::setStereoLeft, py::arg("cameraId"), py::arg("rectifiedRotation"), DOC(dai, CalibrationHandler, setStereoLeft)) - .def("setStereoRight", &CalibrationHandler::setStereoRight, py::arg("cameraId"), py::arg("rectifiedRotation"), DOC(dai, CalibrationHandler, setStereoRight)); - - + .def("setCameraExtrinsics", + &CalibrationHandler::setCameraExtrinsics, + py::arg("srcCameraId"), + py::arg("destCameraId"), + py::arg("rotationMatrix"), + py::arg("translation"), + py::arg("specTranslation") = std::vector(3, 0), + DOC(dai, CalibrationHandler, setCameraExtrinsics)) + .def("setImuExtrinsics", + &CalibrationHandler::setImuExtrinsics, + py::arg("destCameraId"), + py::arg("rotationMatrix"), + py::arg("translation"), + py::arg("specTranslation") = std::vector(3, 0), + DOC(dai, CalibrationHandler, setImuExtrinsics)) + + .def( + "setStereoLeft", &CalibrationHandler::setStereoLeft, py::arg("cameraId"), py::arg("rectifiedRotation"), DOC(dai, CalibrationHandler, setStereoLeft)) + .def("setStereoRight", + &CalibrationHandler::setStereoRight, + py::arg("cameraId"), + py::arg("rectifiedRotation"), + DOC(dai, CalibrationHandler, setStereoRight)); } \ No newline at end of file diff --git a/bindings/python/src/DatatypeBindings.cpp b/bindings/python/src/DatatypeBindings.cpp index 4e9304665..ace49726b 100644 --- a/bindings/python/src/DatatypeBindings.cpp +++ b/bindings/python/src/DatatypeBindings.cpp @@ -36,7 +36,7 @@ void bind_imagealignconfig(pybind11::module& m, void* pCallstack); void bind_imageannotations(pybind11::module& m, void* pCallstack); void DatatypeBindings::addToCallstack(std::deque& callstack) { - // Bind common datatypebindings + // Bind common datatypebindings callstack.push_front(DatatypeBindings::bind); // Bind all datatypes (order matters) @@ -70,10 +70,10 @@ void DatatypeBindings::addToCallstack(std::deque& callstack) { callstack.push_front(bind_pointclouddata); callstack.push_front(bind_transformdata); callstack.push_front(bind_imagealignconfig); - callstack.push_front(bind_imageannotations); + callstack.push_front(bind_imageannotations); } -void DatatypeBindings::bind(pybind11::module& m, void* pCallstack){ +void DatatypeBindings::bind(pybind11::module& m, void* pCallstack) { using namespace dai; py::enum_ datatypeEnum(m, "DatatypeEnum", DOC(dai, DatatypeEnum)); @@ -82,7 +82,7 @@ void DatatypeBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -123,7 +123,5 @@ void DatatypeBindings::bind(pybind11::module& m, void* pCallstack){ .value("PointCloudConfig", DatatypeEnum::PointCloudConfig) .value("PointCloudData", DatatypeEnum::PointCloudData) .value("ImageAlignConfig", DatatypeEnum::ImageAlignConfig) - .value("ImgAnnotations", DatatypeEnum::ImgAnnotations) - ; - + .value("ImgAnnotations", DatatypeEnum::ImgAnnotations); } diff --git a/bindings/python/src/DatatypeBindings.hpp b/bindings/python/src/DatatypeBindings.hpp index c89aa63d2..4a47782ab 100644 --- a/bindings/python/src/DatatypeBindings.hpp +++ b/bindings/python/src/DatatypeBindings.hpp @@ -7,7 +7,8 @@ struct DatatypeBindings { static void addToCallstack(std::deque& callstack); - private: + + private: static void bind(pybind11::module& m, void* pCallstack); }; diff --git a/bindings/python/src/DeviceBindings.cpp b/bindings/python/src/DeviceBindings.cpp index 19e3afe36..ca018659b 100644 --- a/bindings/python/src/DeviceBindings.cpp +++ b/bindings/python/src/DeviceBindings.cpp @@ -24,16 +24,15 @@ PYBIND11_MAKE_OPAQUE(std::unordered_map); // Searches for available devices (as Device constructor) // but pooling, to check for python interrupts, and releases GIL in between -template -static auto deviceSearchHelper(Args&&... args){ - +template +static auto deviceSearchHelper(Args&&... args) { bool found; dai::DeviceInfo deviceInfo; // releases python GIL py::gil_scoped_release release; - std::tie(found, deviceInfo) = DEVICE::getAnyAvailableDevice(DEVICE::getDefaultSearchTime(), [](){ + std::tie(found, deviceInfo) = DEVICE::getAnyAvailableDevice(DEVICE::getDefaultSearchTime(), []() { py::gil_scoped_acquire acquire; - if (PyErr_CheckSignals() != 0) throw py::error_already_set(); + if(PyErr_CheckSignals() != 0) throw py::error_already_set(); }); // if no devices found, then throw @@ -49,8 +48,8 @@ static auto deviceSearchHelper(Args&&... args){ return deviceInfo; } - -// static std::vector deviceGetQueueEventsHelper(dai::Device& d, const std::vector& queueNames, std::size_t maxNumEvents, std::chrono::microseconds timeout){ +// static std::vector deviceGetQueueEventsHelper(dai::Device& d, const std::vector& queueNames, std::size_t maxNumEvents, +// std::chrono::microseconds timeout){ // using namespace std::chrono; // // if timeout < 0, unlimited timeout @@ -72,119 +71,173 @@ static auto deviceSearchHelper(Args&&... args){ // return std::vector(); // } - -template -static void bindConstructors(ARG& arg){ +template +static void bindConstructors(ARG& arg) { using namespace dai; - arg - .def(py::init([](const Pipeline& pipeline){ - auto dev = deviceSearchHelper(); - py::gil_scoped_release release; - return std::make_unique(pipeline, dev); - }), py::arg("pipeline"), DOC(dai, DeviceBase, DeviceBase)) - .def(py::init([](const Pipeline& pipeline, bool usb2Mode){ - PyErr_WarnEx(PyExc_DeprecationWarning, "Use constructor taking 'UsbSpeed' instead", 1); - auto dev = deviceSearchHelper(); - py::gil_scoped_release release; - return std::make_unique(pipeline, dev, usb2Mode); - }), py::arg("pipeline"), py::arg("usb2Mode"), DOC(dai, DeviceBase, DeviceBase, 2)) - .def(py::init([](const Pipeline& pipeline, UsbSpeed maxUsbSpeed){ - auto dev = deviceSearchHelper(); - py::gil_scoped_release release; - return std::make_unique(pipeline, dev, maxUsbSpeed); - }), py::arg("pipeline"), py::arg("maxUsbSpeed"), DOC(dai, DeviceBase, DeviceBase, 3)) - .def(py::init([](const Pipeline& pipeline, const dai::Path& pathToCmd){ - auto dev = deviceSearchHelper(); - py::gil_scoped_release release; - return std::make_unique(pipeline, dev, pathToCmd); - }), py::arg("pipeline"), py::arg("pathToCmd"), DOC(dai, DeviceBase, DeviceBase, 4)) - .def(py::init([](const Pipeline& pipeline, const DeviceInfo& deviceInfo, bool usb2Mode){ - PyErr_WarnEx(PyExc_DeprecationWarning, "Use constructor taking 'UsbSpeed' instead", 1); - py::gil_scoped_release release; - return std::make_unique(pipeline, deviceInfo, usb2Mode); - }), py::arg("pipeline"), py::arg("devInfo"), py::arg("usb2Mode") = false, DOC(dai, DeviceBase, DeviceBase, 6)) - .def(py::init([](const Pipeline& pipeline, const DeviceInfo& deviceInfo, UsbSpeed maxUsbSpeed){ - py::gil_scoped_release release; - return std::make_unique(pipeline, deviceInfo, maxUsbSpeed); - }), py::arg("pipeline"), py::arg("deviceInfo"), py::arg("maxUsbSpeed"), DOC(dai, DeviceBase, DeviceBase, 7)) - .def(py::init([](const Pipeline& pipeline, const DeviceInfo& deviceInfo, dai::Path pathToCmd){ - py::gil_scoped_release release; - return std::make_unique(pipeline, deviceInfo, pathToCmd); - }), py::arg("pipeline"), py::arg("devInfo"), py::arg("pathToCmd"), DOC(dai, DeviceBase, DeviceBase, 8)) - - // DeviceBase constructor - OpenVINO version - .def(py::init([](OpenVINO::Version version){ - auto dev = deviceSearchHelper(); - py::gil_scoped_release release; - return std::make_unique(version, dev); - }), py::arg("version") = OpenVINO::VERSION_UNIVERSAL, DOC(dai, DeviceBase, DeviceBase, 10)) - .def(py::init([](OpenVINO::Version version, bool usb2Mode){ - PyErr_WarnEx(PyExc_DeprecationWarning, "Use constructor taking 'UsbSpeed' instead", 1); - auto dev = deviceSearchHelper(); - py::gil_scoped_release release; - return std::make_unique(version, dev, usb2Mode); - }), py::arg("version"), py::arg("usb2Mode") = false, DOC(dai, DeviceBase, DeviceBase, 11)) - .def(py::init([](OpenVINO::Version version, UsbSpeed maxUsbSpeed){ - auto dev = deviceSearchHelper(); - py::gil_scoped_release release; - return std::make_unique(version, dev, maxUsbSpeed); - }), py::arg("version"), py::arg("maxUsbSpeed"), DOC(dai, DeviceBase, DeviceBase, 12)) - .def(py::init([](OpenVINO::Version version, const dai::Path& pathToCmd){ - auto dev = deviceSearchHelper(); - py::gil_scoped_release release; - return std::make_unique(version, dev, pathToCmd); - }), py::arg("version"), py::arg("pathToCmd"), DOC(dai, DeviceBase, DeviceBase, 13)) - .def(py::init([](OpenVINO::Version version, const DeviceInfo& deviceInfo, bool usb2Mode){ - PyErr_WarnEx(PyExc_DeprecationWarning, "Use constructor taking 'UsbSpeed' instead", 1); - py::gil_scoped_release release; - return std::make_unique(version, deviceInfo, usb2Mode); - }), py::arg("version"), py::arg("deviceInfo"), py::arg("usb2Mode") = false, DOC(dai, DeviceBase, DeviceBase, 15)) - .def(py::init([](OpenVINO::Version version, const DeviceInfo& deviceInfo, UsbSpeed maxUsbSpeed){ - py::gil_scoped_release release; - return std::make_unique(version, deviceInfo, maxUsbSpeed); - }), py::arg("version"), py::arg("deviceInfo"), py::arg("maxUsbSpeed"), DOC(dai, DeviceBase, DeviceBase, 16)) - .def(py::init([](OpenVINO::Version version, const DeviceInfo& deviceInfo, dai::Path pathToCmd){ - py::gil_scoped_release release; - return std::make_unique(version, deviceInfo, pathToCmd); - }), py::arg("version"), py::arg("deviceDesc"), py::arg("pathToCmd"), DOC(dai, DeviceBase, DeviceBase, 17)) - .def(py::init([](typename D::Config config){ - auto dev = deviceSearchHelper(); - py::gil_scoped_release release; - return std::make_unique(config, dev); - }), py::arg("config"), DOC(dai, DeviceBase, DeviceBase, 18)) - .def(py::init([](typename D::Config config, const DeviceInfo& deviceInfo){ - py::gil_scoped_release release; - return std::make_unique(config, deviceInfo); - }), py::arg("config"), py::arg("deviceInfo"), DOC(dai, DeviceBase, DeviceBase, 19)) - - // DeviceInfo version - .def(py::init([](const DeviceInfo& deviceInfo){ - py::gil_scoped_release release; - return std::make_unique(deviceInfo); - }), py::arg("deviceInfo"), DOC(dai, DeviceBase, DeviceBase, 20)) - .def(py::init([](const DeviceInfo& deviceInfo, UsbSpeed maxUsbSpeed){ - py::gil_scoped_release release; - return std::make_unique(deviceInfo, maxUsbSpeed); - }), py::arg("deviceInfo"), py::arg("maxUsbSpeed"), DOC(dai, DeviceBase, DeviceBase, 21)) - - // name or device id version - .def(py::init([](std::string nameOrDeviceId){ - py::gil_scoped_release release; - return std::make_unique(std::move(nameOrDeviceId)); - }), py::arg("nameOrDeviceId"), DOC(dai, DeviceBase, DeviceBase, 22)) - .def(py::init([](std::string nameOrDeviceId, UsbSpeed maxUsbSpeed){ - py::gil_scoped_release release; - return std::make_unique(std::move(nameOrDeviceId), maxUsbSpeed); - }), py::arg("nameOrDeviceId"), py::arg("maxUsbSpeed"), DOC(dai, DeviceBase, DeviceBase, 23)) - ; - + arg.def(py::init([](const Pipeline& pipeline) { + auto dev = deviceSearchHelper(); + py::gil_scoped_release release; + return std::make_unique(pipeline, dev); + }), + py::arg("pipeline"), + DOC(dai, DeviceBase, DeviceBase)) + .def(py::init([](const Pipeline& pipeline, bool usb2Mode) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Use constructor taking 'UsbSpeed' instead", 1); + auto dev = deviceSearchHelper(); + py::gil_scoped_release release; + return std::make_unique(pipeline, dev, usb2Mode); + }), + py::arg("pipeline"), + py::arg("usb2Mode"), + DOC(dai, DeviceBase, DeviceBase, 2)) + .def(py::init([](const Pipeline& pipeline, UsbSpeed maxUsbSpeed) { + auto dev = deviceSearchHelper(); + py::gil_scoped_release release; + return std::make_unique(pipeline, dev, maxUsbSpeed); + }), + py::arg("pipeline"), + py::arg("maxUsbSpeed"), + DOC(dai, DeviceBase, DeviceBase, 3)) + .def(py::init([](const Pipeline& pipeline, const dai::Path& pathToCmd) { + auto dev = deviceSearchHelper(); + py::gil_scoped_release release; + return std::make_unique(pipeline, dev, pathToCmd); + }), + py::arg("pipeline"), + py::arg("pathToCmd"), + DOC(dai, DeviceBase, DeviceBase, 4)) + .def(py::init([](const Pipeline& pipeline, const DeviceInfo& deviceInfo, bool usb2Mode) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Use constructor taking 'UsbSpeed' instead", 1); + py::gil_scoped_release release; + return std::make_unique(pipeline, deviceInfo, usb2Mode); + }), + py::arg("pipeline"), + py::arg("devInfo"), + py::arg("usb2Mode") = false, + DOC(dai, DeviceBase, DeviceBase, 6)) + .def(py::init([](const Pipeline& pipeline, const DeviceInfo& deviceInfo, UsbSpeed maxUsbSpeed) { + py::gil_scoped_release release; + return std::make_unique(pipeline, deviceInfo, maxUsbSpeed); + }), + py::arg("pipeline"), + py::arg("deviceInfo"), + py::arg("maxUsbSpeed"), + DOC(dai, DeviceBase, DeviceBase, 7)) + .def(py::init([](const Pipeline& pipeline, const DeviceInfo& deviceInfo, dai::Path pathToCmd) { + py::gil_scoped_release release; + return std::make_unique(pipeline, deviceInfo, pathToCmd); + }), + py::arg("pipeline"), + py::arg("devInfo"), + py::arg("pathToCmd"), + DOC(dai, DeviceBase, DeviceBase, 8)) + + // DeviceBase constructor - OpenVINO version + .def(py::init([](OpenVINO::Version version) { + auto dev = deviceSearchHelper(); + py::gil_scoped_release release; + return std::make_unique(version, dev); + }), + py::arg("version") = OpenVINO::VERSION_UNIVERSAL, + DOC(dai, DeviceBase, DeviceBase, 10)) + .def(py::init([](OpenVINO::Version version, bool usb2Mode) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Use constructor taking 'UsbSpeed' instead", 1); + auto dev = deviceSearchHelper(); + py::gil_scoped_release release; + return std::make_unique(version, dev, usb2Mode); + }), + py::arg("version"), + py::arg("usb2Mode") = false, + DOC(dai, DeviceBase, DeviceBase, 11)) + .def(py::init([](OpenVINO::Version version, UsbSpeed maxUsbSpeed) { + auto dev = deviceSearchHelper(); + py::gil_scoped_release release; + return std::make_unique(version, dev, maxUsbSpeed); + }), + py::arg("version"), + py::arg("maxUsbSpeed"), + DOC(dai, DeviceBase, DeviceBase, 12)) + .def(py::init([](OpenVINO::Version version, const dai::Path& pathToCmd) { + auto dev = deviceSearchHelper(); + py::gil_scoped_release release; + return std::make_unique(version, dev, pathToCmd); + }), + py::arg("version"), + py::arg("pathToCmd"), + DOC(dai, DeviceBase, DeviceBase, 13)) + .def(py::init([](OpenVINO::Version version, const DeviceInfo& deviceInfo, bool usb2Mode) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Use constructor taking 'UsbSpeed' instead", 1); + py::gil_scoped_release release; + return std::make_unique(version, deviceInfo, usb2Mode); + }), + py::arg("version"), + py::arg("deviceInfo"), + py::arg("usb2Mode") = false, + DOC(dai, DeviceBase, DeviceBase, 15)) + .def(py::init([](OpenVINO::Version version, const DeviceInfo& deviceInfo, UsbSpeed maxUsbSpeed) { + py::gil_scoped_release release; + return std::make_unique(version, deviceInfo, maxUsbSpeed); + }), + py::arg("version"), + py::arg("deviceInfo"), + py::arg("maxUsbSpeed"), + DOC(dai, DeviceBase, DeviceBase, 16)) + .def(py::init([](OpenVINO::Version version, const DeviceInfo& deviceInfo, dai::Path pathToCmd) { + py::gil_scoped_release release; + return std::make_unique(version, deviceInfo, pathToCmd); + }), + py::arg("version"), + py::arg("deviceDesc"), + py::arg("pathToCmd"), + DOC(dai, DeviceBase, DeviceBase, 17)) + .def(py::init([](typename D::Config config) { + auto dev = deviceSearchHelper(); + py::gil_scoped_release release; + return std::make_unique(config, dev); + }), + py::arg("config"), + DOC(dai, DeviceBase, DeviceBase, 18)) + .def(py::init([](typename D::Config config, const DeviceInfo& deviceInfo) { + py::gil_scoped_release release; + return std::make_unique(config, deviceInfo); + }), + py::arg("config"), + py::arg("deviceInfo"), + DOC(dai, DeviceBase, DeviceBase, 19)) + + // DeviceInfo version + .def(py::init([](const DeviceInfo& deviceInfo) { + py::gil_scoped_release release; + return std::make_unique(deviceInfo); + }), + py::arg("deviceInfo"), + DOC(dai, DeviceBase, DeviceBase, 20)) + .def(py::init([](const DeviceInfo& deviceInfo, UsbSpeed maxUsbSpeed) { + py::gil_scoped_release release; + return std::make_unique(deviceInfo, maxUsbSpeed); + }), + py::arg("deviceInfo"), + py::arg("maxUsbSpeed"), + DOC(dai, DeviceBase, DeviceBase, 21)) + + // name or device id version + .def(py::init([](std::string nameOrDeviceId) { + py::gil_scoped_release release; + return std::make_unique(std::move(nameOrDeviceId)); + }), + py::arg("nameOrDeviceId"), + DOC(dai, DeviceBase, DeviceBase, 22)) + .def(py::init([](std::string nameOrDeviceId, UsbSpeed maxUsbSpeed) { + py::gil_scoped_release release; + return std::make_unique(std::move(nameOrDeviceId), maxUsbSpeed); + }), + py::arg("nameOrDeviceId"), + py::arg("maxUsbSpeed"), + DOC(dai, DeviceBase, DeviceBase, 23)); } - - -void DeviceBindings::bind(pybind11::module& m, void* pCallstack){ - +void DeviceBindings::bind(pybind11::module& m, void* pCallstack) { using namespace dai; // Type definitions @@ -194,10 +247,13 @@ void DeviceBindings::bind(pybind11::module& m, void* pCallstack){ py::class_ crashDump(m, "CrashDump", DOC(dai, CrashDump)); py::class_ crashReport(crashDump, "CrashReport", DOC(dai, CrashDump, CrashReport)); py::class_ errorSourceInfo(crashReport, "ErrorSourceInfo", DOC(dai, CrashDump, CrashReport, ErrorSourceInfo)); - py::class_ assertContext(errorSourceInfo, "AssertContext", DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, AssertContext)); - py::class_ trapContext(errorSourceInfo, "TrapContext", DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, TrapContext)); + py::class_ assertContext( + errorSourceInfo, "AssertContext", DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, AssertContext)); + py::class_ trapContext( + errorSourceInfo, "TrapContext", DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, TrapContext)); py::class_ threadCallstack(crashReport, "ThreadCallstack", DOC(dai, CrashDump, CrashReport, ThreadCallstack)); - py::class_ callstackContext(threadCallstack, "CallstackContext", DOC(dai, CrashDump, CrashReport, ThreadCallstack, CallstackContext)); + py::class_ callstackContext( + threadCallstack, "CallstackContext", DOC(dai, CrashDump, CrashReport, ThreadCallstack, CallstackContext)); py::class_ boardConfig(m, "BoardConfig", DOC(dai, BoardConfig)); py::class_ boardConfigUsb(boardConfig, "USB", DOC(dai, BoardConfig, USB)); py::class_ boardConfigNetwork(boardConfig, "Network", DOC(dai, BoardConfig, Network)); @@ -211,10 +267,9 @@ void DeviceBindings::bind(pybind11::module& m, void* pCallstack){ py::class_ boardConfigUart(boardConfig, "UART", DOC(dai, BoardConfig, UART)); py::class_ boardConfigUvc(boardConfig, "UVC", DOC(dai, BoardConfig, UVC)); py::enum_ platform(m, "Platform", DOC(dai, Platform)); - struct PyClock{}; + struct PyClock {}; py::class_ clock(m, "Clock"); - py::bind_map>(boardConfig, "GPIOMap"); py::bind_map>(boardConfig, "UARTMap"); @@ -229,7 +284,7 @@ void DeviceBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -237,29 +292,23 @@ void DeviceBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// - // Bind BoardConfig::USB - boardConfigUsb - .def(py::init<>()) + boardConfigUsb.def(py::init<>()) .def_readwrite("vid", &BoardConfig::USB::vid) .def_readwrite("pid", &BoardConfig::USB::pid) .def_readwrite("flashBootedVid", &BoardConfig::USB::flashBootedVid) .def_readwrite("flashBootedPid", &BoardConfig::USB::flashBootedPid) .def_readwrite("maxSpeed", &BoardConfig::USB::maxSpeed) .def_readwrite("productName", &BoardConfig::USB::productName) - .def_readwrite("manufacturer", &BoardConfig::USB::manufacturer) - ; + .def_readwrite("manufacturer", &BoardConfig::USB::manufacturer); // Bind BoardConfig::Network - boardConfigNetwork - .def(py::init<>()) + boardConfigNetwork.def(py::init<>()) .def_readwrite("mtu", &BoardConfig::Network::mtu) - .def_readwrite("xlinkTcpNoDelay", &BoardConfig::Network::xlinkTcpNoDelay) - ; + .def_readwrite("xlinkTcpNoDelay", &BoardConfig::Network::xlinkTcpNoDelay); // GPIO Mode - boardConfigGpioMode - .value("ALT_MODE_0", BoardConfig::GPIO::ALT_MODE_0, DOC(dai, BoardConfig, GPIO, Mode, ALT_MODE_0)) + boardConfigGpioMode.value("ALT_MODE_0", BoardConfig::GPIO::ALT_MODE_0, DOC(dai, BoardConfig, GPIO, Mode, ALT_MODE_0)) .value("ALT_MODE_1", BoardConfig::GPIO::ALT_MODE_1, DOC(dai, BoardConfig, GPIO, Mode, ALT_MODE_1)) .value("ALT_MODE_2", BoardConfig::GPIO::ALT_MODE_2, DOC(dai, BoardConfig, GPIO, Mode, ALT_MODE_2)) .value("ALT_MODE_3", BoardConfig::GPIO::ALT_MODE_3, DOC(dai, BoardConfig, GPIO, Mode, ALT_MODE_3)) @@ -267,44 +316,34 @@ void DeviceBindings::bind(pybind11::module& m, void* pCallstack){ .value("ALT_MODE_5", BoardConfig::GPIO::ALT_MODE_5, DOC(dai, BoardConfig, GPIO, Mode, ALT_MODE_5)) .value("ALT_MODE_6", BoardConfig::GPIO::ALT_MODE_6, DOC(dai, BoardConfig, GPIO, Mode, ALT_MODE_6)) .value("DIRECT", BoardConfig::GPIO::DIRECT, DOC(dai, BoardConfig, GPIO, Mode, DIRECT)) - .export_values() - ; + .export_values(); // GPIO Direction - boardConfigGpioDirection - .value("INPUT", BoardConfig::GPIO::INPUT, DOC(dai, BoardConfig, GPIO, Direction, INPUT)) + boardConfigGpioDirection.value("INPUT", BoardConfig::GPIO::INPUT, DOC(dai, BoardConfig, GPIO, Direction, INPUT)) .value("OUTPUT", BoardConfig::GPIO::OUTPUT, DOC(dai, BoardConfig, GPIO, Direction, OUTPUT)) - .export_values() - ; + .export_values(); // GPIO Level - boardConfigGpioLevel - .value("LOW", BoardConfig::GPIO::LOW, DOC(dai, BoardConfig, GPIO, Level, LOW)) + boardConfigGpioLevel.value("LOW", BoardConfig::GPIO::LOW, DOC(dai, BoardConfig, GPIO, Level, LOW)) .value("HIGH", BoardConfig::GPIO::HIGH, DOC(dai, BoardConfig, GPIO, Level, HIGH)) - .export_values() - ; + .export_values(); // GPIO Pull - boardConfigGpioPull - .value("NO_PULL", BoardConfig::GPIO::NO_PULL, DOC(dai, BoardConfig, GPIO, Pull, NO_PULL)) + boardConfigGpioPull.value("NO_PULL", BoardConfig::GPIO::NO_PULL, DOC(dai, BoardConfig, GPIO, Pull, NO_PULL)) .value("PULL_UP", BoardConfig::GPIO::PULL_UP, DOC(dai, BoardConfig, GPIO, Pull, PULL_UP)) .value("PULL_DOWN", BoardConfig::GPIO::PULL_DOWN, DOC(dai, BoardConfig, GPIO, Pull, PULL_DOWN)) .value("BUS_KEEPER", BoardConfig::GPIO::BUS_KEEPER, DOC(dai, BoardConfig, GPIO, Pull, BUS_KEEPER)) - .export_values() - ; + .export_values(); // GPIO Drive - boardConfigGpioDrive - .value("MA_2", BoardConfig::GPIO::MA_2, DOC(dai, BoardConfig, GPIO, Drive, MA_2)) + boardConfigGpioDrive.value("MA_2", BoardConfig::GPIO::MA_2, DOC(dai, BoardConfig, GPIO, Drive, MA_2)) .value("MA_4", BoardConfig::GPIO::MA_4, DOC(dai, BoardConfig, GPIO, Drive, MA_4)) .value("MA_8", BoardConfig::GPIO::MA_8, DOC(dai, BoardConfig, GPIO, Drive, MA_8)) .value("MA_12", BoardConfig::GPIO::MA_12, DOC(dai, BoardConfig, GPIO, Drive, MA_12)) - .export_values() - ; + .export_values(); // Bind BoardConfig::GPIO - boardConfigGpio - .def(py::init<>()) + boardConfigGpio.def(py::init<>()) .def(py::init()) .def(py::init()) .def(py::init()) @@ -316,25 +355,19 @@ void DeviceBindings::bind(pybind11::module& m, void* pCallstack){ .def_readwrite("pull", &BoardConfig::GPIO::pull) .def_readwrite("drive", &BoardConfig::GPIO::drive) .def_readwrite("schmitt", &BoardConfig::GPIO::schmitt) - .def_readwrite("slewFast", &BoardConfig::GPIO::slewFast) - ; + .def_readwrite("slewFast", &BoardConfig::GPIO::slewFast); // Bind BoardConfig::UART - boardConfigUart - .def(py::init<>()) - .def_readwrite("tmp", &BoardConfig::UART::tmp) - ; + boardConfigUart.def(py::init<>()).def_readwrite("tmp", &BoardConfig::UART::tmp); // Bind BoardConfig::UVC - boardConfigUvc - .def(py::init<>()) + boardConfigUvc.def(py::init<>()) .def(py::init()) .def_readwrite("cameraName", &BoardConfig::UVC::cameraName) .def_readwrite("width", &BoardConfig::UVC::width) .def_readwrite("height", &BoardConfig::UVC::height) .def_readwrite("frameType", &BoardConfig::UVC::frameType) - .def_readwrite("enable", &BoardConfig::UVC::enable) - ; + .def_readwrite("enable", &BoardConfig::UVC::enable); // Bind Platform platform.value("RVC2", Platform::RVC2, DOC(dai, Platform, RVC2)) @@ -351,8 +384,7 @@ void DeviceBindings::bind(pybind11::module& m, void* pCallstack){ m.def("string2platform", &string2platform, DOC(dai, string2platform)); // Bind BoardConfig - boardConfig - .def(py::init<>()) + boardConfig.def(py::init<>()) .def_readwrite("usb", &BoardConfig::usb, DOC(dai, BoardConfig, usb)) .def_readwrite("network", &BoardConfig::network, DOC(dai, BoardConfig, network)) .def_readwrite("sysctl", &BoardConfig::sysctl, DOC(dai, BoardConfig, sysctl)) @@ -368,77 +400,82 @@ void DeviceBindings::bind(pybind11::module& m, void* pCallstack){ .def_readwrite("logSizeMax", &BoardConfig::logSizeMax, DOC(dai, BoardConfig, logSizeMax)) .def_readwrite("logVerbosity", &BoardConfig::logVerbosity, DOC(dai, BoardConfig, logVerbosity)) .def_readwrite("logDevicePrints", &BoardConfig::logDevicePrints, DOC(dai, BoardConfig, logDevicePrints)) - .def_readwrite("uvc", &BoardConfig::uvc, DOC(dai, BoardConfig, uvc)) - ; + .def_readwrite("uvc", &BoardConfig::uvc, DOC(dai, BoardConfig, uvc)); // Bind Device::Config - deviceConfig - .def(py::init<>()) + deviceConfig.def(py::init<>()) .def_readwrite("version", &Device::Config::version) .def_readwrite("board", &Device::Config::board) .def_readwrite("nonExclusiveMode", &Device::Config::nonExclusiveMode) .def_readwrite("outputLogLevel", &Device::Config::outputLogLevel) - .def_readwrite("logLevel", &Device::Config::logLevel) - ; + .def_readwrite("logLevel", &Device::Config::logLevel); // Bind CrashDump - crashDump - .def(py::init<>()) + crashDump.def(py::init<>()) .def("serializeToJson", &CrashDump::serializeToJson, DOC(dai, CrashDump, serializeToJson)) .def_readwrite("crashReports", &CrashDump::crashReports, DOC(dai, CrashDump, crashReports)) .def_readwrite("depthaiCommitHash", &CrashDump::depthaiCommitHash, DOC(dai, CrashDump, depthaiCommitHash)) - .def_readwrite("deviceId", &CrashDump::deviceId, DOC(dai, CrashDump, deviceId)) - ; + .def_readwrite("deviceId", &CrashDump::deviceId, DOC(dai, CrashDump, deviceId)); - crashReport - .def(py::init<>()) + crashReport.def(py::init<>()) .def_readwrite("processor", &CrashDump::CrashReport::processor, DOC(dai, CrashDump, CrashReport, processor)) .def_readwrite("errorSource", &CrashDump::CrashReport::errorSource, DOC(dai, CrashDump, CrashReport, errorSource)) .def_readwrite("crashedThreadId", &CrashDump::CrashReport::crashedThreadId, DOC(dai, CrashDump, CrashReport, crashedThreadId)) - .def_readwrite("threadCallstack", &CrashDump::CrashReport::threadCallstack, DOC(dai, CrashDump, CrashReport, threadCallstack)) - ; + .def_readwrite("threadCallstack", &CrashDump::CrashReport::threadCallstack, DOC(dai, CrashDump, CrashReport, threadCallstack)); - errorSourceInfo - .def(py::init<>()) - .def_readwrite("assertContext", &CrashDump::CrashReport::ErrorSourceInfo::assertContext, DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, assertContext)) + errorSourceInfo.def(py::init<>()) + .def_readwrite( + "assertContext", &CrashDump::CrashReport::ErrorSourceInfo::assertContext, DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, assertContext)) .def_readwrite("trapContext", &CrashDump::CrashReport::ErrorSourceInfo::trapContext, DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, trapContext)) - .def_readwrite("errorId", &CrashDump::CrashReport::ErrorSourceInfo::errorId, DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, errorId)) - ; - - assertContext - .def(py::init<>()) - .def_readwrite("fileName", &CrashDump::CrashReport::ErrorSourceInfo::AssertContext::fileName, DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, AssertContext, fileName)) - .def_readwrite("functionName", &CrashDump::CrashReport::ErrorSourceInfo::AssertContext::functionName, DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, AssertContext, functionName)) - .def_readwrite("line", &CrashDump::CrashReport::ErrorSourceInfo::AssertContext::line, DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, AssertContext, line)) - ; - - trapContext - .def(py::init<>()) - .def_readwrite("trapNumber", &CrashDump::CrashReport::ErrorSourceInfo::TrapContext::trapNumber, DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, TrapContext, trapNumber)) - .def_readwrite("trapAddress", &CrashDump::CrashReport::ErrorSourceInfo::TrapContext::trapAddress, DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, TrapContext, trapAddress)) - .def_readwrite("trapName", &CrashDump::CrashReport::ErrorSourceInfo::TrapContext::trapName, DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, TrapContext, trapName)) - ; - - threadCallstack - .def(py::init<>()) + .def_readwrite("errorId", &CrashDump::CrashReport::ErrorSourceInfo::errorId, DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, errorId)); + + assertContext.def(py::init<>()) + .def_readwrite("fileName", + &CrashDump::CrashReport::ErrorSourceInfo::AssertContext::fileName, + DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, AssertContext, fileName)) + .def_readwrite("functionName", + &CrashDump::CrashReport::ErrorSourceInfo::AssertContext::functionName, + DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, AssertContext, functionName)) + .def_readwrite( + "line", &CrashDump::CrashReport::ErrorSourceInfo::AssertContext::line, DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, AssertContext, line)); + + trapContext.def(py::init<>()) + .def_readwrite("trapNumber", + &CrashDump::CrashReport::ErrorSourceInfo::TrapContext::trapNumber, + DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, TrapContext, trapNumber)) + .def_readwrite("trapAddress", + &CrashDump::CrashReport::ErrorSourceInfo::TrapContext::trapAddress, + DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, TrapContext, trapAddress)) + .def_readwrite("trapName", + &CrashDump::CrashReport::ErrorSourceInfo::TrapContext::trapName, + DOC(dai, CrashDump, CrashReport, ErrorSourceInfo, TrapContext, trapName)); + + threadCallstack.def(py::init<>()) .def_readwrite("threadId", &CrashDump::CrashReport::ThreadCallstack::threadId, DOC(dai, CrashDump, CrashReport, ThreadCallstack, threadId)) .def_readwrite("threadName", &CrashDump::CrashReport::ThreadCallstack::threadName, DOC(dai, CrashDump, CrashReport, ThreadCallstack, threadName)) .def_readwrite("stackBottom", &CrashDump::CrashReport::ThreadCallstack::stackBottom, DOC(dai, CrashDump, CrashReport, ThreadCallstack, stackBottom)) .def_readwrite("stackTop", &CrashDump::CrashReport::ThreadCallstack::stackTop, DOC(dai, CrashDump, CrashReport, ThreadCallstack, stackTop)) .def_readwrite("stackPointer", &CrashDump::CrashReport::ThreadCallstack::stackPointer, DOC(dai, CrashDump, CrashReport, ThreadCallstack, stackPointer)) - .def_readwrite("instructionPointer", &CrashDump::CrashReport::ThreadCallstack::instructionPointer, DOC(dai, CrashDump, CrashReport, ThreadCallstack, instructionPointer)) + .def_readwrite("instructionPointer", + &CrashDump::CrashReport::ThreadCallstack::instructionPointer, + DOC(dai, CrashDump, CrashReport, ThreadCallstack, instructionPointer)) .def_readwrite("threadStatus", &CrashDump::CrashReport::ThreadCallstack::threadStatus, DOC(dai, CrashDump, CrashReport, ThreadCallstack, threadStatus)) - .def_readwrite("callStack", &CrashDump::CrashReport::ThreadCallstack::callStack, DOC(dai, CrashDump, CrashReport, ThreadCallstack, callStack)) - ; - - callstackContext - .def(py::init<>()) - .def_readwrite("callSite", &CrashDump::CrashReport::ThreadCallstack::CallstackContext::callSite, DOC(dai, CrashDump, CrashReport, ThreadCallstack, CallstackContext, callSite)) - .def_readwrite("calledTarget", &CrashDump::CrashReport::ThreadCallstack::CallstackContext::calledTarget, DOC(dai, CrashDump, CrashReport, ThreadCallstack, CallstackContext, calledTarget)) - .def_readwrite("framePointer", &CrashDump::CrashReport::ThreadCallstack::CallstackContext::framePointer, DOC(dai, CrashDump, CrashReport, ThreadCallstack, CallstackContext, framePointer)) - .def_readwrite("context", &CrashDump::CrashReport::ThreadCallstack::CallstackContext::context, DOC(dai, CrashDump, CrashReport, ThreadCallstack, CallstackContext, context)) - ; + .def_readwrite("callStack", &CrashDump::CrashReport::ThreadCallstack::callStack, DOC(dai, CrashDump, CrashReport, ThreadCallstack, callStack)); + + callstackContext.def(py::init<>()) + .def_readwrite("callSite", + &CrashDump::CrashReport::ThreadCallstack::CallstackContext::callSite, + DOC(dai, CrashDump, CrashReport, ThreadCallstack, CallstackContext, callSite)) + .def_readwrite("calledTarget", + &CrashDump::CrashReport::ThreadCallstack::CallstackContext::calledTarget, + DOC(dai, CrashDump, CrashReport, ThreadCallstack, CallstackContext, calledTarget)) + .def_readwrite("framePointer", + &CrashDump::CrashReport::ThreadCallstack::CallstackContext::framePointer, + DOC(dai, CrashDump, CrashReport, ThreadCallstack, CallstackContext, framePointer)) + .def_readwrite("context", + &CrashDump::CrashReport::ThreadCallstack::CallstackContext::context, + DOC(dai, CrashDump, CrashReport, ThreadCallstack, CallstackContext, context)); // Bind constructors bindConstructors(deviceBase); @@ -446,152 +483,558 @@ void DeviceBindings::bind(pybind11::module& m, void* pCallstack){ deviceBase // Python only methods .def("__enter__", [](DeviceBase& d) -> DeviceBase& { return d; }) - .def("__exit__", [](DeviceBase& d, py::object type, py::object value, py::object traceback) { - py::gil_scoped_release release; - d.close(); - }) - .def("close", [](DeviceBase& d) { py::gil_scoped_release release; d.close(); }, "Closes the connection to device. Better alternative is the usage of context manager: `with depthai.Device(pipeline) as device:`") - .def("isClosed", [](DeviceBase& d) { py::gil_scoped_release release; return d.isClosed(); }, DOC(dai, DeviceBase, isClosed)) - .def("setMaxReconnectionAttempts", &DeviceBase::setMaxReconnectionAttempts, py::arg("maxAttempts"), py::arg("callback") = py::none(), DOC(dai, DeviceBase, setMaxReconnectionAttempts)) - - //dai::Device methods - //static - .def_static("getAnyAvailableDevice", [](std::chrono::milliseconds ms){ return DeviceBase::getAnyAvailableDevice(ms); }, py::arg("timeout"), DOC(dai, DeviceBase, getAnyAvailableDevice)) - .def_static("getAnyAvailableDevice", [](){ return DeviceBase::getAnyAvailableDevice(); }, DOC(dai, DeviceBase, getAnyAvailableDevice, 2)) - .def_static("getFirstAvailableDevice", &DeviceBase::getFirstAvailableDevice, py::arg("skipInvalidDevices") = true, DOC(dai, DeviceBase, getFirstAvailableDevice)) + .def("__exit__", + [](DeviceBase& d, py::object type, py::object value, py::object traceback) { + py::gil_scoped_release release; + d.close(); + }) + .def( + "close", + [](DeviceBase& d) { + py::gil_scoped_release release; + d.close(); + }, + "Closes the connection to device. Better alternative is the usage of context manager: `with depthai.Device(pipeline) as device:`") + .def( + "isClosed", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.isClosed(); + }, + DOC(dai, DeviceBase, isClosed)) + .def("setMaxReconnectionAttempts", + &DeviceBase::setMaxReconnectionAttempts, + py::arg("maxAttempts"), + py::arg("callback") = py::none(), + DOC(dai, DeviceBase, setMaxReconnectionAttempts)) + + // dai::Device methods + // static + .def_static( + "getAnyAvailableDevice", + [](std::chrono::milliseconds ms) { return DeviceBase::getAnyAvailableDevice(ms); }, + py::arg("timeout"), + DOC(dai, DeviceBase, getAnyAvailableDevice)) + .def_static( + "getAnyAvailableDevice", []() { return DeviceBase::getAnyAvailableDevice(); }, DOC(dai, DeviceBase, getAnyAvailableDevice, 2)) + .def_static("getFirstAvailableDevice", + &DeviceBase::getFirstAvailableDevice, + py::arg("skipInvalidDevices") = true, + DOC(dai, DeviceBase, getFirstAvailableDevice)) .def_static("getAllAvailableDevices", &DeviceBase::getAllAvailableDevices, DOC(dai, DeviceBase, getAllAvailableDevices)) - .def_static("getEmbeddedDeviceBinary", py::overload_cast(&DeviceBase::getEmbeddedDeviceBinary), py::arg("usb2Mode"), py::arg("version") = OpenVINO::VERSION_UNIVERSAL, DOC(dai, DeviceBase, getEmbeddedDeviceBinary)) - .def_static("getEmbeddedDeviceBinary", py::overload_cast(&DeviceBase::getEmbeddedDeviceBinary), py::arg("config"), DOC(dai, DeviceBase, getEmbeddedDeviceBinary, 2)) + .def_static("getEmbeddedDeviceBinary", + py::overload_cast(&DeviceBase::getEmbeddedDeviceBinary), + py::arg("usb2Mode"), + py::arg("version") = OpenVINO::VERSION_UNIVERSAL, + DOC(dai, DeviceBase, getEmbeddedDeviceBinary)) + .def_static("getEmbeddedDeviceBinary", + py::overload_cast(&DeviceBase::getEmbeddedDeviceBinary), + py::arg("config"), + DOC(dai, DeviceBase, getEmbeddedDeviceBinary, 2)) .def_static("getDeviceById", &DeviceBase::getDeviceById, py::arg("deviceId"), DOC(dai, DeviceBase, getDeviceById)) .def_static("getAllConnectedDevices", &DeviceBase::getAllConnectedDevices, DOC(dai, DeviceBase, getAllConnectedDevices)) .def_static("getGlobalProfilingData", &DeviceBase::getGlobalProfilingData, DOC(dai, DeviceBase, getGlobalProfilingData)) // methods .def("getBootloaderVersion", &DeviceBase::getBootloaderVersion, DOC(dai, DeviceBase, getBootloaderVersion)) - .def("isPipelineRunning", [](DeviceBase& d) { py::gil_scoped_release release; return d.isPipelineRunning(); }, DOC(dai, DeviceBase, isPipelineRunning)) - .def("startPipeline", [](DeviceBase& d){ - // Issue an deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "Device(pipeline) starts the pipeline automatically. Use Device() and startPipeline(pipeline) otherwise", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - py::gil_scoped_release release; - d.startPipeline(); - HEDLEY_DIAGNOSTIC_POP - }, DOC(dai, DeviceBase, startPipeline)) - .def("startPipeline", [](DeviceBase& d, const Pipeline& pipeline) { py::gil_scoped_release release; return d.startPipeline(pipeline); }, DOC(dai, DeviceBase, startPipeline, 2)) + .def( + "isPipelineRunning", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.isPipelineRunning(); + }, + DOC(dai, DeviceBase, isPipelineRunning)) + .def( + "startPipeline", + [](DeviceBase& d) { + // Issue an deprecation warning + PyErr_WarnEx( + PyExc_DeprecationWarning, "Device(pipeline) starts the pipeline automatically. Use Device() and startPipeline(pipeline) otherwise", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + py::gil_scoped_release release; + d.startPipeline(); + HEDLEY_DIAGNOSTIC_POP + }, + DOC(dai, DeviceBase, startPipeline)) + .def( + "startPipeline", + [](DeviceBase& d, const Pipeline& pipeline) { + py::gil_scoped_release release; + return d.startPipeline(pipeline); + }, + DOC(dai, DeviceBase, startPipeline, 2)) // Doesn't require GIL release (eg, don't do RPC or long blocking things in background) .def("setLogOutputLevel", &DeviceBase::setLogOutputLevel, py::arg("level"), DOC(dai, DeviceBase, setLogOutputLevel)) .def("getLogOutputLevel", &DeviceBase::getLogOutputLevel, DOC(dai, DeviceBase, getLogOutputLevel)) // Requires GIL release - .def("setLogLevel", [](DeviceBase& d, LogLevel l) { py::gil_scoped_release release; d.setLogLevel(l); }, py::arg("level"), DOC(dai, DeviceBase, setLogLevel)) - .def("getLogLevel", [](DeviceBase& d) { py::gil_scoped_release release; return d.getLogLevel(); }, DOC(dai, DeviceBase, getLogLevel)) - .def("setSystemInformationLoggingRate", [](DeviceBase& d, float hz) { py::gil_scoped_release release; d.setSystemInformationLoggingRate(hz); }, py::arg("rateHz"), DOC(dai, DeviceBase, setSystemInformationLoggingRate)) - .def("getSystemInformationLoggingRate", [](DeviceBase& d) { py::gil_scoped_release release; return d.getSystemInformationLoggingRate(); }, DOC(dai, DeviceBase, getSystemInformationLoggingRate)) - .def("getCrashDump", [](DeviceBase& d, bool clearCrashDump) { py::gil_scoped_release release; return d.getCrashDump(clearCrashDump); }, py::arg("clearCrashDump") = true, DOC(dai, DeviceBase, getCrashDump)) - .def("hasCrashDump", [](DeviceBase& d) { py::gil_scoped_release release; return d.hasCrashDump(); }, DOC(dai, DeviceBase, hasCrashDump)) - .def("getConnectedCameras", [](DeviceBase& d) { py::gil_scoped_release release; return d.getConnectedCameras(); }, DOC(dai, DeviceBase, getConnectedCameras)) - .def("getConnectionInterfaces", [](DeviceBase& d) { py::gil_scoped_release release; return d.getConnectionInterfaces(); }, DOC(dai, DeviceBase, getConnectionInterfaces)) - .def("getConnectedCameraFeatures", [](DeviceBase& d) { py::gil_scoped_release release; return d.getConnectedCameraFeatures(); }, DOC(dai, DeviceBase, getConnectedCameraFeatures)) - .def("getCameraSensorNames", [](DeviceBase& d) { py::gil_scoped_release release; return d.getCameraSensorNames(); }, DOC(dai, DeviceBase, getCameraSensorNames)) - .def("getStereoPairs", [](DeviceBase& d) { py::gil_scoped_release release; return d.getStereoPairs(); }, DOC(dai, DeviceBase, getStereoPairs)) - .def("getAvailableStereoPairs", [](DeviceBase& d) { py::gil_scoped_release release; return d.getAvailableStereoPairs(); }, DOC(dai, DeviceBase, getAvailableStereoPairs)) - .def("getConnectedIMU", [](DeviceBase& d) { py::gil_scoped_release release; return d.getConnectedIMU(); }, DOC(dai, DeviceBase, getConnectedIMU)) - .def("getIMUFirmwareVersion", [](DeviceBase& d) { py::gil_scoped_release release; return d.getIMUFirmwareVersion(); }, DOC(dai, DeviceBase, getIMUFirmwareVersion)) - .def("getEmbeddedIMUFirmwareVersion", [](DeviceBase& d) { py::gil_scoped_release release; return d.getEmbeddedIMUFirmwareVersion(); }, DOC(dai, DeviceBase, getEmbeddedIMUFirmwareVersion)) - .def("startIMUFirmwareUpdate", [](DeviceBase& d, bool forceUpdate) { py::gil_scoped_release release; return d.startIMUFirmwareUpdate(forceUpdate); }, py::arg("forceUpdate") = false, DOC(dai, DeviceBase, startIMUFirmwareUpdate)) - .def("getIMUFirmwareUpdateStatus", [](DeviceBase& d) { py::gil_scoped_release release; return d.getIMUFirmwareUpdateStatus(); }, DOC(dai, DeviceBase, getIMUFirmwareUpdateStatus)) - .def("getDdrMemoryUsage", [](DeviceBase& d) { py::gil_scoped_release release; return d.getDdrMemoryUsage(); }, DOC(dai, DeviceBase, getDdrMemoryUsage)) - .def("getCmxMemoryUsage", [](DeviceBase& d) { py::gil_scoped_release release; return d.getCmxMemoryUsage(); }, DOC(dai, DeviceBase, getCmxMemoryUsage)) - .def("getLeonCssHeapUsage", [](DeviceBase& d) { py::gil_scoped_release release; return d.getLeonCssHeapUsage(); }, DOC(dai, DeviceBase, getLeonCssHeapUsage)) - .def("getLeonMssHeapUsage", [](DeviceBase& d) { py::gil_scoped_release release; return d.getLeonMssHeapUsage(); }, DOC(dai, DeviceBase, getLeonMssHeapUsage)) - .def("getChipTemperature", [](DeviceBase& d) { py::gil_scoped_release release; return d.getChipTemperature(); }, DOC(dai, DeviceBase, getChipTemperature)) - .def("getLeonCssCpuUsage", [](DeviceBase& d) { py::gil_scoped_release release; return d.getLeonCssCpuUsage(); }, DOC(dai, DeviceBase, getLeonCssCpuUsage)) - .def("getLeonMssCpuUsage", [](DeviceBase& d) { py::gil_scoped_release release; return d.getLeonMssCpuUsage(); }, DOC(dai, DeviceBase, getLeonMssCpuUsage)) - .def("addLogCallback", [](DeviceBase& d, std::function callback) { py::gil_scoped_release release; return d.addLogCallback(callback); }, py::arg("callback"), DOC(dai, DeviceBase, addLogCallback)) - .def("removeLogCallback", [](DeviceBase& d, int cbId) { py::gil_scoped_release release; return d.removeLogCallback(cbId); }, py::arg("callbackId"), DOC(dai, DeviceBase, removeLogCallback)) - .def("getUsbSpeed", [](DeviceBase& d) { py::gil_scoped_release release; return d.getUsbSpeed(); }, DOC(dai, DeviceBase, getUsbSpeed)) - .def("getDeviceInfo", [](DeviceBase& d) { py::gil_scoped_release release; return d.getDeviceInfo(); }, DOC(dai, DeviceBase, getDeviceInfo)) - .def("getMxId", [](DeviceBase& d) { - PyErr_WarnEx(PyExc_DeprecationWarning, "Use getDeviceId() instead.", 1); - py::gil_scoped_release release; - return d.getMxId(); }, DOC(dai, DeviceBase, getMxId)) - .def("getDeviceId", [](DeviceBase& d) { py::gil_scoped_release release; - return d.getDeviceId(); }, DOC(dai, DeviceBase, getDeviceId)) - .def("getProfilingData", [](DeviceBase& d) { py::gil_scoped_release release; return d.getProfilingData(); }, DOC(dai, DeviceBase, getProfilingData)) - .def("readCalibration", [](DeviceBase& d) { py::gil_scoped_release release; return d.readCalibration(); }, DOC(dai, DeviceBase, readCalibration)) - .def("flashCalibration", [](DeviceBase& d, CalibrationHandler calibrationDataHandler) { py::gil_scoped_release release; return d.flashCalibration(calibrationDataHandler); }, py::arg("calibrationDataHandler"), DOC(dai, DeviceBase, flashCalibration)) - .def("setXLinkChunkSize", [](DeviceBase& d, int s) { py::gil_scoped_release release; d.setXLinkChunkSize(s); }, py::arg("sizeBytes"), DOC(dai, DeviceBase, setXLinkChunkSize)) - .def("getXLinkChunkSize", [](DeviceBase& d) { py::gil_scoped_release release; return d.getXLinkChunkSize(); }, DOC(dai, DeviceBase, getXLinkChunkSize)) - .def("setIrLaserDotProjectorBrightness", [](DeviceBase& d, float mA, int mask) { - PyErr_WarnEx(PyExc_DeprecationWarning, "Use setIrLaserDotProjectorIntensity() instead.", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - py::gil_scoped_release release; - bool result = d.setIrLaserDotProjectorBrightness(mA, mask); - HEDLEY_DIAGNOSTIC_POP - return result; - }, py::arg("mA"), py::arg("mask") = -1, DOC(dai, DeviceBase, setIrLaserDotProjectorBrightness)) - .def("setIrFloodLightBrightness", [](DeviceBase& d, float mA, int mask) { - PyErr_WarnEx(PyExc_DeprecationWarning, "Use setIrFloodLightIntensity() instead.", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - py::gil_scoped_release release; - bool result = d.setIrFloodLightBrightness(mA, mask); - HEDLEY_DIAGNOSTIC_POP - return result; - }, py::arg("mA"), py::arg("mask") = -1, DOC(dai, DeviceBase, setIrFloodLightBrightness)) - .def("setIrLaserDotProjectorIntensity", [](DeviceBase& d, float intensity, int mask) { py::gil_scoped_release release; return d.setIrLaserDotProjectorIntensity(intensity, mask); }, py::arg("intensity"), py::arg("mask") = -1, DOC(dai, DeviceBase, setIrLaserDotProjectorIntensity)) - .def("setIrFloodLightIntensity", [](DeviceBase& d, float intensity, int mask) { py::gil_scoped_release release; return d.setIrFloodLightIntensity(intensity, mask); }, py::arg("intensity"), py::arg("mask") = -1, DOC(dai, DeviceBase, setIrFloodLightIntensity)) - .def("getIrDrivers", [](DeviceBase& d) { py::gil_scoped_release release; return d.getIrDrivers(); }, DOC(dai, DeviceBase, getIrDrivers)) - .def("isEepromAvailable", [](DeviceBase& d) { py::gil_scoped_release release; return d.isEepromAvailable(); }, DOC(dai, DeviceBase, isEepromAvailable)) - .def("flashCalibration2", [](DeviceBase& d, CalibrationHandler ch) { py::gil_scoped_release release; return d.flashCalibration2(ch); }, DOC(dai, DeviceBase, flashCalibration2)) - .def("readCalibration2", [](DeviceBase& d) { py::gil_scoped_release release; return d.readCalibration2(); }, DOC(dai, DeviceBase, readCalibration2)) - .def("readCalibrationOrDefault", [](DeviceBase& d) { py::gil_scoped_release release; return d.readCalibrationOrDefault(); }, DOC(dai, DeviceBase, readCalibrationOrDefault)) - .def("factoryResetCalibration", [](DeviceBase& d) { py::gil_scoped_release release; return d.factoryResetCalibration(); }, DOC(dai, DeviceBase, factoryResetCalibration)) - .def("flashFactoryCalibration", [](DeviceBase& d, CalibrationHandler ch) { py::gil_scoped_release release; return d.flashFactoryCalibration(ch); }, DOC(dai, DeviceBase, flashFactoryCalibration)) - .def("readFactoryCalibration", [](DeviceBase& d) { py::gil_scoped_release release; return d.readFactoryCalibration(); }, DOC(dai, DeviceBase, readFactoryCalibration)) - .def("readFactoryCalibrationOrDefault", [](DeviceBase& d) { py::gil_scoped_release release; return d.readFactoryCalibrationOrDefault(); }, DOC(dai, DeviceBase, readFactoryCalibrationOrDefault)) - .def("readCalibrationRaw", [](DeviceBase& d) { py::gil_scoped_release release; return d.readCalibrationRaw(); }, DOC(dai, DeviceBase, readCalibrationRaw)) - .def("readFactoryCalibrationRaw", [](DeviceBase& d) { py::gil_scoped_release release; return d.readFactoryCalibrationRaw(); }, DOC(dai, DeviceBase, readFactoryCalibrationRaw)) - .def("flashEepromClear", [](DeviceBase& d) { py::gil_scoped_release release; d.flashEepromClear(); }, DOC(dai, DeviceBase, flashEepromClear)) - .def("flashFactoryEepromClear", [](DeviceBase& d) { py::gil_scoped_release release; d.flashFactoryEepromClear(); }, DOC(dai, DeviceBase, flashFactoryEepromClear)) - .def("setTimesync", [](DeviceBase& d, std::chrono::milliseconds p, int s, bool r) { py::gil_scoped_release release; return d.setTimesync(p,s,r); }, DOC(dai, DeviceBase, setTimesync)) - .def("setTimesync", [](DeviceBase& d, bool e) { py::gil_scoped_release release; return d.setTimesync(e); }, py::arg("enable"), DOC(dai, DeviceBase, setTimesync, 2)) - .def("getDeviceName", [](DeviceBase& d) { std::string name; { py::gil_scoped_release release; name = d.getDeviceName(); } return py::bytes(name).attr("decode")("utf-8", "replace"); }, DOC(dai, DeviceBase, getDeviceName)) - .def("getProductName", [](DeviceBase& d) { std::string name; { py::gil_scoped_release release; name = d.getProductName(); } return py::bytes(name).attr("decode")("utf-8", "replace"); }, DOC(dai, DeviceBase, getProductName)) - .def("crashDevice", [](DeviceBase& d) { py::gil_scoped_release release; return d.crashDevice(); }, DOC(dai, DeviceBase, crashDevice)) - ; - + .def( + "setLogLevel", + [](DeviceBase& d, LogLevel l) { + py::gil_scoped_release release; + d.setLogLevel(l); + }, + py::arg("level"), + DOC(dai, DeviceBase, setLogLevel)) + .def( + "getLogLevel", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getLogLevel(); + }, + DOC(dai, DeviceBase, getLogLevel)) + .def( + "setSystemInformationLoggingRate", + [](DeviceBase& d, float hz) { + py::gil_scoped_release release; + d.setSystemInformationLoggingRate(hz); + }, + py::arg("rateHz"), + DOC(dai, DeviceBase, setSystemInformationLoggingRate)) + .def( + "getSystemInformationLoggingRate", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getSystemInformationLoggingRate(); + }, + DOC(dai, DeviceBase, getSystemInformationLoggingRate)) + .def( + "getCrashDump", + [](DeviceBase& d, bool clearCrashDump) { + py::gil_scoped_release release; + return d.getCrashDump(clearCrashDump); + }, + py::arg("clearCrashDump") = true, + DOC(dai, DeviceBase, getCrashDump)) + .def( + "hasCrashDump", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.hasCrashDump(); + }, + DOC(dai, DeviceBase, hasCrashDump)) + .def( + "getConnectedCameras", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getConnectedCameras(); + }, + DOC(dai, DeviceBase, getConnectedCameras)) + .def( + "getConnectionInterfaces", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getConnectionInterfaces(); + }, + DOC(dai, DeviceBase, getConnectionInterfaces)) + .def( + "getConnectedCameraFeatures", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getConnectedCameraFeatures(); + }, + DOC(dai, DeviceBase, getConnectedCameraFeatures)) + .def( + "getCameraSensorNames", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getCameraSensorNames(); + }, + DOC(dai, DeviceBase, getCameraSensorNames)) + .def( + "getStereoPairs", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getStereoPairs(); + }, + DOC(dai, DeviceBase, getStereoPairs)) + .def( + "getAvailableStereoPairs", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getAvailableStereoPairs(); + }, + DOC(dai, DeviceBase, getAvailableStereoPairs)) + .def( + "getConnectedIMU", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getConnectedIMU(); + }, + DOC(dai, DeviceBase, getConnectedIMU)) + .def( + "getIMUFirmwareVersion", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getIMUFirmwareVersion(); + }, + DOC(dai, DeviceBase, getIMUFirmwareVersion)) + .def( + "getEmbeddedIMUFirmwareVersion", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getEmbeddedIMUFirmwareVersion(); + }, + DOC(dai, DeviceBase, getEmbeddedIMUFirmwareVersion)) + .def( + "startIMUFirmwareUpdate", + [](DeviceBase& d, bool forceUpdate) { + py::gil_scoped_release release; + return d.startIMUFirmwareUpdate(forceUpdate); + }, + py::arg("forceUpdate") = false, + DOC(dai, DeviceBase, startIMUFirmwareUpdate)) + .def( + "getIMUFirmwareUpdateStatus", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getIMUFirmwareUpdateStatus(); + }, + DOC(dai, DeviceBase, getIMUFirmwareUpdateStatus)) + .def( + "getDdrMemoryUsage", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getDdrMemoryUsage(); + }, + DOC(dai, DeviceBase, getDdrMemoryUsage)) + .def( + "getCmxMemoryUsage", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getCmxMemoryUsage(); + }, + DOC(dai, DeviceBase, getCmxMemoryUsage)) + .def( + "getLeonCssHeapUsage", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getLeonCssHeapUsage(); + }, + DOC(dai, DeviceBase, getLeonCssHeapUsage)) + .def( + "getLeonMssHeapUsage", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getLeonMssHeapUsage(); + }, + DOC(dai, DeviceBase, getLeonMssHeapUsage)) + .def( + "getChipTemperature", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getChipTemperature(); + }, + DOC(dai, DeviceBase, getChipTemperature)) + .def( + "getLeonCssCpuUsage", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getLeonCssCpuUsage(); + }, + DOC(dai, DeviceBase, getLeonCssCpuUsage)) + .def( + "getLeonMssCpuUsage", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getLeonMssCpuUsage(); + }, + DOC(dai, DeviceBase, getLeonMssCpuUsage)) + .def( + "addLogCallback", + [](DeviceBase& d, std::function callback) { + py::gil_scoped_release release; + return d.addLogCallback(callback); + }, + py::arg("callback"), + DOC(dai, DeviceBase, addLogCallback)) + .def( + "removeLogCallback", + [](DeviceBase& d, int cbId) { + py::gil_scoped_release release; + return d.removeLogCallback(cbId); + }, + py::arg("callbackId"), + DOC(dai, DeviceBase, removeLogCallback)) + .def( + "getUsbSpeed", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getUsbSpeed(); + }, + DOC(dai, DeviceBase, getUsbSpeed)) + .def( + "getDeviceInfo", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getDeviceInfo(); + }, + DOC(dai, DeviceBase, getDeviceInfo)) + .def( + "getMxId", + [](DeviceBase& d) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Use getDeviceId() instead.", 1); + py::gil_scoped_release release; + return d.getMxId(); + }, + DOC(dai, DeviceBase, getMxId)) + .def( + "getDeviceId", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getDeviceId(); + }, + DOC(dai, DeviceBase, getDeviceId)) + .def( + "getProfilingData", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getProfilingData(); + }, + DOC(dai, DeviceBase, getProfilingData)) + .def( + "readCalibration", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.readCalibration(); + }, + DOC(dai, DeviceBase, readCalibration)) + .def( + "flashCalibration", + [](DeviceBase& d, CalibrationHandler calibrationDataHandler) { + py::gil_scoped_release release; + return d.flashCalibration(calibrationDataHandler); + }, + py::arg("calibrationDataHandler"), + DOC(dai, DeviceBase, flashCalibration)) + .def( + "setXLinkChunkSize", + [](DeviceBase& d, int s) { + py::gil_scoped_release release; + d.setXLinkChunkSize(s); + }, + py::arg("sizeBytes"), + DOC(dai, DeviceBase, setXLinkChunkSize)) + .def( + "getXLinkChunkSize", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getXLinkChunkSize(); + }, + DOC(dai, DeviceBase, getXLinkChunkSize)) + .def( + "setIrLaserDotProjectorBrightness", + [](DeviceBase& d, float mA, int mask) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Use setIrLaserDotProjectorIntensity() instead.", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + py::gil_scoped_release release; + bool result = d.setIrLaserDotProjectorBrightness(mA, mask); + HEDLEY_DIAGNOSTIC_POP + return result; + }, + py::arg("mA"), + py::arg("mask") = -1, + DOC(dai, DeviceBase, setIrLaserDotProjectorBrightness)) + .def( + "setIrFloodLightBrightness", + [](DeviceBase& d, float mA, int mask) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Use setIrFloodLightIntensity() instead.", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + py::gil_scoped_release release; + bool result = d.setIrFloodLightBrightness(mA, mask); + HEDLEY_DIAGNOSTIC_POP + return result; + }, + py::arg("mA"), + py::arg("mask") = -1, + DOC(dai, DeviceBase, setIrFloodLightBrightness)) + .def( + "setIrLaserDotProjectorIntensity", + [](DeviceBase& d, float intensity, int mask) { + py::gil_scoped_release release; + return d.setIrLaserDotProjectorIntensity(intensity, mask); + }, + py::arg("intensity"), + py::arg("mask") = -1, + DOC(dai, DeviceBase, setIrLaserDotProjectorIntensity)) + .def( + "setIrFloodLightIntensity", + [](DeviceBase& d, float intensity, int mask) { + py::gil_scoped_release release; + return d.setIrFloodLightIntensity(intensity, mask); + }, + py::arg("intensity"), + py::arg("mask") = -1, + DOC(dai, DeviceBase, setIrFloodLightIntensity)) + .def( + "getIrDrivers", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.getIrDrivers(); + }, + DOC(dai, DeviceBase, getIrDrivers)) + .def( + "isEepromAvailable", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.isEepromAvailable(); + }, + DOC(dai, DeviceBase, isEepromAvailable)) + .def( + "flashCalibration2", + [](DeviceBase& d, CalibrationHandler ch) { + py::gil_scoped_release release; + return d.flashCalibration2(ch); + }, + DOC(dai, DeviceBase, flashCalibration2)) + .def( + "readCalibration2", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.readCalibration2(); + }, + DOC(dai, DeviceBase, readCalibration2)) + .def( + "readCalibrationOrDefault", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.readCalibrationOrDefault(); + }, + DOC(dai, DeviceBase, readCalibrationOrDefault)) + .def( + "factoryResetCalibration", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.factoryResetCalibration(); + }, + DOC(dai, DeviceBase, factoryResetCalibration)) + .def( + "flashFactoryCalibration", + [](DeviceBase& d, CalibrationHandler ch) { + py::gil_scoped_release release; + return d.flashFactoryCalibration(ch); + }, + DOC(dai, DeviceBase, flashFactoryCalibration)) + .def( + "readFactoryCalibration", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.readFactoryCalibration(); + }, + DOC(dai, DeviceBase, readFactoryCalibration)) + .def( + "readFactoryCalibrationOrDefault", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.readFactoryCalibrationOrDefault(); + }, + DOC(dai, DeviceBase, readFactoryCalibrationOrDefault)) + .def( + "readCalibrationRaw", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.readCalibrationRaw(); + }, + DOC(dai, DeviceBase, readCalibrationRaw)) + .def( + "readFactoryCalibrationRaw", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.readFactoryCalibrationRaw(); + }, + DOC(dai, DeviceBase, readFactoryCalibrationRaw)) + .def( + "flashEepromClear", + [](DeviceBase& d) { + py::gil_scoped_release release; + d.flashEepromClear(); + }, + DOC(dai, DeviceBase, flashEepromClear)) + .def( + "flashFactoryEepromClear", + [](DeviceBase& d) { + py::gil_scoped_release release; + d.flashFactoryEepromClear(); + }, + DOC(dai, DeviceBase, flashFactoryEepromClear)) + .def( + "setTimesync", + [](DeviceBase& d, std::chrono::milliseconds p, int s, bool r) { + py::gil_scoped_release release; + return d.setTimesync(p, s, r); + }, + DOC(dai, DeviceBase, setTimesync)) + .def( + "setTimesync", + [](DeviceBase& d, bool e) { + py::gil_scoped_release release; + return d.setTimesync(e); + }, + py::arg("enable"), + DOC(dai, DeviceBase, setTimesync, 2)) + .def( + "getDeviceName", + [](DeviceBase& d) { + std::string name; + { + py::gil_scoped_release release; + name = d.getDeviceName(); + } + return py::bytes(name).attr("decode")("utf-8", "replace"); + }, + DOC(dai, DeviceBase, getDeviceName)) + .def( + "getProductName", + [](DeviceBase& d) { + std::string name; + { + py::gil_scoped_release release; + name = d.getProductName(); + } + return py::bytes(name).attr("decode")("utf-8", "replace"); + }, + DOC(dai, DeviceBase, getProductName)) + .def( + "crashDevice", + [](DeviceBase& d) { + py::gil_scoped_release release; + return d.crashDevice(); + }, + DOC(dai, DeviceBase, crashDevice)); // Bind constructors bindConstructors(device); - device - .def("getPlatform", &Device::getPlatform, DOC(dai, Device, getPlatform)) - .def("getPlatformAsString", &Device::getPlatformAsString, DOC(dai, Device, getPlatformAsString)) - ; + device.def("getPlatform", &Device::getPlatform, DOC(dai, Device, getPlatform)) + .def("getPlatformAsString", &Device::getPlatformAsString, DOC(dai, Device, getPlatformAsString)); // // Bind the rest // device - // .def("getOutputQueue", static_cast(Device::*)(const std::string&)>(&Device::getOutputQueue), py::arg("name"), DOC(dai, Device, getOutputQueue)) - // .def("getOutputQueue", static_cast(Device::*)(const std::string&, unsigned int, bool)>(&Device::getOutputQueue), py::arg("name"), py::arg("maxSize"), py::arg("blocking") = true, DOC(dai, Device, getOutputQueue, 2)) + // .def("getOutputQueue", static_cast(Device::*)(const std::string&)>(&Device::getOutputQueue), py::arg("name"), + // DOC(dai, Device, getOutputQueue)) .def("getOutputQueue", static_cast(Device::*)(const std::string&, unsigned int, + // bool)>(&Device::getOutputQueue), py::arg("name"), py::arg("maxSize"), py::arg("blocking") = true, DOC(dai, Device, getOutputQueue, 2)) // .def("getOutputQueueNames", &Device::getOutputQueueNames, DOC(dai, Device, getOutputQueueNames)) - // .def("getInputQueue", static_cast(Device::*)(const std::string&)>(&Device::getInputQueue), py::arg("name"), DOC(dai, Device, getInputQueue)) - // .def("getInputQueue", static_cast(Device::*)(const std::string&, unsigned int, bool)>(&Device::getInputQueue), py::arg("name"), py::arg("maxSize"), py::arg("blocking") = true, DOC(dai, Device, getInputQueue, 2)) + // .def("getInputQueue", static_cast(Device::*)(const std::string&)>(&Device::getInputQueue), py::arg("name"), DOC(dai, + // Device, getInputQueue)) .def("getInputQueue", static_cast(Device::*)(const std::string&, unsigned int, + // bool)>(&Device::getInputQueue), py::arg("name"), py::arg("maxSize"), py::arg("blocking") = true, DOC(dai, Device, getInputQueue, 2)) // .def("getInputQueueNames", &Device::getInputQueueNames, DOC(dai, Device, getInputQueueNames)) // .def("getQueueEvents", [](Device& d, const std::vector& queueNames, std::size_t maxNumEvents, std::chrono::microseconds timeout) { // return deviceGetQueueEventsHelper(d, queueNames, maxNumEvents, timeout); - // }, py::arg("queueNames"), py::arg("maxNumEvents") = std::numeric_limits::max(), py::arg("timeout") = std::chrono::microseconds(-1), DOC(dai, Device, getQueueEvents)) - // .def("getQueueEvents", [](Device& d, std::string queueName, std::size_t maxNumEvents, std::chrono::microseconds timeout) { + // }, py::arg("queueNames"), py::arg("maxNumEvents") = std::numeric_limits::max(), py::arg("timeout") = std::chrono::microseconds(-1), + // DOC(dai, Device, getQueueEvents)) .def("getQueueEvents", [](Device& d, std::string queueName, std::size_t maxNumEvents, std::chrono::microseconds + // timeout) { // return deviceGetQueueEventsHelper(d, std::vector{queueName}, maxNumEvents, timeout); - // }, py::arg("queueName"), py::arg("maxNumEvents") = std::numeric_limits::max(), py::arg("timeout") = std::chrono::microseconds(-1), DOC(dai, Device, getQueueEvents, 3)) - // .def("getQueueEvents", [](Device& d, std::size_t maxNumEvents, std::chrono::microseconds timeout) { + // }, py::arg("queueName"), py::arg("maxNumEvents") = std::numeric_limits::max(), py::arg("timeout") = std::chrono::microseconds(-1), + // DOC(dai, Device, getQueueEvents, 3)) .def("getQueueEvents", [](Device& d, std::size_t maxNumEvents, std::chrono::microseconds timeout) { // return deviceGetQueueEventsHelper(d, d.getOutputQueueNames(), maxNumEvents, timeout); - // }, py::arg("maxNumEvents") = std::numeric_limits::max(), py::arg("timeout") = std::chrono::microseconds(-1), DOC(dai, Device, getQueueEvents, 4)) + // }, py::arg("maxNumEvents") = std::numeric_limits::max(), py::arg("timeout") = std::chrono::microseconds(-1), DOC(dai, Device, + // getQueueEvents, 4)) // .def("getQueueEvent", [](Device& d, const std::vector& queueNames, std::chrono::microseconds timeout) { // auto events = deviceGetQueueEventsHelper(d, queueNames, std::numeric_limits::max(), timeout); @@ -611,10 +1054,9 @@ void DeviceBindings::bind(pybind11::module& m, void* pCallstack){ // return events[0]; // }, py::arg("timeout") = std::chrono::microseconds(-1), DOC(dai, Device, getQueueEvent, 4)) - //.def("setCallback", DeviceWrapper::wrap(&Device::setCallback), py::arg("name"), py::arg("callback")) + //.def("setCallback", DeviceWrapper::wrap(&Device::setCallback), py::arg("name"), py::arg("callback")) ; clock.def("now", &Clock::now); - } diff --git a/bindings/python/src/DeviceBootloaderBindings.cpp b/bindings/python/src/DeviceBootloaderBindings.cpp index b862c6f80..30acef56e 100644 --- a/bindings/python/src/DeviceBootloaderBindings.cpp +++ b/bindings/python/src/DeviceBootloaderBindings.cpp @@ -3,8 +3,7 @@ // depthai #include "depthai/device/DeviceBootloader.hpp" -void DeviceBootloaderBindings::bind(pybind11::module& m, void* pCallstack){ - +void DeviceBootloaderBindings::bind(pybind11::module& m, void* pCallstack) { using namespace dai; // Type definitions @@ -18,12 +17,11 @@ void DeviceBootloaderBindings::bind(pybind11::module& m, void* pCallstack){ py::class_ deviceBootloderApplicationInfo(deviceBootloader, "ApplicationInfo"); py::class_ deviceBootloderMemoryInfo(deviceBootloader, "MemoryInfo"); - /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -31,35 +29,25 @@ void DeviceBootloaderBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// - // Bind DeviceBootloader - deviceBootloaderType - .value("AUTO", DeviceBootloader::Type::AUTO) + deviceBootloaderType.value("AUTO", DeviceBootloader::Type::AUTO) .value("USB", DeviceBootloader::Type::USB) - .value("NETWORK", DeviceBootloader::Type::NETWORK) - ; - deviceBootloaderMemory - .value("AUTO", DeviceBootloader::Memory::AUTO) + .value("NETWORK", DeviceBootloader::Type::NETWORK); + deviceBootloaderMemory.value("AUTO", DeviceBootloader::Memory::AUTO) .value("FLASH", DeviceBootloader::Memory::FLASH) - .value("EMMC", DeviceBootloader::Memory::EMMC) - ; - deviceBootloaderSection - .value("AUTO", DeviceBootloader::Section::AUTO) + .value("EMMC", DeviceBootloader::Memory::EMMC); + deviceBootloaderSection.value("AUTO", DeviceBootloader::Section::AUTO) .value("HEADER", DeviceBootloader::Section::HEADER) .value("BOOTLOADER", DeviceBootloader::Section::BOOTLOADER) .value("BOOTLOADER_CONFIG", DeviceBootloader::Section::BOOTLOADER_CONFIG) - .value("APPLICATION", DeviceBootloader::Section::APPLICATION) - ; + .value("APPLICATION", DeviceBootloader::Section::APPLICATION); - deviceBootlaoderUsbConfig - .def(py::init<>()) + deviceBootlaoderUsbConfig.def(py::init<>()) .def_readwrite("timeoutMs", &DeviceBootloader::UsbConfig::timeoutMs) .def_readwrite("maxUsbSpeed", &DeviceBootloader::UsbConfig::maxUsbSpeed) .def_readwrite("vid", &DeviceBootloader::UsbConfig::vid) - .def_readwrite("pid", &DeviceBootloader::UsbConfig::pid) - ; - deviceBootlaoderNetworkConfig - .def(py::init<>()) + .def_readwrite("pid", &DeviceBootloader::UsbConfig::pid); + deviceBootlaoderNetworkConfig.def(py::init<>()) .def_readwrite("timeoutMs", &DeviceBootloader::NetworkConfig::timeoutMs) .def_readwrite("ipv4", &DeviceBootloader::NetworkConfig::ipv4) .def_readwrite("ipv4Mask", &DeviceBootloader::NetworkConfig::ipv4Mask) @@ -73,11 +61,9 @@ void DeviceBootloaderBindings::bind(pybind11::module& m, void* pCallstack){ .def_readwrite("ipv6Dns", &DeviceBootloader::NetworkConfig::ipv6Dns) .def_readwrite("ipv6DnsAlt", &DeviceBootloader::NetworkConfig::ipv6DnsAlt) .def_readwrite("staticIpv6", &DeviceBootloader::NetworkConfig::staticIpv6) - .def_readwrite("mac", &DeviceBootloader::NetworkConfig::mac) - ; + .def_readwrite("mac", &DeviceBootloader::NetworkConfig::mac); - deviceBootloderConfig - .def(py::init<>()) + deviceBootloderConfig.def(py::init<>()) .def_readwrite("appMem", &DeviceBootloader::Config::appMem) .def_readwrite("usb", &DeviceBootloader::Config::usb) .def_readwrite("network", &DeviceBootloader::Config::network) @@ -99,82 +85,377 @@ void DeviceBootloaderBindings::bind(pybind11::module& m, void* pCallstack){ .def("setUsbMaxSpeed", &DeviceBootloader::Config::setUsbMaxSpeed) .def("getUsbMaxSpeed", &DeviceBootloader::Config::getUsbMaxSpeed) .def("toJson", &DeviceBootloader::Config::toJson) - .def("fromJson", &DeviceBootloader::Config::fromJson) - ; + .def("fromJson", &DeviceBootloader::Config::fromJson); - deviceBootloderApplicationInfo - .def(py::init<>()) + deviceBootloderApplicationInfo.def(py::init<>()) .def_readwrite("hasApplication", &DeviceBootloader::ApplicationInfo::hasApplication) .def_readwrite("firmwareVersion", &DeviceBootloader::ApplicationInfo::firmwareVersion) - .def_readwrite("applicationName", &DeviceBootloader::ApplicationInfo::applicationName) - ; + .def_readwrite("applicationName", &DeviceBootloader::ApplicationInfo::applicationName); - deviceBootloderMemoryInfo - .def(py::init<>()) + deviceBootloderMemoryInfo.def(py::init<>()) .def_readwrite("available", &DeviceBootloader::MemoryInfo::available) .def_readwrite("size", &DeviceBootloader::MemoryInfo::size) - .def_readwrite("info", &DeviceBootloader::MemoryInfo::info) - ; + .def_readwrite("info", &DeviceBootloader::MemoryInfo::info); deviceBootloader - // Python only methods + // Python only methods .def("__enter__", [](DeviceBootloader& d) -> DeviceBootloader& { return d; }) .def("__exit__", [](DeviceBootloader& bl, py::object type, py::object value, py::object traceback) { bl.close(); }) - .def("close", &DeviceBootloader::close, "Closes the connection to device. Better alternative is the usage of context manager: `with depthai.DeviceBootloader(deviceInfo) as bootloader:`") + .def("close", + &DeviceBootloader::close, + "Closes the connection to device. Better alternative is the usage of context manager: `with depthai.DeviceBootloader(deviceInfo) as bootloader:`") .def_static("getFirstAvailableDevice", &DeviceBootloader::getFirstAvailableDevice, DOC(dai, DeviceBootloader, getFirstAvailableDevice)) .def_static("getAllAvailableDevices", &DeviceBootloader::getAllAvailableDevices, DOC(dai, DeviceBootloader, getAllAvailableDevices)) - .def_static("saveDepthaiApplicationPackage", py::overload_cast(&DeviceBootloader::saveDepthaiApplicationPackage), py::arg("path"), py::arg("pipeline"), py::arg("pathToCmd") = Path{}, py::arg("compress") = false, py::arg("applicationName") = "", py::arg("checkChecksum") = false, DOC(dai, DeviceBootloader, saveDepthaiApplicationPackage)) - .def_static("saveDepthaiApplicationPackage", py::overload_cast(&DeviceBootloader::saveDepthaiApplicationPackage), py::arg("path"), py::arg("pipeline"), py::arg("compress"), py::arg("applicationName") = "", py::arg("checkChecksum") = false, DOC(dai, DeviceBootloader, saveDepthaiApplicationPackage, 2)) - .def_static("createDepthaiApplicationPackage", py::overload_cast(&DeviceBootloader::createDepthaiApplicationPackage), py::arg("pipeline"), py::arg("pathToCmd") = Path{}, py::arg("compress") = false, py::arg("applicationName") = "", py::arg("checkChecksum") = false, DOC(dai, DeviceBootloader, createDepthaiApplicationPackage)) - .def_static("createDepthaiApplicationPackage", py::overload_cast(&DeviceBootloader::createDepthaiApplicationPackage), py::arg("pipeline"), py::arg("compress"), py::arg("applicationName") = "", py::arg("checkChecksum") = false, DOC(dai, DeviceBootloader, createDepthaiApplicationPackage, 2)) + .def_static("saveDepthaiApplicationPackage", + py::overload_cast(&DeviceBootloader::saveDepthaiApplicationPackage), + py::arg("path"), + py::arg("pipeline"), + py::arg("pathToCmd") = Path{}, + py::arg("compress") = false, + py::arg("applicationName") = "", + py::arg("checkChecksum") = false, + DOC(dai, DeviceBootloader, saveDepthaiApplicationPackage)) + .def_static("saveDepthaiApplicationPackage", + py::overload_cast(&DeviceBootloader::saveDepthaiApplicationPackage), + py::arg("path"), + py::arg("pipeline"), + py::arg("compress"), + py::arg("applicationName") = "", + py::arg("checkChecksum") = false, + DOC(dai, DeviceBootloader, saveDepthaiApplicationPackage, 2)) + .def_static("createDepthaiApplicationPackage", + py::overload_cast(&DeviceBootloader::createDepthaiApplicationPackage), + py::arg("pipeline"), + py::arg("pathToCmd") = Path{}, + py::arg("compress") = false, + py::arg("applicationName") = "", + py::arg("checkChecksum") = false, + DOC(dai, DeviceBootloader, createDepthaiApplicationPackage)) + .def_static("createDepthaiApplicationPackage", + py::overload_cast(&DeviceBootloader::createDepthaiApplicationPackage), + py::arg("pipeline"), + py::arg("compress"), + py::arg("applicationName") = "", + py::arg("checkChecksum") = false, + DOC(dai, DeviceBootloader, createDepthaiApplicationPackage, 2)) .def_static("getEmbeddedBootloaderVersion", &DeviceBootloader::getEmbeddedBootloaderVersion, DOC(dai, DeviceBootloader, getEmbeddedBootloaderVersion)) .def_static("getEmbeddedBootloaderBinary", &DeviceBootloader::getEmbeddedBootloaderBinary, DOC(dai, DeviceBootloader, getEmbeddedBootloaderBinary)) - .def(py::init(), py::arg("devInfo"), py::arg("allowFlashingBootloader") = false, DOC(dai, DeviceBootloader, DeviceBootloader, 4)) - .def(py::init(), py::arg("devInfo"), py::arg("pathToCmd"), py::arg("allowFlashingBootloader") = false, DOC(dai, DeviceBootloader, DeviceBootloader, 5)) - .def(py::init(), py::arg("nameOrDeviceId"), py::arg("allowFlashingBootloader") = false, DOC(dai, DeviceBootloader, DeviceBootloader, 6)) + .def(py::init(), + py::arg("devInfo"), + py::arg("allowFlashingBootloader") = false, + DOC(dai, DeviceBootloader, DeviceBootloader, 4)) + .def(py::init(), + py::arg("devInfo"), + py::arg("pathToCmd"), + py::arg("allowFlashingBootloader") = false, + DOC(dai, DeviceBootloader, DeviceBootloader, 5)) + .def(py::init(), + py::arg("nameOrDeviceId"), + py::arg("allowFlashingBootloader") = false, + DOC(dai, DeviceBootloader, DeviceBootloader, 6)) - .def("flash", [](DeviceBootloader& db, std::function progressCallback, const Pipeline& pipeline, bool compress, std::string applicationName, DeviceBootloader::Memory memory, bool checkChecksum) { py::gil_scoped_release release; return db.flash(progressCallback, pipeline, compress, applicationName, memory, checkChecksum); }, py::arg("progressCallback"), py::arg("pipeline"), py::arg("compress") = false, py::arg("applicationName") = "", py::arg("memory") = DeviceBootloader::Memory::AUTO, py::arg("checkChecksum") = false, DOC(dai, DeviceBootloader, flash)) - .def("flash", [](DeviceBootloader& db, const Pipeline& pipeline, bool compress, std::string applicationName, DeviceBootloader::Memory memory, bool checkChecksum) { py::gil_scoped_release release; return db.flash(pipeline, compress, applicationName, memory, checkChecksum); }, py::arg("pipeline"), py::arg("compress") = false, py::arg("applicationName") = "", py::arg("memory") = DeviceBootloader::Memory::AUTO, py::arg("checkChecksum") = false, DOC(dai, DeviceBootloader, flash, 2)) + .def( + "flash", + [](DeviceBootloader& db, + std::function progressCallback, + const Pipeline& pipeline, + bool compress, + std::string applicationName, + DeviceBootloader::Memory memory, + bool checkChecksum) { + py::gil_scoped_release release; + return db.flash(progressCallback, pipeline, compress, applicationName, memory, checkChecksum); + }, + py::arg("progressCallback"), + py::arg("pipeline"), + py::arg("compress") = false, + py::arg("applicationName") = "", + py::arg("memory") = DeviceBootloader::Memory::AUTO, + py::arg("checkChecksum") = false, + DOC(dai, DeviceBootloader, flash)) + .def( + "flash", + [](DeviceBootloader& db, + const Pipeline& pipeline, + bool compress, + std::string applicationName, + DeviceBootloader::Memory memory, + bool checkChecksum) { + py::gil_scoped_release release; + return db.flash(pipeline, compress, applicationName, memory, checkChecksum); + }, + py::arg("pipeline"), + py::arg("compress") = false, + py::arg("applicationName") = "", + py::arg("memory") = DeviceBootloader::Memory::AUTO, + py::arg("checkChecksum") = false, + DOC(dai, DeviceBootloader, flash, 2)) - .def("readApplicationInfo", [](DeviceBootloader& db, DeviceBootloader::Memory mem) { py::gil_scoped_release release; return db.readApplicationInfo(mem); }, py::arg("memory"), DOC(dai, DeviceBootloader, readApplicationInfo)) - .def("getMemoryInfo", [](DeviceBootloader& db, DeviceBootloader::Memory memory) { py::gil_scoped_release release; return db.getMemoryInfo(memory); }, DOC(dai, DeviceBootloader, getMemoryInfo)) - .def("isUserBootloader", [](DeviceBootloader& db) { py::gil_scoped_release release; return db.isUserBootloader(); }, DOC(dai, DeviceBootloader, isUserBootloader)) - .def("isUserBootloaderSupported", [](DeviceBootloader& db) { py::gil_scoped_release release; return db.isUserBootloaderSupported(); }, DOC(dai, DeviceBootloader, isUserBootloaderSupported)) + .def( + "readApplicationInfo", + [](DeviceBootloader& db, DeviceBootloader::Memory mem) { + py::gil_scoped_release release; + return db.readApplicationInfo(mem); + }, + py::arg("memory"), + DOC(dai, DeviceBootloader, readApplicationInfo)) + .def( + "getMemoryInfo", + [](DeviceBootloader& db, DeviceBootloader::Memory memory) { + py::gil_scoped_release release; + return db.getMemoryInfo(memory); + }, + DOC(dai, DeviceBootloader, getMemoryInfo)) + .def( + "isUserBootloader", + [](DeviceBootloader& db) { + py::gil_scoped_release release; + return db.isUserBootloader(); + }, + DOC(dai, DeviceBootloader, isUserBootloader)) + .def( + "isUserBootloaderSupported", + [](DeviceBootloader& db) { + py::gil_scoped_release release; + return db.isUserBootloaderSupported(); + }, + DOC(dai, DeviceBootloader, isUserBootloaderSupported)) - .def("flashDepthaiApplicationPackage", [](DeviceBootloader& db, std::function progressCallback, std::vector package, DeviceBootloader::Memory memory) { py::gil_scoped_release release; return db.flashDepthaiApplicationPackage(progressCallback, package); }, py::arg("progressCallback"), py::arg("package"), py::arg("memory") = DeviceBootloader::Memory::AUTO, DOC(dai, DeviceBootloader, flashDepthaiApplicationPackage)) - .def("flashDepthaiApplicationPackage", [](DeviceBootloader& db, std::vector package, DeviceBootloader::Memory memory) { py::gil_scoped_release release; return db.flashDepthaiApplicationPackage(package); }, py::arg("package"), py::arg("memory") = DeviceBootloader::Memory::AUTO, DOC(dai, DeviceBootloader, flashDepthaiApplicationPackage, 2)) - .def("flashBootloader", [](DeviceBootloader& db, std::function progressCallback, const Path& path) { py::gil_scoped_release release; return db.flashBootloader(progressCallback, path); }, py::arg("progressCallback"), py::arg("path") = "", DOC(dai, DeviceBootloader, flashBootloader)) - .def("flashBootloader", [](DeviceBootloader& db, DeviceBootloader::Memory memory, DeviceBootloader::Type type, std::function progressCallback, dai::Path path) { py::gil_scoped_release release; return db.flashBootloader(memory, type, progressCallback, path); }, py::arg("memory"), py::arg("type"), py::arg("progressCallback"), py::arg("path") = "", DOC(dai, DeviceBootloader, flashBootloader, 2)) - .def("flashUserBootloader", [](DeviceBootloader& db, std::function progressCallback, const Path& path) { py::gil_scoped_release release; return db.flashUserBootloader(progressCallback, path); }, py::arg("progressCallback"), py::arg("path") = "", DOC(dai, DeviceBootloader, flashUserBootloader)) + .def( + "flashDepthaiApplicationPackage", + [](DeviceBootloader& db, std::function progressCallback, std::vector package, DeviceBootloader::Memory memory) { + py::gil_scoped_release release; + return db.flashDepthaiApplicationPackage(progressCallback, package); + }, + py::arg("progressCallback"), + py::arg("package"), + py::arg("memory") = DeviceBootloader::Memory::AUTO, + DOC(dai, DeviceBootloader, flashDepthaiApplicationPackage)) + .def( + "flashDepthaiApplicationPackage", + [](DeviceBootloader& db, std::vector package, DeviceBootloader::Memory memory) { + py::gil_scoped_release release; + return db.flashDepthaiApplicationPackage(package); + }, + py::arg("package"), + py::arg("memory") = DeviceBootloader::Memory::AUTO, + DOC(dai, DeviceBootloader, flashDepthaiApplicationPackage, 2)) + .def( + "flashBootloader", + [](DeviceBootloader& db, std::function progressCallback, const Path& path) { + py::gil_scoped_release release; + return db.flashBootloader(progressCallback, path); + }, + py::arg("progressCallback"), + py::arg("path") = "", + DOC(dai, DeviceBootloader, flashBootloader)) + .def( + "flashBootloader", + [](DeviceBootloader& db, + DeviceBootloader::Memory memory, + DeviceBootloader::Type type, + std::function progressCallback, + dai::Path path) { + py::gil_scoped_release release; + return db.flashBootloader(memory, type, progressCallback, path); + }, + py::arg("memory"), + py::arg("type"), + py::arg("progressCallback"), + py::arg("path") = "", + DOC(dai, DeviceBootloader, flashBootloader, 2)) + .def( + "flashUserBootloader", + [](DeviceBootloader& db, std::function progressCallback, const Path& path) { + py::gil_scoped_release release; + return db.flashUserBootloader(progressCallback, path); + }, + py::arg("progressCallback"), + py::arg("path") = "", + DOC(dai, DeviceBootloader, flashUserBootloader)) - .def("readConfigData", [](DeviceBootloader& db, DeviceBootloader::Memory memory, DeviceBootloader::Type type) { py::gil_scoped_release release; return db.readConfigData(memory, type); }, py::arg("memory") = DeviceBootloader::Memory::AUTO, py::arg("type") = DeviceBootloader::Type::AUTO, DOC(dai, DeviceBootloader, readConfigData)) - .def("flashConfigData", [](DeviceBootloader& db, nlohmann::json configData, DeviceBootloader::Memory memory, DeviceBootloader::Type type) { py::gil_scoped_release release; return db.flashConfigData(configData, memory, type); }, py::arg("configData"), py::arg("memory") = DeviceBootloader::Memory::AUTO, py::arg("type") = DeviceBootloader::Type::AUTO, DOC(dai, DeviceBootloader, flashConfigData)) - .def("flashConfigFile", [](DeviceBootloader& db, dai::Path configPath, DeviceBootloader::Memory memory, DeviceBootloader::Type type) { py::gil_scoped_release release; return db.flashConfigFile(configPath, memory, type); }, py::arg("configData"), py::arg("memory") = DeviceBootloader::Memory::AUTO, py::arg("type") = DeviceBootloader::Type::AUTO, DOC(dai, DeviceBootloader, flashConfigFile)) - .def("flashConfigClear", [](DeviceBootloader& db, DeviceBootloader::Memory memory, DeviceBootloader::Type type) { py::gil_scoped_release release; return db.flashConfigClear(memory, type); }, py::arg("memory") = DeviceBootloader::Memory::AUTO, py::arg("type") = DeviceBootloader::Type::AUTO, DOC(dai, DeviceBootloader, flashConfigClear)) - .def("readConfig", [](DeviceBootloader& db, DeviceBootloader::Memory memory, DeviceBootloader::Type type) { py::gil_scoped_release release; return db.readConfig(memory, type); }, py::arg("memory") = DeviceBootloader::Memory::AUTO, py::arg("type") = DeviceBootloader::Type::AUTO, DOC(dai, DeviceBootloader, readConfig)) - .def("flashConfig", [](DeviceBootloader& db, const DeviceBootloader::Config& config, DeviceBootloader::Memory memory, DeviceBootloader::Type type) { py::gil_scoped_release release; return db.flashConfig(config, memory, type); }, py::arg("config"), py::arg("memory") = DeviceBootloader::Memory::AUTO, py::arg("type") = DeviceBootloader::Type::AUTO, DOC(dai, DeviceBootloader, flashConfig)) + .def( + "readConfigData", + [](DeviceBootloader& db, DeviceBootloader::Memory memory, DeviceBootloader::Type type) { + py::gil_scoped_release release; + return db.readConfigData(memory, type); + }, + py::arg("memory") = DeviceBootloader::Memory::AUTO, + py::arg("type") = DeviceBootloader::Type::AUTO, + DOC(dai, DeviceBootloader, readConfigData)) + .def( + "flashConfigData", + [](DeviceBootloader& db, nlohmann::json configData, DeviceBootloader::Memory memory, DeviceBootloader::Type type) { + py::gil_scoped_release release; + return db.flashConfigData(configData, memory, type); + }, + py::arg("configData"), + py::arg("memory") = DeviceBootloader::Memory::AUTO, + py::arg("type") = DeviceBootloader::Type::AUTO, + DOC(dai, DeviceBootloader, flashConfigData)) + .def( + "flashConfigFile", + [](DeviceBootloader& db, dai::Path configPath, DeviceBootloader::Memory memory, DeviceBootloader::Type type) { + py::gil_scoped_release release; + return db.flashConfigFile(configPath, memory, type); + }, + py::arg("configData"), + py::arg("memory") = DeviceBootloader::Memory::AUTO, + py::arg("type") = DeviceBootloader::Type::AUTO, + DOC(dai, DeviceBootloader, flashConfigFile)) + .def( + "flashConfigClear", + [](DeviceBootloader& db, DeviceBootloader::Memory memory, DeviceBootloader::Type type) { + py::gil_scoped_release release; + return db.flashConfigClear(memory, type); + }, + py::arg("memory") = DeviceBootloader::Memory::AUTO, + py::arg("type") = DeviceBootloader::Type::AUTO, + DOC(dai, DeviceBootloader, flashConfigClear)) + .def( + "readConfig", + [](DeviceBootloader& db, DeviceBootloader::Memory memory, DeviceBootloader::Type type) { + py::gil_scoped_release release; + return db.readConfig(memory, type); + }, + py::arg("memory") = DeviceBootloader::Memory::AUTO, + py::arg("type") = DeviceBootloader::Type::AUTO, + DOC(dai, DeviceBootloader, readConfig)) + .def( + "flashConfig", + [](DeviceBootloader& db, const DeviceBootloader::Config& config, DeviceBootloader::Memory memory, DeviceBootloader::Type type) { + py::gil_scoped_release release; + return db.flashConfig(config, memory, type); + }, + py::arg("config"), + py::arg("memory") = DeviceBootloader::Memory::AUTO, + py::arg("type") = DeviceBootloader::Type::AUTO, + DOC(dai, DeviceBootloader, flashConfig)) - .def("bootMemory", [](DeviceBootloader& db, const std::vector& fw) { py::gil_scoped_release release; return db.bootMemory(fw); }, py::arg("fw"), DOC(dai, DeviceBootloader, bootMemory)) - .def("bootUsbRomBootloader", [](DeviceBootloader& db) { py::gil_scoped_release release; return db.bootUsbRomBootloader(); }, DOC(dai, DeviceBootloader, bootUsbRomBootloader)) + .def( + "bootMemory", + [](DeviceBootloader& db, const std::vector& fw) { + py::gil_scoped_release release; + return db.bootMemory(fw); + }, + py::arg("fw"), + DOC(dai, DeviceBootloader, bootMemory)) + .def( + "bootUsbRomBootloader", + [](DeviceBootloader& db) { + py::gil_scoped_release release; + return db.bootUsbRomBootloader(); + }, + DOC(dai, DeviceBootloader, bootUsbRomBootloader)) - //.def("flashCustom", &DeviceBootloader::flashCustom, py::arg("memory"), py::arg("offset"), py::arg("progressCallback"), py::arg("data"), DOC(dai, DeviceBootloader, flashCustom)) - .def("getVersion", [](DeviceBootloader& db) { py::gil_scoped_release release; return db.getVersion(); }, DOC(dai, DeviceBootloader, getVersion)) + //.def("flashCustom", &DeviceBootloader::flashCustom, py::arg("memory"), py::arg("offset"), py::arg("progressCallback"), py::arg("data"), DOC(dai, + // DeviceBootloader, flashCustom)) + .def( + "getVersion", + [](DeviceBootloader& db) { + py::gil_scoped_release release; + return db.getVersion(); + }, + DOC(dai, DeviceBootloader, getVersion)) .def("isEmbeddedVersion", &DeviceBootloader::isEmbeddedVersion, DOC(dai, DeviceBootloader, isEmbeddedVersion)) .def("getType", &DeviceBootloader::getType, DOC(dai, DeviceBootloader, getType)) .def("isAllowedFlashingBootloader", &DeviceBootloader::isAllowedFlashingBootloader, DOC(dai, DeviceBootloader, isAllowedFlashingBootloader)) - .def("flashClear", [](DeviceBootloader& db, DeviceBootloader::Memory memory) { py::gil_scoped_release release; return db.flashClear(memory); }, py::arg("memory") = DeviceBootloader::Memory::AUTO, DOC(dai, DeviceBootloader, flashClear)) - .def("flashGpioModeBootHeader", [](DeviceBootloader& db, DeviceBootloader::Memory memory, int mode) { py::gil_scoped_release release; return db.flashGpioModeBootHeader(memory, mode); }, py::arg("memory"), py::arg("mode"), DOC(dai, DeviceBootloader, flashGpioModeBootHeader)) - .def("flashUsbRecoveryBootHeader", [](DeviceBootloader& db, DeviceBootloader::Memory memory) { py::gil_scoped_release release; return db.flashUsbRecoveryBootHeader(memory); }, py::arg("memory"), DOC(dai, DeviceBootloader, flashUsbRecoveryBootHeader)) - .def("flashBootHeader", [](DeviceBootloader& db, DeviceBootloader::Memory memory, int32_t frequency, int64_t location, int32_t dummyCycles, int64_t offset) { py::gil_scoped_release release; return db.flashBootHeader(memory, frequency, location, dummyCycles, offset); }, py::arg("memory"), py::arg("frequency") = -1, py::arg("location") = -1, py::arg("dummyCycles") = -1, py::arg("offset") = -1, DOC(dai, DeviceBootloader, flashBootHeader)) - .def("flashFastBootHeader", [](DeviceBootloader& db, DeviceBootloader::Memory memory, int32_t frequency, int64_t location, int32_t dummyCycles, int64_t offset) { py::gil_scoped_release release; return db.flashFastBootHeader(memory, frequency, location, dummyCycles, offset); }, py::arg("memory"), py::arg("frequency") = -1, py::arg("location") = -1, py::arg("dummyCycles") = -1, py::arg("offset") = -1, DOC(dai, DeviceBootloader, flashFastBootHeader)) - .def("flashCustom", [](DeviceBootloader& db, DeviceBootloader::Memory memory, size_t offset, const std::vector& data, std::function progressCb) { py::gil_scoped_release release; return db.flashCustom(memory, offset, data, progressCb); }, py::arg("memory"), py::arg("offset"), py::arg("data"), py::arg("progressCallback") = nullptr, DOC(dai, DeviceBootloader, flashCustom)) - .def("flashCustom", [](DeviceBootloader& db, DeviceBootloader::Memory memory, size_t offset, std::string filename, std::function progressCb) { py::gil_scoped_release release; return db.flashCustom(memory, offset, filename, progressCb); }, py::arg("memory"), py::arg("offset"), py::arg("filename"), py::arg("progressCallback") = nullptr, DOC(dai, DeviceBootloader, flashCustom)) - .def("readCustom", [](DeviceBootloader& db, DeviceBootloader::Memory memory, size_t offset, size_t size, std::string filename, std::function progressCb) { py::gil_scoped_release release; return db.readCustom(memory, offset, size, filename, progressCb); }, py::arg("memory"), py::arg("offset"), py::arg("size"), py::arg("filename"), py::arg("progressCallback") = nullptr, DOC(dai, DeviceBootloader, readCustom)) - .def("readCustom", [](DeviceBootloader& db, DeviceBootloader::Memory memory, size_t offset, size_t size, std::function progressCb) { py::gil_scoped_release release; return db.readCustom(memory, offset, size, progressCb); }, py::arg("memory"), py::arg("offset"), py::arg("size"), py::arg("progressCallback") = nullptr, DOC(dai, DeviceBootloader, readCustom)) - ; - + .def( + "flashClear", + [](DeviceBootloader& db, DeviceBootloader::Memory memory) { + py::gil_scoped_release release; + return db.flashClear(memory); + }, + py::arg("memory") = DeviceBootloader::Memory::AUTO, + DOC(dai, DeviceBootloader, flashClear)) + .def( + "flashGpioModeBootHeader", + [](DeviceBootloader& db, DeviceBootloader::Memory memory, int mode) { + py::gil_scoped_release release; + return db.flashGpioModeBootHeader(memory, mode); + }, + py::arg("memory"), + py::arg("mode"), + DOC(dai, DeviceBootloader, flashGpioModeBootHeader)) + .def( + "flashUsbRecoveryBootHeader", + [](DeviceBootloader& db, DeviceBootloader::Memory memory) { + py::gil_scoped_release release; + return db.flashUsbRecoveryBootHeader(memory); + }, + py::arg("memory"), + DOC(dai, DeviceBootloader, flashUsbRecoveryBootHeader)) + .def( + "flashBootHeader", + [](DeviceBootloader& db, DeviceBootloader::Memory memory, int32_t frequency, int64_t location, int32_t dummyCycles, int64_t offset) { + py::gil_scoped_release release; + return db.flashBootHeader(memory, frequency, location, dummyCycles, offset); + }, + py::arg("memory"), + py::arg("frequency") = -1, + py::arg("location") = -1, + py::arg("dummyCycles") = -1, + py::arg("offset") = -1, + DOC(dai, DeviceBootloader, flashBootHeader)) + .def( + "flashFastBootHeader", + [](DeviceBootloader& db, DeviceBootloader::Memory memory, int32_t frequency, int64_t location, int32_t dummyCycles, int64_t offset) { + py::gil_scoped_release release; + return db.flashFastBootHeader(memory, frequency, location, dummyCycles, offset); + }, + py::arg("memory"), + py::arg("frequency") = -1, + py::arg("location") = -1, + py::arg("dummyCycles") = -1, + py::arg("offset") = -1, + DOC(dai, DeviceBootloader, flashFastBootHeader)) + .def( + "flashCustom", + [](DeviceBootloader& db, DeviceBootloader::Memory memory, size_t offset, const std::vector& data, std::function progressCb) { + py::gil_scoped_release release; + return db.flashCustom(memory, offset, data, progressCb); + }, + py::arg("memory"), + py::arg("offset"), + py::arg("data"), + py::arg("progressCallback") = nullptr, + DOC(dai, DeviceBootloader, flashCustom)) + .def( + "flashCustom", + [](DeviceBootloader& db, DeviceBootloader::Memory memory, size_t offset, std::string filename, std::function progressCb) { + py::gil_scoped_release release; + return db.flashCustom(memory, offset, filename, progressCb); + }, + py::arg("memory"), + py::arg("offset"), + py::arg("filename"), + py::arg("progressCallback") = nullptr, + DOC(dai, DeviceBootloader, flashCustom)) + .def( + "readCustom", + [](DeviceBootloader& db, DeviceBootloader::Memory memory, size_t offset, size_t size, std::string filename, std::function progressCb) { + py::gil_scoped_release release; + return db.readCustom(memory, offset, size, filename, progressCb); + }, + py::arg("memory"), + py::arg("offset"), + py::arg("size"), + py::arg("filename"), + py::arg("progressCallback") = nullptr, + DOC(dai, DeviceBootloader, readCustom)) + .def( + "readCustom", + [](DeviceBootloader& db, DeviceBootloader::Memory memory, size_t offset, size_t size, std::function progressCb) { + py::gil_scoped_release release; + return db.readCustom(memory, offset, size, progressCb); + }, + py::arg("memory"), + py::arg("offset"), + py::arg("size"), + py::arg("progressCallback") = nullptr, + DOC(dai, DeviceBootloader, readCustom)); } diff --git a/bindings/python/src/MessageQueueBindings.cpp b/bindings/python/src/MessageQueueBindings.cpp index e819d332a..d8b1a9927 100644 --- a/bindings/python/src/MessageQueueBindings.cpp +++ b/bindings/python/src/MessageQueueBindings.cpp @@ -10,7 +10,7 @@ #include "depthai/pipeline/MessageQueue.hpp" #include "depthai/pipeline/datatype/ADatatype.hpp" -py::object messageQueueException; // Needed to be able to catch in C++ after it's raised on the Python side +py::object messageQueueException; // Needed to be able to catch in C++ after it's raised on the Python side void MessageQueueBindings::bind(pybind11::module& m, void* pCallstack) { using namespace dai; @@ -44,17 +44,17 @@ void MessageQueueBindings::bind(pybind11::module& m, void* pCallstack) { pybind11::object result = inspectModule.attr("signature")(cb).attr("parameters"); auto numParams = pybind11::len(result); - if (numParams == 2) { + if(numParams == 2) { return q.addCallback([cb](std::string msg, std::shared_ptr data) { pybind11::gil_scoped_acquire gil; cb(msg, data); }); - } else if (numParams == 1) { + } else if(numParams == 1) { return q.addCallback([cb](std::shared_ptr data) { pybind11::gil_scoped_acquire gil; cb(data); }); - } else if (numParams == 0) { + } else if(numParams == 0) { return q.addCallback([cb]() { pybind11::gil_scoped_acquire gil; cb(); diff --git a/bindings/python/src/VersionBindings.cpp b/bindings/python/src/VersionBindings.cpp index e13006226..a618bafa3 100644 --- a/bindings/python/src/VersionBindings.cpp +++ b/bindings/python/src/VersionBindings.cpp @@ -3,8 +3,7 @@ // depthai #include "depthai/device/Version.hpp" -void VersionBindings::bind(pybind11::module& m, void* pCallstack){ - +void VersionBindings::bind(pybind11::module& m, void* pCallstack) { using namespace dai; // Type definitions @@ -14,7 +13,7 @@ void VersionBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -23,15 +22,12 @@ void VersionBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Bind DeviceBootloader - version - .def(py::init(), py::arg("v"), DOC(dai, Version, Version)) + version.def(py::init(), py::arg("v"), DOC(dai, Version, Version)) .def(py::init(), py::arg("major"), py::arg("minor"), py::arg("patch"), DOC(dai, Version, Version, 2)) .def("__str__", &Version::toString, DOC(dai, Version, toString)) .def("__eq__", &Version::operator==) .def("__lt__", &Version::operator<) .def("__gt__", &Version::operator>) .def("toStringSemver", &Version::toStringSemver, DOC(dai, Version, toStringSemver)) - .def("getBuildInfo", &Version::getBuildInfo, DOC(dai, Version, getBuildInfo)) - ; - + .def("getBuildInfo", &Version::getBuildInfo, DOC(dai, Version, getBuildInfo)); } diff --git a/bindings/python/src/XLinkBindings.cpp b/bindings/python/src/XLinkBindings.cpp index 9be3ab5fb..5916ba923 100644 --- a/bindings/python/src/XLinkBindings.cpp +++ b/bindings/python/src/XLinkBindings.cpp @@ -1,4 +1,5 @@ #include "XLinkBindings.hpp" + #include // std @@ -9,10 +10,7 @@ #include "depthai/xlink/XLinkConnection.hpp" #include "depthai/xlink/XLinkStream.hpp" - -void XLinkBindings::bind(pybind11::module &m, void *pCallstack) -{ - +void XLinkBindings::bind(pybind11::module& m, void* pCallstack) { using namespace dai; // Type definitions @@ -33,16 +31,15 @@ void XLinkBindings::bind(pybind11::module &m, void *pCallstack) auto xlinkReadError = py::register_exception(m, "XLinkReadError", xlinkError.ptr()); auto xlinkWriteError = py::register_exception(m, "XLinkWriteError", xlinkError.ptr()); - //py::class_ xLinkError(m, "XLinkError", DOC(dai, XLinkError)); - //py::class_ xLinkReadError(m, "XLinkReadError", DOC(dai, XLinkReadError)); - //py::class_ xLinkWriteError(m, "XLinkWriteError", DOC(dai, XLinkWriteError)); - + // py::class_ xLinkError(m, "XLinkError", DOC(dai, XLinkError)); + // py::class_ xLinkReadError(m, "XLinkReadError", DOC(dai, XLinkReadError)); + // py::class_ xLinkWriteError(m, "XLinkWriteError", DOC(dai, XLinkWriteError)); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack *callstack = (Callstack *)pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -62,7 +59,13 @@ void XLinkBindings::bind(pybind11::module &m, void *pCallstack) DOC(dai, DeviceInfo, DeviceInfo, 2)) .def(py::init(), py::arg("deviceIdOrName"), DOC(dai, DeviceInfo, DeviceInfo, 3)) .def(py::init(), DOC(dai, DeviceInfo, DeviceInfo, 4)) - .def("getMxId", [](DeviceInfo& info) { PyErr_WarnEx(PyExc_DeprecationWarning, "getMxId is deprecated, use getDeviceId instead.", 1); return info.getMxId(); }, DOC(dai, DeviceInfo, getMxId)) + .def( + "getMxId", + [](DeviceInfo& info) { + PyErr_WarnEx(PyExc_DeprecationWarning, "getMxId is deprecated, use getDeviceId instead.", 1); + return info.getMxId(); + }, + DOC(dai, DeviceInfo, getMxId)) .def("getDeviceId", &DeviceInfo::getDeviceId, DOC(dai, DeviceInfo, getDeviceId)) .def("getXLinkDeviceDesc", &DeviceInfo::getXLinkDeviceDesc) .def_readwrite("name", &DeviceInfo::name) @@ -73,45 +76,40 @@ void XLinkBindings::bind(pybind11::module &m, void *pCallstack) .def_readwrite("status", &DeviceInfo::status) .def("__repr__", &DeviceInfo::toString) // deprecated - .def_property("desc", [](py::object& self) { - // Issue an deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "desc field is deprecated, use name/mxid and others instead.", 1); - return self; - },[](DeviceInfo& i, DeviceInfo di){ - // Issue an deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "desc field is deprecated, use name/mxid and others instead.", 1); - i = di; - }) - ; - - deviceDesc - .def(py::init<>()) + .def_property( + "desc", + [](py::object& self) { + // Issue an deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "desc field is deprecated, use name/mxid and others instead.", 1); + return self; + }, + [](DeviceInfo& i, DeviceInfo di) { + // Issue an deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "desc field is deprecated, use name/mxid and others instead.", 1); + i = di; + }); + + deviceDesc.def(py::init<>()) .def_readwrite("protocol", &deviceDesc_t::protocol) .def_readwrite("platform", &deviceDesc_t::platform) .def_readwrite("state", &deviceDesc_t::state) .def_readwrite("status", &deviceDesc_t::status) .def_property( "name", - [](deviceDesc_t &o) - { return std::string(o.name); }, - [](deviceDesc_t &o, std::string n) - { + [](deviceDesc_t& o) { return std::string(o.name); }, + [](deviceDesc_t& o, std::string n) { memset(o.name, 0, sizeof(o.name)); std::strncpy(o.name, n.c_str(), sizeof(o.name)); }) .def_property( "mxid", - [](deviceDesc_t &o) - { return std::string(o.mxid); }, - [](deviceDesc_t &o, std::string n) - { + [](deviceDesc_t& o) { return std::string(o.mxid); }, + [](deviceDesc_t& o, std::string n) { memset(o.mxid, 0, sizeof(o.mxid)); std::strncpy(o.mxid, n.c_str(), sizeof(o.mxid)); - }) - ; + }); - xLinkDeviceState - .value("X_LINK_ANY_STATE", X_LINK_ANY_STATE) + xLinkDeviceState.value("X_LINK_ANY_STATE", X_LINK_ANY_STATE) .value("X_LINK_BOOTED", X_LINK_BOOTED) .value("X_LINK_UNBOOTED", X_LINK_UNBOOTED) .value("X_LINK_BOOTLOADER", X_LINK_BOOTLOADER) @@ -119,41 +117,36 @@ void XLinkBindings::bind(pybind11::module &m, void *pCallstack) .value("X_LINK_BOOTED_NON_EXCLUSIVE", X_LINK_BOOTED_NON_EXCLUSIVE) .value("X_LINK_GATE", X_LINK_GATE) .value("X_LINK_GATE_BOOTED", X_LINK_GATE_BOOTED) - .export_values() - ; + .export_values(); - xLinkProtocol - .value("X_LINK_USB_VSC", X_LINK_USB_VSC) + xLinkProtocol.value("X_LINK_USB_VSC", X_LINK_USB_VSC) .value("X_LINK_USB_CDC", X_LINK_USB_CDC) .value("X_LINK_PCIE", X_LINK_PCIE) .value("X_LINK_TCP_IP", X_LINK_TCP_IP) .value("X_LINK_IPC", X_LINK_IPC) .value("X_LINK_NMB_OF_PROTOCOLS", X_LINK_NMB_OF_PROTOCOLS) .value("X_LINK_ANY_PROTOCOL", X_LINK_ANY_PROTOCOL) - .export_values() - ; + .export_values(); xLinkPlatform.value("X_LINK_ANY_PLATFORM", X_LINK_ANY_PLATFORM) .value("X_LINK_MYRIAD_2", X_LINK_MYRIAD_2) .value("X_LINK_MYRIAD_X", X_LINK_MYRIAD_X) .value("X_LINK_RVC3", X_LINK_RVC3) .value("X_LINK_RVC4", X_LINK_RVC4) - .export_values() - ; - - xLinkConnection - .def(py::init >()) - .def(py::init()) - .def(py::init()) - .def_static("getAllConnectedDevices", &XLinkConnection::getAllConnectedDevices, py::arg("state") = X_LINK_ANY_STATE, py::arg("skipInvalidDevices") = true) + .export_values(); + + xLinkConnection.def(py::init >()) + .def(py::init()) + .def(py::init()) + .def_static( + "getAllConnectedDevices", &XLinkConnection::getAllConnectedDevices, py::arg("state") = X_LINK_ANY_STATE, py::arg("skipInvalidDevices") = true) .def_static("getFirstDevice", &XLinkConnection::getFirstDevice, py::arg("state") = X_LINK_ANY_STATE, py::arg("skipInvalidDevice") = true) - .def_static("getDeviceById", &XLinkConnection::getDeviceById, py::arg("deviceId"), py::arg("state") = X_LINK_ANY_STATE, py::arg("skipInvalidDevice") = true) + .def_static( + "getDeviceById", &XLinkConnection::getDeviceById, py::arg("deviceId"), py::arg("state") = X_LINK_ANY_STATE, py::arg("skipInvalidDevice") = true) .def_static("bootBootloader", &XLinkConnection::bootBootloader, py::arg("devInfo")) - .def_static("getGlobalProfilingData", &XLinkConnection::getGlobalProfilingData, DOC(dai, XLinkConnection, getGlobalProfilingData)) - ; + .def_static("getGlobalProfilingData", &XLinkConnection::getGlobalProfilingData, DOC(dai, XLinkConnection, getGlobalProfilingData)); - xLinkError - .value("X_LINK_SUCCESS", X_LINK_SUCCESS) + xLinkError.value("X_LINK_SUCCESS", X_LINK_SUCCESS) .value("X_LINK_ALREADY_OPEN", X_LINK_ALREADY_OPEN) .value("X_LINK_COMMUNICATION_NOT_OPEN", X_LINK_COMMUNICATION_NOT_OPEN) .value("X_LINK_COMMUNICATION_FAIL", X_LINK_COMMUNICATION_FAIL) @@ -168,9 +161,7 @@ void XLinkBindings::bind(pybind11::module &m, void *pCallstack) .value("X_LINK_INIT_USB_ERROR", X_LINK_INIT_USB_ERROR) .value("X_LINK_INIT_TCP_IP_ERROR", X_LINK_INIT_TCP_IP_ERROR) .value("X_LINK_INIT_PCIE_ERROR", X_LINK_INIT_PCIE_ERROR) - .export_values() - ; - + .export_values(); //// Exceptions @@ -186,6 +177,4 @@ void XLinkBindings::bind(pybind11::module &m, void *pCallstack) // // xLinkWriteError // .def(py::init()); - - } \ No newline at end of file diff --git a/bindings/python/src/XLinkBindings.hpp b/bindings/python/src/XLinkBindings.hpp index ea360b302..da70babb8 100644 --- a/bindings/python/src/XLinkBindings.hpp +++ b/bindings/python/src/XLinkBindings.hpp @@ -3,7 +3,6 @@ // pybind #include "pybind11_common.hpp" -struct XLinkBindings -{ - static void bind(pybind11::module &m, void *pCallstack); +struct XLinkBindings { + static void bind(pybind11::module& m, void* pCallstack); }; diff --git a/bindings/python/src/common/ModelTypeBindings.cpp b/bindings/python/src/common/ModelTypeBindings.cpp index 45883f3b3..c32b82adf 100644 --- a/bindings/python/src/common/ModelTypeBindings.cpp +++ b/bindings/python/src/common/ModelTypeBindings.cpp @@ -6,7 +6,6 @@ #include - PYBIND11_MAKE_OPAQUE(std::vector); void ModelTypeBindings::bind(pybind11::module& m, void* pCallstack) { diff --git a/bindings/python/src/log/LogBindings.cpp b/bindings/python/src/log/LogBindings.cpp index 8766eb6ac..f0dc248fe 100644 --- a/bindings/python/src/log/LogBindings.cpp +++ b/bindings/python/src/log/LogBindings.cpp @@ -4,20 +4,18 @@ #include "depthai/log/LogLevel.hpp" #include "depthai/log/LogMessage.hpp" -void LogBindings::bind(pybind11::module& m, void* pCallstack){ - +void LogBindings::bind(pybind11::module& m, void* pCallstack) { using namespace dai; // Bind LogLevel py::enum_ logLevel(m, "LogLevel"); py::class_ logMessage(m, "LogMessage", DOC(dai, LogMessage)); - /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -26,24 +24,18 @@ void LogBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// - - logLevel - .value("TRACE", LogLevel::TRACE) + logLevel.value("TRACE", LogLevel::TRACE) .value("DEBUG", LogLevel::DEBUG) .value("INFO", LogLevel::INFO) .value("WARN", LogLevel::WARN) .value("ERR", LogLevel::ERR) .value("CRITICAL", LogLevel::CRITICAL) - .value("OFF", LogLevel::OFF) - ; + .value("OFF", LogLevel::OFF); - logMessage - .def_readwrite("nodeIdName", &LogMessage::nodeIdName) + logMessage.def_readwrite("nodeIdName", &LogMessage::nodeIdName) .def_readwrite("level", &LogMessage::level) .def_readwrite("time", &LogMessage::time) .def_readwrite("colorRangeStart", &LogMessage::colorRangeStart) .def_readwrite("colorRangeEnd", &LogMessage::colorRangeEnd) - .def_readwrite("payload", &LogMessage::payload) - ; - + .def_readwrite("payload", &LogMessage::payload); } \ No newline at end of file diff --git a/bindings/python/src/modelzoo/NNModelDescriptionBindings.cpp b/bindings/python/src/modelzoo/NNModelDescriptionBindings.cpp index d9583f3bb..f02a66510 100644 --- a/bindings/python/src/modelzoo/NNModelDescriptionBindings.cpp +++ b/bindings/python/src/modelzoo/NNModelDescriptionBindings.cpp @@ -83,7 +83,7 @@ void NNModelDescriptionBindings::bind(pybind11::module& m, void* pCallstack) { .def(py::init(), py::arg("teamName") = "", py::arg("modelSlug") = "", - py::arg("modelVariantSlug")= "", + py::arg("modelVariantSlug") = "", py::arg("modelRef") = "") .def("merge", &SlugComponents::merge, DOC(dai, SlugComponents, merge)) .def_static("split", &SlugComponents::split, py::arg("slug"), DOC(dai, SlugComponents, split)) diff --git a/bindings/python/src/nn_archive/NNArchiveBindings.cpp b/bindings/python/src/nn_archive/NNArchiveBindings.cpp index 21e632a41..4cbda0c63 100644 --- a/bindings/python/src/nn_archive/NNArchiveBindings.cpp +++ b/bindings/python/src/nn_archive/NNArchiveBindings.cpp @@ -5,8 +5,8 @@ #include #include "depthai/nn_archive/NNArchive.hpp" -#include "depthai/nn_archive/NNArchiveVersionedConfig.hpp" #include "depthai/nn_archive/NNArchiveEntry.hpp" +#include "depthai/nn_archive/NNArchiveVersionedConfig.hpp" // v1 nn_archive bindings #include "depthai/nn_archive/v1/Config.hpp" @@ -102,19 +102,19 @@ void NNArchiveBindings::bind(pybind11::module& m, void* pCallstack) { // Bind NNArchiveVersionedConfig nnArchiveVersionedConfig.def(py::init(), - py::arg("path"), - py::arg("compression") = NNArchiveEntry::Compression::AUTO, - DOC(dai, NNArchiveVersionedConfig, NNArchiveVersionedConfig)); + py::arg("path"), + py::arg("compression") = NNArchiveEntry::Compression::AUTO, + DOC(dai, NNArchiveVersionedConfig, NNArchiveVersionedConfig)); nnArchiveVersionedConfig.def(py::init&, NNArchiveEntry::Compression>(), - py::arg("data"), - py::arg("compression") = NNArchiveEntry::Compression::AUTO, - DOC(dai, NNArchiveVersionedConfig, NNArchiveVersionedConfig)); + py::arg("data"), + py::arg("compression") = NNArchiveEntry::Compression::AUTO, + DOC(dai, NNArchiveVersionedConfig, NNArchiveVersionedConfig)); nnArchiveVersionedConfig.def(py::init([](const std::function& openCallback, - const std::function()>& readCallback, - const std::function& seekCallback, - const std::function& skipCallback, - const std::function& closeCallback, - NNArchiveEntry::Compression compression) { + const std::function()>& readCallback, + const std::function& seekCallback, + const std::function& skipCallback, + const std::function& closeCallback, + NNArchiveEntry::Compression compression) { auto readCallbackWrapper = [readCallback]() { return std::make_shared>(readCallback()); }; return NNArchiveVersionedConfig(openCallback, readCallbackWrapper, seekCallback, skipCallback, closeCallback, compression); })); @@ -137,8 +137,6 @@ void NNArchiveBindings::bind(pybind11::module& m, void* pCallstack) { archiveEntrySeek.value("CUR", NNArchiveEntry::Seek::CUR); archiveEntrySeek.value("END", NNArchiveEntry::Seek::END); - - v1config.def(py::init<>()); v1config.def(py::init(), py::arg("configVersion"), py::arg("model")); v1config.def_readwrite("configVersion", &v1::Config::configVersion, DOC(dai, nn_archive, v1, Config, configVersion)); @@ -172,7 +170,6 @@ void NNArchiveBindings::bind(pybind11::module& m, void* pCallstack) { v1dataType.value("UINT64", v1::DataType::UINT64); v1dataType.value("STRING", v1::DataType::STRING); - v1inputType.value("IMAGE", v1::InputType::IMAGE); v1inputType.value("RAW", v1::InputType::RAW); diff --git a/bindings/python/src/openvino/OpenVINOBindings.cpp b/bindings/python/src/openvino/OpenVINOBindings.cpp index abcad6830..8eb2dfe42 100644 --- a/bindings/python/src/openvino/OpenVINOBindings.cpp +++ b/bindings/python/src/openvino/OpenVINOBindings.cpp @@ -1,11 +1,11 @@ #include "OpenVINOBindings.hpp" + #include // depthai #include "depthai/openvino/OpenVINO.hpp" -void OpenVINOBindings::bind(pybind11::module& m, void* pCallstack){ - +void OpenVINOBindings::bind(pybind11::module& m, void* pCallstack) { using namespace dai; py::class_ openvino(m, "OpenVINO", DOC(dai, OpenVINO)); @@ -14,12 +14,11 @@ void OpenVINOBindings::bind(pybind11::module& m, void* pCallstack){ py::class_ openvinoSuperBlob(openvino, "SuperBlob", DOC(dai, OpenVINO, SuperBlob)); py::enum_ openvinoDevice(openvino, "Device", DOC(dai, OpenVINO, Device)); - /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -28,17 +27,22 @@ void OpenVINOBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// - - // Bind OpenVINO - openvino - .def_static("getVersions", &OpenVINO::getVersions, DOC(dai, OpenVINO, getVersions)) + openvino.def_static("getVersions", &OpenVINO::getVersions, DOC(dai, OpenVINO, getVersions)) .def_static("getVersionName", &OpenVINO::getVersionName, py::arg("version"), DOC(dai, OpenVINO, getVersionName)) .def_static("parseVersionName", &OpenVINO::parseVersionName, py::arg("versionString"), DOC(dai, OpenVINO, parseVersionName)) - .def_static("getBlobSupportedVersions", &OpenVINO::getBlobSupportedVersions, py::arg("majorVersion"), py::arg("majorVersion"), DOC(dai, OpenVINO, getBlobSupportedVersions)) - .def_static("getBlobLatestSupportedVersion", &OpenVINO::getBlobLatestSupportedVersion, py::arg("majorVersion"), py::arg("majorVersion"), DOC(dai, OpenVINO, getBlobLatestSupportedVersion)) - .def_static("areVersionsBlobCompatible", &OpenVINO::areVersionsBlobCompatible, py::arg("v1"), py::arg("v2"), DOC(dai, OpenVINO, areVersionsBlobCompatible)) - ; + .def_static("getBlobSupportedVersions", + &OpenVINO::getBlobSupportedVersions, + py::arg("majorVersion"), + py::arg("majorVersion"), + DOC(dai, OpenVINO, getBlobSupportedVersions)) + .def_static("getBlobLatestSupportedVersion", + &OpenVINO::getBlobLatestSupportedVersion, + py::arg("majorVersion"), + py::arg("majorVersion"), + DOC(dai, OpenVINO, getBlobLatestSupportedVersion)) + .def_static( + "areVersionsBlobCompatible", &OpenVINO::areVersionsBlobCompatible, py::arg("v1"), py::arg("v2"), DOC(dai, OpenVINO, areVersionsBlobCompatible)); // not strongly typed enum OpenVINO::Version // previous step defined class 'OpenVINO' (variable 'openvino') @@ -47,8 +51,7 @@ void OpenVINOBindings::bind(pybind11::module& m, void* pCallstack){ // they are exported // By default, pybind creates strong typed enums, eg: OpenVINO::Version::VERSION_2021_4 - openvinoVersion - .value("VERSION_2020_3", OpenVINO::Version::VERSION_2020_3) + openvinoVersion.value("VERSION_2020_3", OpenVINO::Version::VERSION_2020_3) .value("VERSION_2020_4", OpenVINO::Version::VERSION_2020_4) .value("VERSION_2021_1", OpenVINO::Version::VERSION_2021_1) .value("VERSION_2021_2", OpenVINO::Version::VERSION_2021_2) @@ -56,19 +59,14 @@ void OpenVINOBindings::bind(pybind11::module& m, void* pCallstack){ .value("VERSION_2021_4", OpenVINO::Version::VERSION_2021_4) .value("VERSION_2022_1", OpenVINO::Version::VERSION_2022_1) .value("VERSION_UNIVERSAL", OpenVINO::Version::VERSION_UNIVERSAL) - .export_values() - ; + .export_values(); // DEFAULT_VERSION binding openvino.attr("DEFAULT_VERSION") = dai::OpenVINO::DEFAULT_VERSION; - openvinoDevice - .value("VPU", OpenVINO::Device::VPU) - .value("VPUX", OpenVINO::Device::VPUX) - ; + openvinoDevice.value("VPU", OpenVINO::Device::VPU).value("VPUX", OpenVINO::Device::VPUX); // Bind OpenVINO::Blob - openvinoBlob - .def(py::init>(), DOC(dai, OpenVINO, Blob, Blob)) + openvinoBlob.def(py::init>(), DOC(dai, OpenVINO, Blob, Blob)) .def(py::init(), DOC(dai, OpenVINO, Blob, Blob, 2)) .def_readwrite("version", &OpenVINO::Blob::version, DOC(dai, OpenVINO, Blob, version)) .def_readwrite("device", &OpenVINO::Blob::device, DOC(dai, OpenVINO, Blob, device)) @@ -77,17 +75,12 @@ void OpenVINOBindings::bind(pybind11::module& m, void* pCallstack){ .def_readwrite("stageCount", &OpenVINO::Blob::stageCount, DOC(dai, OpenVINO, Blob, stageCount)) .def_readwrite("numShaves", &OpenVINO::Blob::numShaves, DOC(dai, OpenVINO, Blob, numShaves)) .def_readwrite("numSlices", &OpenVINO::Blob::numSlices, DOC(dai, OpenVINO, Blob, numSlices)) - .def_readwrite("data", &OpenVINO::Blob::data, DOC(dai, OpenVINO, Blob, data)) - ; + .def_readwrite("data", &OpenVINO::Blob::data, DOC(dai, OpenVINO, Blob, data)); // Bind OpenVINO::SuperBlob - openvinoSuperBlob - .def(py::init>(), py::arg("superblobBytes"), DOC(dai, OpenVINO, SuperBlob, SuperBlob)) + openvinoSuperBlob.def(py::init>(), py::arg("superblobBytes"), DOC(dai, OpenVINO, SuperBlob, SuperBlob)) .def(py::init(), py::arg("pathToSuperBlobFile"), DOC(dai, OpenVINO, SuperBlob, SuperBlob)) .def("getBlobWithNumShaves", &OpenVINO::SuperBlob::getBlobWithNumShaves, py::arg("numShaves"), DOC(dai, OpenVINO, SuperBlob, getBlobWithNumShaves)) .def_readonly_static("NUMBER_OF_PATCHES", &OpenVINO::SuperBlob::NUMBER_OF_PATCHES); ; } - - - diff --git a/bindings/python/src/pipeline/AssetManagerBindings.cpp b/bindings/python/src/pipeline/AssetManagerBindings.cpp index 9a8c26d3e..b6dbc6bee 100644 --- a/bindings/python/src/pipeline/AssetManagerBindings.cpp +++ b/bindings/python/src/pipeline/AssetManagerBindings.cpp @@ -3,21 +3,18 @@ // depthai #include "depthai/pipeline/AssetManager.hpp" -void AssetManagerBindings::bind(pybind11::module& m, void* pCallstack){ - +void AssetManagerBindings::bind(pybind11::module& m, void* pCallstack) { using namespace dai; - // Type definitions py::class_> asset(m, "Asset", DOC(dai, Asset)); py::class_ assetManager(m, "AssetManager", DOC(dai, AssetManager)); - /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -26,39 +23,57 @@ void AssetManagerBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// - // Bind Asset - asset - .def(py::init<>()) + asset.def(py::init<>()) .def(py::init()) .def_readonly("key", &Asset::key) // numpy array access - zero copy on access - .def_property("data", [](py::object &obj){ - dai::Asset &a = obj.cast(); - return py::array_t(a.data.size(), a.data.data(), obj); - }, [](py::object &obj, py::array_t array){ - dai::Asset &a = obj.cast(); - a.data = {array.data(), array.data() + array.size()}; - }) - .def_readwrite("alignment", &Asset::alignment) - ; + .def_property( + "data", + [](py::object& obj) { + dai::Asset& a = obj.cast(); + return py::array_t(a.data.size(), a.data.data(), obj); + }, + [](py::object& obj, py::array_t array) { + dai::Asset& a = obj.cast(); + a.data = {array.data(), array.data() + array.size()}; + }) + .def_readwrite("alignment", &Asset::alignment); // Bind AssetManager - assetManager - .def(py::init<>()) + assetManager.def(py::init<>()) .def(py::init()) .def("addExisting", &AssetManager::addExisting, py::arg("assets"), DOC(dai, AssetManager, addExisting)) .def("set", static_cast (AssetManager::*)(Asset)>(&AssetManager::set), py::arg("asset"), DOC(dai, AssetManager, set)) - .def("set", static_cast (AssetManager::*)(const std::string&, Asset)>(&AssetManager::set), py::arg("key"), py::arg("asset"), DOC(dai, AssetManager, set, 2)) - .def("set", static_cast (AssetManager::*)(const std::string& key, const dai::Path& path, int alignment)>(&AssetManager::set), py::arg("key"), py::arg("path"), py::arg("alignment") = 64, DOC(dai, AssetManager, set, 3)) - .def("set", static_cast (AssetManager::*)(const std::string& key, const std::vector& data, int alignment)>(&AssetManager::set), py::arg("key"), py::arg("data"), py::arg("alignment") = 64, DOC(dai, AssetManager, set, 4)) - .def("get", static_cast (AssetManager::*)(const std::string&) const>(&AssetManager::get), py::arg("key"), DOC(dai, AssetManager, get)) - .def("get", static_cast (AssetManager::*)(const std::string&)>(&AssetManager::get), py::arg("key"), DOC(dai, AssetManager, get, 2)) + .def("set", + static_cast (AssetManager::*)(const std::string&, Asset)>(&AssetManager::set), + py::arg("key"), + py::arg("asset"), + DOC(dai, AssetManager, set, 2)) + .def("set", + static_cast (AssetManager::*)(const std::string& key, const dai::Path& path, int alignment)>(&AssetManager::set), + py::arg("key"), + py::arg("path"), + py::arg("alignment") = 64, + DOC(dai, AssetManager, set, 3)) + .def("set", + static_cast (AssetManager::*)(const std::string& key, const std::vector& data, int alignment)>( + &AssetManager::set), + py::arg("key"), + py::arg("data"), + py::arg("alignment") = 64, + DOC(dai, AssetManager, set, 4)) + .def("get", + static_cast (AssetManager::*)(const std::string&) const>(&AssetManager::get), + py::arg("key"), + DOC(dai, AssetManager, get)) + .def("get", + static_cast (AssetManager::*)(const std::string&)>(&AssetManager::get), + py::arg("key"), + DOC(dai, AssetManager, get, 2)) .def("getAll", static_cast> (AssetManager::*)() const>(&AssetManager::getAll), DOC(dai, AssetManager, getAll)) .def("getAll", static_cast> (AssetManager::*)()>(&AssetManager::getAll), DOC(dai, AssetManager, getAll, 2)) .def("size", &AssetManager::size, DOC(dai, AssetManager, size)) .def("remove", &AssetManager::remove, py::arg("key"), DOC(dai, AssetManager, remove)) - .def("getRootPath", &AssetManager::getRootPath, DOC(dai, AssetManager, getRootPath)) - ; - + .def("getRootPath", &AssetManager::getRootPath, DOC(dai, AssetManager, getRootPath)); } diff --git a/bindings/python/src/pipeline/CommonBindings.cpp b/bindings/python/src/pipeline/CommonBindings.cpp index 0cc3d8c90..b5ca46dfd 100644 --- a/bindings/python/src/pipeline/CommonBindings.cpp +++ b/bindings/python/src/pipeline/CommonBindings.cpp @@ -21,26 +21,25 @@ #include "depthai/common/Interpolation.hpp" #include "depthai/common/MemoryInfo.hpp" #include "depthai/common/Point2f.hpp" +#include "depthai/common/Point3d.hpp" #include "depthai/common/Point3f.hpp" #include "depthai/common/Point3fRGB.hpp" -#include "depthai/common/Point3d.hpp" -#include "depthai/common/Quaterniond.hpp" #include "depthai/common/ProcessorType.hpp" +#include "depthai/common/Quaterniond.hpp" #include "depthai/common/Rect.hpp" #include "depthai/common/RotatedRect.hpp" #include "depthai/common/Size2f.hpp" +#include "depthai/common/StereoPair.hpp" #include "depthai/common/Timestamp.hpp" #include "depthai/common/UsbSpeed.hpp" -#include "depthai/common/StereoPair.hpp" // depthai -#include "depthai/common/CameraFeatures.hpp" #include "depthai/common/CameraExposureOffset.hpp" +#include "depthai/common/CameraFeatures.hpp" #include "depthai/common/StereoPair.hpp" #include "depthai/utility/ProfilingData.hpp" -void CommonBindings::bind(pybind11::module& m, void* pCallstack){ - +void CommonBindings::bind(pybind11::module& m, void* pCallstack) { using namespace dai; py::class_ timestamp(m, "Timestamp", DOC(dai, Timestamp)); @@ -84,7 +83,7 @@ void CommonBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -93,8 +92,7 @@ void CommonBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// - rotatedRect - .def(py::init<>()) + rotatedRect.def(py::init<>()) .def(py::init()) .def(py::init()) .def_readwrite("center", &RotatedRect::center) @@ -104,11 +102,9 @@ void CommonBindings::bind(pybind11::module& m, void* pCallstack){ .def("normalize", &RotatedRect::normalize, py::arg("width"), py::arg("height"), DOC(dai, RotatedRect, normalize)) .def("denormalize", &RotatedRect::denormalize, py::arg("width"), py::arg("height"), DOC(dai, RotatedRect, denormalize)) .def("getPoints", &RotatedRect::getPoints, DOC(dai, RotatedRect, getPoints)) - .def("getOuterRect", &RotatedRect::getOuterRect, DOC(dai, RotatedRect, getOuterRect)) - ; + .def("getOuterRect", &RotatedRect::getOuterRect, DOC(dai, RotatedRect, getOuterRect)); - rect - .def(py::init<>()) + rect.def(py::init<>()) .def(py::init()) .def(py::init()) .def(py::init()) @@ -128,11 +124,9 @@ void CommonBindings::bind(pybind11::module& m, void* pCallstack){ .def_readwrite("x", &Rect::x) .def_readwrite("y", &Rect::y) .def_readwrite("width", &Rect::width) - .def_readwrite("height", &Rect::height) - ; + .def_readwrite("height", &Rect::height); - stereoPair - .def(py::init<>()) + stereoPair.def(py::init<>()) .def_readwrite("left", &StereoPair::left) .def_readwrite("right", &StereoPair::right) .def_readwrite("baseline", &StereoPair::baseline) @@ -141,72 +135,54 @@ void CommonBindings::bind(pybind11::module& m, void* pCallstack){ std::stringstream stream; stream << stereoPair; return stream.str(); - }) - ; + }); - timestamp - .def(py::init<>()) - .def_readwrite("sec", &Timestamp::sec) - .def_readwrite("nsec", &Timestamp::nsec) - .def("get", &Timestamp::get) - ; + timestamp.def(py::init<>()).def_readwrite("sec", &Timestamp::sec).def_readwrite("nsec", &Timestamp::nsec).def("get", &Timestamp::get); - point2f - .def(py::init<>(), DOC(dai, Point2f, Point2f)) + point2f.def(py::init<>(), DOC(dai, Point2f, Point2f)) .def(py::init(), py::arg("x"), py::arg("y"), DOC(dai, Point2f, Point2f, 2)) .def(py::init(), py::arg("x"), py::arg("y"), py::arg("normalized"), DOC(dai, Point2f, Point2f, 3)) .def_readwrite("x", &Point2f::x) .def_readwrite("y", &Point2f::y) - .def("isNormalized", &Point2f::isNormalized) - ; + .def("isNormalized", &Point2f::isNormalized); - point3f - .def(py::init<>()) + point3f.def(py::init<>()) .def(py::init()) .def_readwrite("x", &Point3f::x) .def_readwrite("y", &Point3f::y) - .def_readwrite("z", &Point3f::z) - ; - point3fRGB - .def(py::init<>()) + .def_readwrite("z", &Point3f::z); + point3fRGB.def(py::init<>()) .def(py::init()) .def_readwrite("x", &Point3fRGB::x) .def_readwrite("y", &Point3fRGB::y) .def_readwrite("z", &Point3fRGB::z) .def_readwrite("r", &Point3fRGB::r) .def_readwrite("g", &Point3fRGB::g) - .def_readwrite("b", &Point3fRGB::b) - ; - point3d - .def(py::init<>()) + .def_readwrite("b", &Point3fRGB::b); + point3d.def(py::init<>()) .def(py::init()) .def_readwrite("x", &Point3d::x) .def_readwrite("y", &Point3d::y) - .def_readwrite("z", &Point3d::z) - ; - quaterniond - .def(py::init<>()) + .def_readwrite("z", &Point3d::z); + quaterniond.def(py::init<>()) .def(py::init()) .def_readwrite("qx", &Quaterniond::qx) .def_readwrite("qy", &Quaterniond::qy) .def_readwrite("qz", &Quaterniond::qz) - .def_readwrite("qw", &Quaterniond::qw) - ; + .def_readwrite("qw", &Quaterniond::qw); size2f.def(py::init<>()) .def(py::init(), py::arg("width"), py::arg("height")) .def(py::init(), py::arg("width"), py::arg("height"), py::arg("normalized")) .def_readwrite("width", &Size2f::width) .def_readwrite("height", &Size2f::height) - .def("isNormalized", &Size2f::isNormalized) - ; + .def("isNormalized", &Size2f::isNormalized); // CameraBoardSocket enum bindings // Deprecated HEDLEY_DIAGNOSTIC_PUSH HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - cameraBoardSocket - .value("AUTO", CameraBoardSocket::AUTO) + cameraBoardSocket.value("AUTO", CameraBoardSocket::AUTO) .value("CAM_A", CameraBoardSocket::CAM_A) .value("CAM_B", CameraBoardSocket::CAM_B) .value("CAM_C", CameraBoardSocket::CAM_C) @@ -223,50 +199,43 @@ void CommonBindings::bind(pybind11::module& m, void* pCallstack){ .value("CENTER", CameraBoardSocket::CENTER, "**Deprecated:** Use CAM_A or address camera by name instead") // Deprecated overriden - .def_property_readonly_static("RGB", [](py::object){ - PyErr_WarnEx(PyExc_DeprecationWarning, "RGB is deprecated, use CAM_A or address camera by name instead.", 1); - return CameraBoardSocket::CAM_A; - }) - .def_property_readonly_static("CENTER", [](py::object){ - PyErr_WarnEx(PyExc_DeprecationWarning, "CENTER is deprecated, use CAM_A or address camera by name instead.", 1); - return CameraBoardSocket::CAM_A; - }) - .def_property_readonly_static("LEFT", [](py::object){ - PyErr_WarnEx(PyExc_DeprecationWarning, "LEFT is deprecated, use CAM_B or address camera by name instead.", 1); - return CameraBoardSocket::CAM_B; - }) - .def_property_readonly_static("RIGHT", [](py::object){ + .def_property_readonly_static("RGB", + [](py::object) { + PyErr_WarnEx(PyExc_DeprecationWarning, "RGB is deprecated, use CAM_A or address camera by name instead.", 1); + return CameraBoardSocket::CAM_A; + }) + .def_property_readonly_static("CENTER", + [](py::object) { + PyErr_WarnEx(PyExc_DeprecationWarning, "CENTER is deprecated, use CAM_A or address camera by name instead.", 1); + return CameraBoardSocket::CAM_A; + }) + .def_property_readonly_static("LEFT", + [](py::object) { + PyErr_WarnEx(PyExc_DeprecationWarning, "LEFT is deprecated, use CAM_B or address camera by name instead.", 1); + return CameraBoardSocket::CAM_B; + }) + .def_property_readonly_static("RIGHT", [](py::object) { PyErr_WarnEx(PyExc_DeprecationWarning, "RIGHT is deprecated, use CAM_C or address camera by name instead.", 1); return CameraBoardSocket::CAM_C; - }) - ; + }); HEDLEY_DIAGNOSTIC_POP // CameraSensorType enum bindings - cameraSensorType - .value("COLOR", CameraSensorType::COLOR) + cameraSensorType.value("COLOR", CameraSensorType::COLOR) .value("MONO", CameraSensorType::MONO) .value("TOF", CameraSensorType::TOF) - .value("THERMAL", CameraSensorType::THERMAL) - ; + .value("THERMAL", CameraSensorType::THERMAL); // ConnectionInterface enum bindings - connectionInterface - .value("USB", ConnectionInterface::USB) - .value("ETHERNET", ConnectionInterface::ETHERNET) - .value("WIFI", ConnectionInterface::WIFI) - ; + connectionInterface.value("USB", ConnectionInterface::USB).value("ETHERNET", ConnectionInterface::ETHERNET).value("WIFI", ConnectionInterface::WIFI); // CameraImageOrientation enum bindings - cameraImageOrientation - .value("AUTO", CameraImageOrientation::AUTO) + cameraImageOrientation.value("AUTO", CameraImageOrientation::AUTO) .value("NORMAL", CameraImageOrientation::NORMAL) .value("HORIZONTAL_MIRROR", CameraImageOrientation::HORIZONTAL_MIRROR) .value("VERTICAL_FLIP", CameraImageOrientation::VERTICAL_FLIP) - .value("ROTATE_180_DEG", CameraImageOrientation::ROTATE_180_DEG) - ; + .value("ROTATE_180_DEG", CameraImageOrientation::ROTATE_180_DEG); // CameraFeatures - cameraFeatures - .def(py::init<>()) + cameraFeatures.def(py::init<>()) .def_readwrite("socket", &CameraFeatures::socket) .def_readwrite("sensorName", &CameraFeatures::sensorName) .def_readwrite("width", &CameraFeatures::width) @@ -286,8 +255,7 @@ void CommonBindings::bind(pybind11::module& m, void* pCallstack){ ; // CameraSensorConfig - cameraSensorConfig - .def(py::init<>()) + cameraSensorConfig.def(py::init<>()) .def_readwrite("width", &CameraSensorConfig::width) .def_readwrite("height", &CameraSensorConfig::height) .def_readwrite("minFps", &CameraSensorConfig::minFps) @@ -298,30 +266,24 @@ void CommonBindings::bind(pybind11::module& m, void* pCallstack){ std::stringstream stream; stream << config; return stream.str(); - }) - ; + }); // MemoryInfo - memoryInfo - .def(py::init<>()) + memoryInfo.def(py::init<>()) .def_readwrite("remaining", &MemoryInfo::remaining) .def_readwrite("used", &MemoryInfo::used) - .def_readwrite("total", &MemoryInfo::total) - ; + .def_readwrite("total", &MemoryInfo::total); // ChipTemperature - chipTemperature - .def(py::init<>()) + chipTemperature.def(py::init<>()) .def_readwrite("css", &ChipTemperature::css) .def_readwrite("mss", &ChipTemperature::mss) .def_readwrite("upa", &ChipTemperature::upa) .def_readwrite("dss", &ChipTemperature::dss) - .def_readwrite("average", &ChipTemperature::average) - ; + .def_readwrite("average", &ChipTemperature::average); // ChipTemperatureS3 - chipTemperatureS3 - .def(py::init<>()) + chipTemperatureS3.def(py::init<>()) .def_readwrite("css", &ChipTemperatureS3::css) .def_readwrite("mss", &ChipTemperatureS3::mss) .def_readwrite("nce", &ChipTemperatureS3::nce) @@ -329,52 +291,39 @@ void CommonBindings::bind(pybind11::module& m, void* pCallstack){ .def_readwrite("average", &ChipTemperatureS3::average); // CpuUsage - cpuUsage - .def(py::init<>()) - .def_readwrite("average", &CpuUsage::average) - .def_readwrite("msTime", &CpuUsage::msTime) - ; + cpuUsage.def(py::init<>()).def_readwrite("average", &CpuUsage::average).def_readwrite("msTime", &CpuUsage::msTime); // CameraModel enum bindings - cameraModel - .value("Perspective", CameraModel::Perspective) + cameraModel.value("Perspective", CameraModel::Perspective) .value("Fisheye", CameraModel::Fisheye) .value("Equirectangular", CameraModel::Equirectangular) - .value("RadialDivision", CameraModel::RadialDivision) - ; + .value("RadialDivision", CameraModel::RadialDivision); // StereoRectification - stereoRectification - .def(py::init<>()) + stereoRectification.def(py::init<>()) .def_readwrite("rectifiedRotationLeft", &StereoRectification::rectifiedRotationLeft) .def_readwrite("rectifiedRotationRight", &StereoRectification::rectifiedRotationRight) .def_readwrite("leftCameraSocket", &StereoRectification::leftCameraSocket) - .def_readwrite("rightCameraSocket", &StereoRectification::rightCameraSocket) - ; + .def_readwrite("rightCameraSocket", &StereoRectification::rightCameraSocket); // Extrinsics - extrinsics - .def(py::init<>()) + extrinsics.def(py::init<>()) .def_readwrite("rotationMatrix", &Extrinsics::rotationMatrix) .def_readwrite("translation", &Extrinsics::translation) .def_readwrite("specTranslation", &Extrinsics::specTranslation) - .def_readwrite("toCameraSocket", &Extrinsics::toCameraSocket) - ; + .def_readwrite("toCameraSocket", &Extrinsics::toCameraSocket); // CameraInfo - cameraInfo - .def(py::init<>()) + cameraInfo.def(py::init<>()) .def_readwrite("width", &CameraInfo::width) .def_readwrite("height", &CameraInfo::height) .def_readwrite("intrinsicMatrix", &CameraInfo::intrinsicMatrix) .def_readwrite("distortionCoeff", &CameraInfo::distortionCoeff) .def_readwrite("extrinsics", &CameraInfo::extrinsics) .def_readwrite("cameraType", &CameraInfo::cameraType) - .def_readwrite("specHfovDeg", &CameraInfo::specHfovDeg) - ; + .def_readwrite("specHfovDeg", &CameraInfo::specHfovDeg); // EepromData - eepromData - .def(py::init<>()) + eepromData.def(py::init<>()) .def_readwrite("version", &EepromData::version) .def_readwrite("boardCustom", &EepromData::boardCustom) .def_readwrite("boardName", &EepromData::boardName) @@ -393,61 +342,39 @@ void CommonBindings::bind(pybind11::module& m, void* pCallstack){ .def_readwrite("housingExtrinsics", &EepromData::housingExtrinsics) .def_readwrite("stereoUseSpecTranslation", &EepromData::stereoUseSpecTranslation) .def_readwrite("stereoEnableDistortionCorrection", &EepromData::stereoEnableDistortionCorrection) - .def_readwrite("verticalCameraSocket", &EepromData::verticalCameraSocket) - ; + .def_readwrite("verticalCameraSocket", &EepromData::verticalCameraSocket); // UsbSpeed - usbSpeed - .value("UNKNOWN", UsbSpeed::UNKNOWN) + usbSpeed.value("UNKNOWN", UsbSpeed::UNKNOWN) .value("LOW", UsbSpeed::LOW) .value("FULL", UsbSpeed::FULL) .value("HIGH", UsbSpeed::HIGH) .value("SUPER", UsbSpeed::SUPER) - .value("SUPER_PLUS", UsbSpeed::SUPER_PLUS) - ; + .value("SUPER_PLUS", UsbSpeed::SUPER_PLUS); // ProcessorType - processorType - .value("LEON_CSS", ProcessorType::LEON_CSS) - .value("LEON_MSS", ProcessorType::LEON_MSS) - ; + processorType.value("LEON_CSS", ProcessorType::LEON_CSS).value("LEON_MSS", ProcessorType::LEON_MSS); - detectionNetworkType - .value("YOLO", DetectionNetworkType::YOLO) - .value("MOBILENET", DetectionNetworkType::MOBILENET) - ; + detectionNetworkType.value("YOLO", DetectionNetworkType::YOLO).value("MOBILENET", DetectionNetworkType::MOBILENET); - serializationType - .value("LIBNOP", SerializationType::LIBNOP) - .value("JSON", SerializationType::JSON) - .value("JSON_MSGPACK", SerializationType::JSON_MSGPACK) - ; + serializationType.value("LIBNOP", SerializationType::LIBNOP).value("JSON", SerializationType::JSON).value("JSON_MSGPACK", SerializationType::JSON_MSGPACK); - detectionParserOptions - .def_readwrite("nnFamily", &DetectionParserOptions::nnFamily) + detectionParserOptions.def_readwrite("nnFamily", &DetectionParserOptions::nnFamily) .def_readwrite("confidenceThreshold", &DetectionParserOptions::confidenceThreshold) .def_readwrite("classes", &DetectionParserOptions::classes) .def_readwrite("coordinates", &DetectionParserOptions::coordinates) .def_readwrite("anchors", &DetectionParserOptions::anchors) .def_readwrite("anchorMasks", &DetectionParserOptions::anchorMasks) - .def_readwrite("iouThreshold", &DetectionParserOptions::iouThreshold) - ; + .def_readwrite("iouThreshold", &DetectionParserOptions::iouThreshold); - cameraExposureOffset - .value("START", CameraExposureOffset::START) - .value("MIDDLE", CameraExposureOffset::MIDDLE) - .value("END", CameraExposureOffset::END) - ; + cameraExposureOffset.value("START", CameraExposureOffset::START).value("MIDDLE", CameraExposureOffset::MIDDLE).value("END", CameraExposureOffset::END); - color - .def(py::init<>()) + color.def(py::init<>()) .def(py::init(), py::arg("r"), py::arg("g"), py::arg("b"), py::arg("a") = 1.0, DOC(dai, Color, Color)) .def_readwrite("r", &Color::r) .def_readwrite("g", &Color::g) .def_readwrite("b", &Color::b) - .def_readwrite("a", &Color::a) - ; - colormap - .value("NONE", Colormap::NONE) + .def_readwrite("a", &Color::a); + colormap.value("NONE", Colormap::NONE) .value("JET", Colormap::JET) .value("TURBO", Colormap::TURBO) .value("STEREO_JET", Colormap::STEREO_JET) @@ -472,29 +399,20 @@ void CommonBindings::bind(pybind11::module& m, void* pCallstack){ // .value("TWILIGHT", Colormap::TWILIGHT) // .value("TWILIGHT_SHIFTED", Colormap::TWILIGHT_SHIFTED) // .value("DEEPGREEN", Colormap::DEEPGREEN) - ; + ; - frameEvent - .value("NONE", FrameEvent::NONE) - .value("READOUT_START", FrameEvent::READOUT_START) - .value("READOUT_END", FrameEvent::READOUT_END) - ; + frameEvent.value("NONE", FrameEvent::NONE).value("READOUT_START", FrameEvent::READOUT_START).value("READOUT_END", FrameEvent::READOUT_END); - interpolation - .value("BILINEAR", Interpolation::BILINEAR) + interpolation.value("BILINEAR", Interpolation::BILINEAR) .value("BICUBIC", Interpolation::BICUBIC) .value("NEAREST_NEIGHBOR", Interpolation::NEAREST_NEIGHBOR) .value("BYPASS", Interpolation::BYPASS) .value("DEFAULT", Interpolation::DEFAULT) - .value("DEFAULT_DISPARITY_DEPTH", Interpolation::DEFAULT_DISPARITY_DEPTH) - ; - - //backward compatibility - //m.attr("node").attr("Warp").attr("Properties").attr("Interpolation") = interpolation; + .value("DEFAULT_DISPARITY_DEPTH", Interpolation::DEFAULT_DISPARITY_DEPTH); - profilingData - .def_readwrite("numBytesWritten", &ProfilingData::numBytesWritten, DOC(dai, ProfilingData, numBytesWritten)) - .def_readwrite("numBytesRead", &ProfilingData::numBytesRead, DOC(dai, ProfilingData, numBytesRead)) - ; + // backward compatibility + // m.attr("node").attr("Warp").attr("Properties").attr("Interpolation") = interpolation; + profilingData.def_readwrite("numBytesWritten", &ProfilingData::numBytesWritten, DOC(dai, ProfilingData, numBytesWritten)) + .def_readwrite("numBytesRead", &ProfilingData::numBytesRead, DOC(dai, ProfilingData, numBytesRead)); } diff --git a/bindings/python/src/pipeline/PipelineBindings.cpp b/bindings/python/src/pipeline/PipelineBindings.cpp index 91f9f6163..5d063419b 100644 --- a/bindings/python/src/pipeline/PipelineBindings.cpp +++ b/bindings/python/src/pipeline/PipelineBindings.cpp @@ -11,52 +11,53 @@ #include "depthai/pipeline/ThreadedHostNode.hpp" // depthai - nodes -#include "depthai/pipeline/node/XLinkIn.hpp" -#include "depthai/pipeline/node/XLinkOut.hpp" -#include "depthai/pipeline/node/BenchmarkOut.hpp" +#include "depthai/pipeline/node/AprilTag.hpp" #include "depthai/pipeline/node/BenchmarkIn.hpp" -#include "depthai/pipeline/node/NeuralNetwork.hpp" -#include "depthai/pipeline/node/ColorCamera.hpp" +#include "depthai/pipeline/node/BenchmarkOut.hpp" #include "depthai/pipeline/node/Camera.hpp" -#include "depthai/pipeline/node/VideoEncoder.hpp" -#include "depthai/pipeline/node/SPIOut.hpp" -#include "depthai/pipeline/node/SPIIn.hpp" +#include "depthai/pipeline/node/ColorCamera.hpp" +#include "depthai/pipeline/node/DetectionNetwork.hpp" +#include "depthai/pipeline/node/DetectionParser.hpp" +#include "depthai/pipeline/node/EdgeDetector.hpp" +#include "depthai/pipeline/node/FeatureTracker.hpp" +#include "depthai/pipeline/node/IMU.hpp" #include "depthai/pipeline/node/ImageManip.hpp" #include "depthai/pipeline/node/ImageManipV2.hpp" #include "depthai/pipeline/node/MonoCamera.hpp" -#include "depthai/pipeline/node/StereoDepth.hpp" -#include "depthai/pipeline/node/DetectionNetwork.hpp" +#include "depthai/pipeline/node/NeuralNetwork.hpp" +#include "depthai/pipeline/node/ObjectTracker.hpp" +#include "depthai/pipeline/node/SPIIn.hpp" +#include "depthai/pipeline/node/SPIOut.hpp" #include "depthai/pipeline/node/Script.hpp" -#include "depthai/pipeline/node/SystemLogger.hpp" -#include "depthai/pipeline/node/SpatialLocationCalculator.hpp" #include "depthai/pipeline/node/SpatialDetectionNetwork.hpp" -#include "depthai/pipeline/node/ObjectTracker.hpp" -#include "depthai/pipeline/node/IMU.hpp" -#include "depthai/pipeline/node/EdgeDetector.hpp" -#include "depthai/pipeline/node/FeatureTracker.hpp" -#include "depthai/pipeline/node/AprilTag.hpp" -#include "depthai/pipeline/node/DetectionParser.hpp" +#include "depthai/pipeline/node/SpatialLocationCalculator.hpp" +#include "depthai/pipeline/node/StereoDepth.hpp" +#include "depthai/pipeline/node/SystemLogger.hpp" #include "depthai/pipeline/node/UVC.hpp" +#include "depthai/pipeline/node/VideoEncoder.hpp" #include "depthai/pipeline/node/Warp.hpp" +#include "depthai/pipeline/node/XLinkIn.hpp" +#include "depthai/pipeline/node/XLinkOut.hpp" // depthai/ +#include + #include "depthai/properties/GlobalProperties.hpp" #include "depthai/utility/RecordReplay.hpp" -#include -std::shared_ptr createNode(dai::Pipeline& p, py::object class_){ +std::shared_ptr createNode(dai::Pipeline& p, py::object class_) { auto nodeCreateMap = NodeBindings::getNodeCreateMap(); - for(auto& kv : nodeCreateMap){ + for(auto& kv : nodeCreateMap) { auto& node = kv.first; auto& create = kv.second; - if(node.is(class_)){ + if(node.is(class_)) { return create(p, class_); } } return nullptr; } -void PipelineBindings::bind(pybind11::module& m, void* pCallstack){ +void PipelineBindings::bind(pybind11::module& m, void* pCallstack) { using namespace dai; // Type definitions @@ -69,7 +70,7 @@ void PipelineBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -78,10 +79,8 @@ void PipelineBindings::bind(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// - // Bind global properties - globalProperties - .def_readwrite("leonOsFrequencyHz", &GlobalProperties::leonCssFrequencyHz) + globalProperties.def_readwrite("leonOsFrequencyHz", &GlobalProperties::leonCssFrequencyHz) .def_readwrite("leonRtFrequencyHz", &GlobalProperties::leonMssFrequencyHz) .def_readwrite("pipelineName", &GlobalProperties::pipelineName) .def_readwrite("pipelineVersion", &GlobalProperties::pipelineVersion) @@ -89,19 +88,16 @@ void PipelineBindings::bind(pybind11::module& m, void* pCallstack){ .def_readwrite("cameraTuningBlobUri", &GlobalProperties::cameraTuningBlobUri, DOC(dai, GlobalProperties, cameraTuningBlobUri)) .def_readwrite("xlinkChunkSize", &GlobalProperties::xlinkChunkSize, DOC(dai, GlobalProperties, xlinkChunkSize)) .def_readwrite("sippBufferSize", &GlobalProperties::sippBufferSize, DOC(dai, GlobalProperties, sippBufferSize)) - .def_readwrite("sippDmaBufferSize", &GlobalProperties::sippDmaBufferSize, DOC(dai, GlobalProperties, sippDmaBufferSize)) - ; + .def_readwrite("sippDmaBufferSize", &GlobalProperties::sippDmaBufferSize, DOC(dai, GlobalProperties, sippDmaBufferSize)); - recordVideoConfig - .def(py::init<>()) + recordVideoConfig.def(py::init<>()) .def_readwrite("enabled", &RecordConfig::VideoEncoding::enabled, DOC(dai, RecordConfig, VideoEncoding, enabled)) .def_readwrite("bitrate", &RecordConfig::VideoEncoding::bitrate, DOC(dai, RecordConfig, VideoEncoding, bitrate)) .def_readwrite("profile", &RecordConfig::VideoEncoding::profile, DOC(dai, RecordConfig, VideoEncoding, profile)) .def_readwrite("lossless", &RecordConfig::VideoEncoding::lossless, DOC(dai, RecordConfig, VideoEncoding, lossless)) .def_readwrite("quality", &RecordConfig::VideoEncoding::quality, DOC(dai, RecordConfig, VideoEncoding, quality)); - recordConfig - .def(py::init<>()) + recordConfig.def(py::init<>()) .def_readwrite("outputDir", &RecordConfig::outputDir, DOC(dai, RecordConfig, outputDir)) .def_readwrite("videoEncoding", &RecordConfig::videoEncoding, DOC(dai, RecordConfig, videoEncoding)) .def_readwrite("compressionLevel", &RecordConfig::compressionLevel, DOC(dai, RecordConfig, compressionLevel)); @@ -169,43 +165,45 @@ void PipelineBindings::bind(pybind11::module& m, void* pCallstack){ }, py::keep_alive<1, 2>()) // 'Template' create function - .def("create", - [](dai::Pipeline& p, py::object class_, const py::args& args, const py::kwargs& kwargs) { - // Check if class_ is a subclass of HostNode - py::object issubclass = py::module::import("builtins").attr("issubclass"); - py::object nodeClass = py::module::import("depthai").attr("node").attr("ThreadedHostNode"); - auto isSubclass = issubclass(class_, nodeClass).cast(); + .def( + "create", + [](dai::Pipeline& p, py::object class_, const py::args& args, const py::kwargs& kwargs) { + // Check if class_ is a subclass of HostNode + py::object issubclass = py::module::import("builtins").attr("issubclass"); + py::object nodeClass = py::module::import("depthai").attr("node").attr("ThreadedHostNode"); + auto isSubclass = issubclass(class_, nodeClass).cast(); - // Check if the class is directly from bindings (__module__ == "depthai.node"). If so, the node comes from bindings, - // so we create in the same manner as device nodes. - auto isFromBindings = class_.attr("__module__").cast() == "depthai.node"; - // Create a copy from kwargs and add autoAddToPipeline to false - if(isSubclass && !isFromBindings) { - setImplicitPipeline(&p); - std::shared_ptr hostNode = py::cast>(class_(*args, **kwargs)); - delImplicitPipeline(); - // Node already adds itself to the pipeline in the constructor - // To be sure - check if it is already added - auto allNodes = p.getAllNodes(); - auto found = false; - for(auto& n : allNodes) { - if(n == hostNode) { - found = true; - break; - } - } - if(!found) { - throw std::invalid_argument("Internal error: Node wasn't added to the pipeline"); - } - return hostNode; - } - // Otherwise create the node with `pipeline.create()` method - auto node = createNode(p, class_); - if(node == nullptr) { - throw std::invalid_argument(std::string(py::str(class_)) + " is not a subclass of depthai.node"); - } - return node; - }, py::keep_alive<1,0>()) + // Check if the class is directly from bindings (__module__ == "depthai.node"). If so, the node comes from bindings, + // so we create in the same manner as device nodes. + auto isFromBindings = class_.attr("__module__").cast() == "depthai.node"; + // Create a copy from kwargs and add autoAddToPipeline to false + if(isSubclass && !isFromBindings) { + setImplicitPipeline(&p); + std::shared_ptr hostNode = py::cast>(class_(*args, **kwargs)); + delImplicitPipeline(); + // Node already adds itself to the pipeline in the constructor + // To be sure - check if it is already added + auto allNodes = p.getAllNodes(); + auto found = false; + for(auto& n : allNodes) { + if(n == hostNode) { + found = true; + break; + } + } + if(!found) { + throw std::invalid_argument("Internal error: Node wasn't added to the pipeline"); + } + return hostNode; + } + // Otherwise create the node with `pipeline.create()` method + auto node = createNode(p, class_); + if(node == nullptr) { + throw std::invalid_argument(std::string(py::str(class_)) + " is not a subclass of depthai.node"); + } + return node; + }, + py::keep_alive<1, 0>()) // TODO(themarpe) DEPRECATE, use pipeline.create([class name]) // templated create function .def("createXLinkIn", &Pipeline::create) @@ -265,6 +263,4 @@ void PipelineBindings::bind(pybind11::module& m, void* pCallstack){ .def("enableHolisticRecord", &Pipeline::enableHolisticRecord, py::arg("recordConfig"), DOC(dai, Pipeline, enableHolisticRecord)) .def("enableHolisticReplay", &Pipeline::enableHolisticReplay, py::arg("recordingPath"), DOC(dai, Pipeline, enableHolisticReplay)); ; - - } diff --git a/bindings/python/src/pipeline/datatype/ADatatypeBindings.cpp b/bindings/python/src/pipeline/datatype/ADatatypeBindings.cpp index f70eb6841..b6b3d960b 100644 --- a/bindings/python/src/pipeline/datatype/ADatatypeBindings.cpp +++ b/bindings/python/src/pipeline/datatype/ADatatypeBindings.cpp @@ -1,12 +1,13 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/ADatatype.hpp" -//pybind +// pybind #include #include @@ -17,10 +18,9 @@ class PyADataType : public ADatatype { public: using ADatatype::ADatatype; }; -} // namespace dai - -void bind_adatatype(pybind11::module& m, void* pCallstack){ +} // namespace dai +void bind_adatatype(pybind11::module& m, void* pCallstack) { using namespace dai; py::class_> adatatype(m, "ADatatype", DOC(dai, ADatatype)); @@ -29,7 +29,7 @@ void bind_adatatype(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -41,6 +41,5 @@ void bind_adatatype(pybind11::module& m, void* pCallstack){ adatatype.def(py::init<>(), DOC(dai, ADatatype, ADatatype)); // Message // adatatype - // .def("getRaw", &ADatatype::getRaw); - + // .def("getRaw", &ADatatype::getRaw); } diff --git a/bindings/python/src/pipeline/datatype/AprilTagConfigBindings.cpp b/bindings/python/src/pipeline/datatype/AprilTagConfigBindings.cpp index ad867505d..220623676 100644 --- a/bindings/python/src/pipeline/datatype/AprilTagConfigBindings.cpp +++ b/bindings/python/src/pipeline/datatype/AprilTagConfigBindings.cpp @@ -1,19 +1,19 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/AprilTagConfig.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_apriltagconfig(pybind11::module& m, void* pCallstack){ - +void bind_apriltagconfig(pybind11::module& m, void* pCallstack) { using namespace dai; // py::class_> @@ -26,7 +26,7 @@ void bind_apriltagconfig(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -36,40 +36,32 @@ void bind_apriltagconfig(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Metadata / raw - aprilTagFamily - .value("TAG_36H11", AprilTagConfig::Family::TAG_36H11) + aprilTagFamily.value("TAG_36H11", AprilTagConfig::Family::TAG_36H11) .value("TAG_36H10", AprilTagConfig::Family::TAG_36H10) .value("TAG_25H9", AprilTagConfig::Family::TAG_25H9) .value("TAG_16H5", AprilTagConfig::Family::TAG_16H5) .value("TAG_CIR21H7", AprilTagConfig::Family::TAG_CIR21H7) - .value("TAG_STAND41H12", AprilTagConfig::Family::TAG_STAND41H12) - ; + .value("TAG_STAND41H12", AprilTagConfig::Family::TAG_STAND41H12); - quadThresholds - .def(py::init<>()) + quadThresholds.def(py::init<>()) .def_readwrite("minClusterPixels", &AprilTagConfig::QuadThresholds::minClusterPixels, DOC(dai, AprilTagConfig, QuadThresholds, minClusterPixels)) .def_readwrite("maxNmaxima", &AprilTagConfig::QuadThresholds::maxNmaxima, DOC(dai, AprilTagConfig, QuadThresholds, maxNmaxima)) .def_readwrite("criticalDegree", &AprilTagConfig::QuadThresholds::criticalDegree, DOC(dai, AprilTagConfig, QuadThresholds, criticalDegree)) .def_readwrite("maxLineFitMse", &AprilTagConfig::QuadThresholds::maxLineFitMse, DOC(dai, AprilTagConfig, QuadThresholds, maxLineFitMse)) .def_readwrite("minWhiteBlackDiff", &AprilTagConfig::QuadThresholds::minWhiteBlackDiff, DOC(dai, AprilTagConfig, QuadThresholds, minWhiteBlackDiff)) - .def_readwrite("deglitch", &AprilTagConfig::QuadThresholds::deglitch, DOC(dai, AprilTagConfig, QuadThresholds, deglitch)) - ; - + .def_readwrite("deglitch", &AprilTagConfig::QuadThresholds::deglitch, DOC(dai, AprilTagConfig, QuadThresholds, deglitch)); - aprilTagConfig - .def(py::init<>()) + aprilTagConfig.def(py::init<>()) .def_readwrite("family", &AprilTagConfig::family, DOC(dai, AprilTagConfig, family)) .def_readwrite("quadDecimate", &AprilTagConfig::quadDecimate, DOC(dai, AprilTagConfig, quadDecimate)) .def_readwrite("quadSigma", &AprilTagConfig::quadSigma, DOC(dai, AprilTagConfig, quadSigma)) .def_readwrite("refineEdges", &AprilTagConfig::refineEdges, DOC(dai, AprilTagConfig, refineEdges)) .def_readwrite("decodeSharpening", &AprilTagConfig::decodeSharpening, DOC(dai, AprilTagConfig, decodeSharpening)) .def_readwrite("maxHammingDistance", &AprilTagConfig::maxHammingDistance, DOC(dai, AprilTagConfig, maxHammingDistance)) - .def_readwrite("quadThresholds", &AprilTagConfig::quadThresholds, DOC(dai, AprilTagConfig, quadThresholds)) - ; + .def_readwrite("quadThresholds", &AprilTagConfig::quadThresholds, DOC(dai, AprilTagConfig, quadThresholds)); // Message - aprilTagConfig - .def(py::init<>()) + aprilTagConfig.def(py::init<>()) .def("__repr__", &AprilTagConfig::str) .def("setFamily", &AprilTagConfig::setFamily, py::arg("family"), DOC(dai, AprilTagConfig, setFamily)) // .def("set", &AprilTagConfig::set, DOC(dai, AprilTagConfig, set)) @@ -77,5 +69,4 @@ void bind_apriltagconfig(pybind11::module& m, void* pCallstack){ ; m.attr("AprilTagConfig").attr("Family") = m.attr("AprilTagConfig").attr("Family"); m.attr("AprilTagConfig").attr("QuadThresholds") = m.attr("AprilTagConfig").attr("QuadThresholds"); - } diff --git a/bindings/python/src/pipeline/datatype/AprilTagsBindings.cpp b/bindings/python/src/pipeline/datatype/AprilTagsBindings.cpp index 8d06d4f3b..c9e21910a 100644 --- a/bindings/python/src/pipeline/datatype/AprilTagsBindings.cpp +++ b/bindings/python/src/pipeline/datatype/AprilTagsBindings.cpp @@ -1,19 +1,19 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/AprilTags.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_apriltags(pybind11::module& m, void* pCallstack){ - +void bind_apriltags(pybind11::module& m, void* pCallstack) { using namespace dai; py::class_ aprilTag(m, "AprilTag", DOC(dai, AprilTag)); @@ -23,7 +23,7 @@ void bind_apriltags(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -33,22 +33,20 @@ void bind_apriltags(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Metadata / raw - aprilTag - .def(py::init<>()) + aprilTag.def(py::init<>()) .def_readwrite("id", &AprilTag::id, DOC(dai, AprilTag, id)) .def_readwrite("hamming", &AprilTag::hamming, DOC(dai, AprilTag, hamming)) .def_readwrite("decisionMargin", &AprilTag::decisionMargin, DOC(dai, AprilTag, decisionMargin)) .def_readwrite("topLeft", &AprilTag::topLeft, DOC(dai, AprilTag, topLeft)) .def_readwrite("topRight", &AprilTag::topRight, DOC(dai, AprilTag, topRight)) .def_readwrite("bottomRight", &AprilTag::bottomRight, DOC(dai, AprilTag, bottomRight)) - .def_readwrite("bottomLeft", &AprilTag::bottomLeft, DOC(dai, AprilTag, bottomLeft)) - ; + .def_readwrite("bottomLeft", &AprilTag::bottomLeft, DOC(dai, AprilTag, bottomLeft)); // Message - aprilTags - .def(py::init<>()) + aprilTags.def(py::init<>()) .def("__repr__", &AprilTags::str) - .def_property("aprilTags", [](AprilTags& det) { return &det.aprilTags; }, [](AprilTags& det, std::vector val) { det.aprilTags = val; }) + .def_property( + "aprilTags", [](AprilTags& det) { return &det.aprilTags; }, [](AprilTags& det, std::vector val) { det.aprilTags = val; }) .def("getTimestamp", &AprilTags::Buffer::getTimestamp, DOC(dai, Buffer, getTimestamp)) .def("getTimestampDevice", &AprilTags::Buffer::getTimestampDevice, DOC(dai, Buffer, getTimestampDevice)) .def("getSequenceNum", &AprilTags::Buffer::getSequenceNum, DOC(dai, Buffer, getSequenceNum)) @@ -56,5 +54,4 @@ void bind_apriltags(pybind11::module& m, void* pCallstack){ // .def("setTimestampDevice", &AprilTags::setTimestampDevice, DOC(dai, Buffer, setTimestampDevice)) // .def("setSequenceNum", &AprilTags::setSequenceNum, DOC(dai, Buffer, setSequenceNum)) ; - } diff --git a/bindings/python/src/pipeline/datatype/BufferBindings.cpp b/bindings/python/src/pipeline/datatype/BufferBindings.cpp index c0a9e98d2..607bb9d90 100644 --- a/bindings/python/src/pipeline/datatype/BufferBindings.cpp +++ b/bindings/python/src/pipeline/datatype/BufferBindings.cpp @@ -1,19 +1,19 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/Buffer.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_buffer(pybind11::module& m, void* pCallstack){ - +void bind_buffer(pybind11::module& m, void* pCallstack) { using namespace dai; // py::class_> rawBuffer(m, "RawBuffer", DOC(dai, RawBuffer)); @@ -23,7 +23,7 @@ void bind_buffer(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -66,32 +66,37 @@ void bind_buffer(pybind11::module& m, void* pCallstack){ // ; // Message - buffer - .def(py::init<>(), DOC(dai, Buffer, Buffer)) + buffer.def(py::init<>(), DOC(dai, Buffer, Buffer)) .def(py::init(), DOC(dai, Buffer, Buffer, 2)) .def("__repr__", &Buffer::str) // obj is "Python" object, which we used then to bind the numpy arrays lifespan to - .def("getData", [](py::object &obj){ - // creates numpy array (zero-copy) which holds correct information such as shape, ... - dai::Buffer &a = obj.cast(); - return py::array_t(a.getData().size(), a.getData().data(), obj); - }, DOC(dai, Buffer, getData)) + .def( + "getData", + [](py::object& obj) { + // creates numpy array (zero-copy) which holds correct information such as shape, ... + dai::Buffer& a = obj.cast(); + return py::array_t(a.getData().size(), a.getData().data(), obj); + }, + DOC(dai, Buffer, getData)) .def("setData", py::overload_cast&>(&Buffer::setData), DOC(dai, Buffer, setData)) - .def("setData", [](Buffer& buffer, py::array_t array){ - buffer.setData({array.data(), array.data() + array.nbytes()}); - }, DOC(dai, Buffer, setData)) - .def("setData", [](Buffer& buffer, py::buffer data){ - std::string str = data.cast(); - buffer.setData({str.data(), str.data() + str.size()}); - }, DOC(dai, Buffer, setData)) + .def( + "setData", + [](Buffer& buffer, py::array_t array) { + buffer.setData({array.data(), array.data() + array.nbytes()}); + }, + DOC(dai, Buffer, setData)) + .def( + "setData", + [](Buffer& buffer, py::buffer data) { + std::string str = data.cast(); + buffer.setData({str.data(), str.data() + str.size()}); + }, + DOC(dai, Buffer, setData)) .def("getTimestamp", &Buffer::getTimestamp, DOC(dai, Buffer, getTimestamp)) .def("getTimestampDevice", &Buffer::getTimestampDevice, DOC(dai, Buffer, getTimestampDevice)) .def("getSequenceNum", &Buffer::getSequenceNum, DOC(dai, Buffer, getSequenceNum)) .def("setTimestamp", &Buffer::setTimestamp, DOC(dai, Buffer, setTimestamp)) .def("setTimestampDevice", &Buffer::setTimestampDevice, DOC(dai, Buffer, setTimestampDevice)) .def("setSequenceNum", &Buffer::setSequenceNum, DOC(dai, Buffer, setSequenceNum)) - .def("getVisualizationMessage", &Buffer::getVisualizationMessage, DOC(dai, Buffer, getVisualizationMessage)) - ; - - + .def("getVisualizationMessage", &Buffer::getVisualizationMessage, DOC(dai, Buffer, getVisualizationMessage)); } diff --git a/bindings/python/src/pipeline/datatype/CameraControlBindings.cpp b/bindings/python/src/pipeline/datatype/CameraControlBindings.cpp index 4455a1497..5a42c074a 100644 --- a/bindings/python/src/pipeline/datatype/CameraControlBindings.cpp +++ b/bindings/python/src/pipeline/datatype/CameraControlBindings.cpp @@ -1,26 +1,27 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/CameraControl.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_cameracontrol(pybind11::module& m, void* pCallstack){ - +void bind_cameracontrol(pybind11::module& m, void* pCallstack) { using namespace dai; // py::class_> rawCameraControl(m, "RawCameraControl", DOC(dai, RawCameraControl)); py::class_, Buffer, std::shared_ptr> cameraControl(m, "CameraControl", DOC(dai, CameraControl)); py::enum_ cameraControlCommand(cameraControl, "Command", DOC(dai, CameraControl, Command)); py::enum_ cameraControlAutoFocusMode(cameraControl, "AutoFocusMode", DOC(dai, CameraControl, AutoFocusMode)); - py::enum_ cameraControlAutoWhiteBalanceMode(cameraControl, "AutoWhiteBalanceMode", DOC(dai, CameraControl, AutoWhiteBalanceMode)); + py::enum_ cameraControlAutoWhiteBalanceMode( + cameraControl, "AutoWhiteBalanceMode", DOC(dai, CameraControl, AutoWhiteBalanceMode)); py::enum_ cameraControlSceneMode(cameraControl, "SceneMode", DOC(dai, CameraControl, SceneMode)); py::enum_ cameraControlControlMode(cameraControl, "ControlMode", DOC(dai, CameraControl, ControlMode)); py::enum_ cameraControlCaptureIntent(cameraControl, "CaptureIntent", DOC(dai, CameraControl, CaptureIntent)); @@ -32,7 +33,7 @@ void bind_cameracontrol(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -42,10 +43,9 @@ void bind_cameracontrol(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Metadata / raw -std::vector camCtrlAttr; + std::vector camCtrlAttr; camCtrlAttr.push_back("Command"); - cameraControlCommand - .value("START_STREAM", CameraControl::Command::START_STREAM) + cameraControlCommand.value("START_STREAM", CameraControl::Command::START_STREAM) .value("STOP_STREAM", CameraControl::Command::STOP_STREAM) .value("STILL_CAPTURE", CameraControl::Command::STILL_CAPTURE) .value("MOVE_LENS", CameraControl::Command::MOVE_LENS) @@ -80,22 +80,18 @@ std::vector camCtrlAttr; .value("AF_REGION", CameraControl::Command::AF_REGION) .value("LUMA_DENOISE", CameraControl::Command::LUMA_DENOISE) .value("CHROMA_DENOISE", CameraControl::Command::CHROMA_DENOISE) - .value("WB_COLOR_TEMP", CameraControl::Command::WB_COLOR_TEMP) - ; + .value("WB_COLOR_TEMP", CameraControl::Command::WB_COLOR_TEMP); camCtrlAttr.push_back("AutoFocusMode"); - cameraControlAutoFocusMode - .value("OFF", CameraControl::AutoFocusMode::OFF) + cameraControlAutoFocusMode.value("OFF", CameraControl::AutoFocusMode::OFF) .value("AUTO", CameraControl::AutoFocusMode::AUTO) .value("MACRO", CameraControl::AutoFocusMode::MACRO) .value("CONTINUOUS_VIDEO", CameraControl::AutoFocusMode::CONTINUOUS_VIDEO) .value("CONTINUOUS_PICTURE", CameraControl::AutoFocusMode::CONTINUOUS_PICTURE) - .value("EDOF", CameraControl::AutoFocusMode::EDOF) - ; + .value("EDOF", CameraControl::AutoFocusMode::EDOF); camCtrlAttr.push_back("AutoWhiteBalanceMode"); - cameraControlAutoWhiteBalanceMode - .value("OFF", CameraControl::AutoWhiteBalanceMode::OFF) + cameraControlAutoWhiteBalanceMode.value("OFF", CameraControl::AutoWhiteBalanceMode::OFF) .value("AUTO", CameraControl::AutoWhiteBalanceMode::AUTO) .value("INCANDESCENT", CameraControl::AutoWhiteBalanceMode::INCANDESCENT) .value("FLUORESCENT", CameraControl::AutoWhiteBalanceMode::FLUORESCENT) @@ -103,12 +99,10 @@ std::vector camCtrlAttr; .value("DAYLIGHT", CameraControl::AutoWhiteBalanceMode::DAYLIGHT) .value("CLOUDY_DAYLIGHT", CameraControl::AutoWhiteBalanceMode::CLOUDY_DAYLIGHT) .value("TWILIGHT", CameraControl::AutoWhiteBalanceMode::TWILIGHT) - .value("SHADE", CameraControl::AutoWhiteBalanceMode::SHADE) - ; + .value("SHADE", CameraControl::AutoWhiteBalanceMode::SHADE); camCtrlAttr.push_back("SceneMode"); - cameraControlSceneMode - .value("UNSUPPORTED", CameraControl::SceneMode::UNSUPPORTED) + cameraControlSceneMode.value("UNSUPPORTED", CameraControl::SceneMode::UNSUPPORTED) .value("FACE_PRIORITY", CameraControl::SceneMode::FACE_PRIORITY) .value("ACTION", CameraControl::SceneMode::ACTION) .value("PORTRAIT", CameraControl::SceneMode::PORTRAIT) @@ -124,37 +118,29 @@ std::vector camCtrlAttr; .value("SPORTS", CameraControl::SceneMode::SPORTS) .value("PARTY", CameraControl::SceneMode::PARTY) .value("CANDLELIGHT", CameraControl::SceneMode::CANDLELIGHT) - .value("BARCODE", CameraControl::SceneMode::BARCODE) - ; + .value("BARCODE", CameraControl::SceneMode::BARCODE); camCtrlAttr.push_back("ControlMode"); - cameraControlControlMode - .value("OFF", CameraControl::ControlMode::OFF) + cameraControlControlMode.value("OFF", CameraControl::ControlMode::OFF) .value("AUTO", CameraControl::ControlMode::AUTO) - .value("USE_SCENE_MODE", CameraControl::ControlMode::USE_SCENE_MODE) - ; + .value("USE_SCENE_MODE", CameraControl::ControlMode::USE_SCENE_MODE); camCtrlAttr.push_back("CaptureIntent"); - cameraControlCaptureIntent - .value("CUSTOM", CameraControl::CaptureIntent::CUSTOM) + cameraControlCaptureIntent.value("CUSTOM", CameraControl::CaptureIntent::CUSTOM) .value("PREVIEW", CameraControl::CaptureIntent::PREVIEW) .value("STILL_CAPTURE", CameraControl::CaptureIntent::STILL_CAPTURE) .value("VIDEO_RECORD", CameraControl::CaptureIntent::VIDEO_RECORD) .value("VIDEO_SNAPSHOT", CameraControl::CaptureIntent::VIDEO_SNAPSHOT) - .value("ZERO_SHUTTER_LAG", CameraControl::CaptureIntent::ZERO_SHUTTER_LAG) - ; + .value("ZERO_SHUTTER_LAG", CameraControl::CaptureIntent::ZERO_SHUTTER_LAG); camCtrlAttr.push_back("AntiBandingMode"); - cameraControlAntiBandingMode - .value("OFF", CameraControl::AntiBandingMode::OFF) + cameraControlAntiBandingMode.value("OFF", CameraControl::AntiBandingMode::OFF) .value("MAINS_50_HZ", CameraControl::AntiBandingMode::MAINS_50_HZ) .value("MAINS_60_HZ", CameraControl::AntiBandingMode::MAINS_60_HZ) - .value("AUTO", CameraControl::AntiBandingMode::AUTO) - ; + .value("AUTO", CameraControl::AntiBandingMode::AUTO); camCtrlAttr.push_back("EffectMode"); - cameraControlEffectMode - .value("OFF", CameraControl::EffectMode::OFF) + cameraControlEffectMode.value("OFF", CameraControl::EffectMode::OFF) .value("MONO", CameraControl::EffectMode::MONO) .value("NEGATIVE", CameraControl::EffectMode::NEGATIVE) .value("SOLARIZE", CameraControl::EffectMode::SOLARIZE) @@ -162,18 +148,14 @@ std::vector camCtrlAttr; .value("POSTERIZE", CameraControl::EffectMode::POSTERIZE) .value("WHITEBOARD", CameraControl::EffectMode::WHITEBOARD) .value("BLACKBOARD", CameraControl::EffectMode::BLACKBOARD) - .value("AQUA", CameraControl::EffectMode::AQUA) - ; + .value("AQUA", CameraControl::EffectMode::AQUA); camCtrlAttr.push_back("FrameSyncMode"); - cameraControlFrameSyncMode - .value("OFF", CameraControl::FrameSyncMode::OFF) + cameraControlFrameSyncMode.value("OFF", CameraControl::FrameSyncMode::OFF) .value("OUTPUT", CameraControl::FrameSyncMode::OUTPUT) - .value("INPUT", CameraControl::FrameSyncMode::INPUT) - ; + .value("INPUT", CameraControl::FrameSyncMode::INPUT); - cameraControl - .def(py::init<>()) + cameraControl.def(py::init<>()) .def_readwrite("cmdMask", &CameraControl::cmdMask) .def_readwrite("autoFocusMode", &CameraControl::autoFocusMode) .def_readwrite("lensPosition", &CameraControl::lensPosition) @@ -198,37 +180,72 @@ std::vector camCtrlAttr; .def_readwrite("wbColorTemp", &CameraControl::wbColorTemp) .def("setCommand", &CameraControl::setCommand) .def("clearCommand", &CameraControl::clearCommand) - .def("getCommand", &CameraControl::getCommand) - ; + .def("getCommand", &CameraControl::getCommand); // Message - cameraControl - .def(py::init<>(), DOC(dai, CameraControl, CameraControl)) + cameraControl.def(py::init<>(), DOC(dai, CameraControl, CameraControl)) .def("__repr__", &CameraControl::str) // setters .def("setCaptureStill", &CameraControl::setCaptureStill, py::arg("capture"), DOC(dai, CameraControl, setCaptureStill)) .def("setStartStreaming", &CameraControl::setStartStreaming, DOC(dai, CameraControl, setStartStreaming)) .def("setStopStreaming", &CameraControl::setStopStreaming, DOC(dai, CameraControl, setStopStreaming)) - .def("setExternalTrigger", &CameraControl::setExternalTrigger, py::arg("numFramesBurst"), py::arg("numFramesDiscard"), DOC(dai, CameraControl, setExternalTrigger)) + .def("setExternalTrigger", + &CameraControl::setExternalTrigger, + py::arg("numFramesBurst"), + py::arg("numFramesDiscard"), + DOC(dai, CameraControl, setExternalTrigger)) .def("setFrameSyncMode", &CameraControl::setFrameSyncMode, py::arg("mode"), DOC(dai, CameraControl, setFrameSyncMode)) .def("setStrobeSensor", &CameraControl::setStrobeSensor, py::arg("activeLevel"), DOC(dai, CameraControl, setStrobeSensor)) .def("setStrobeExternal", &CameraControl::setStrobeExternal, py::arg("gpioNumber"), py::arg("activeLevel"), DOC(dai, CameraControl, setStrobeExternal)) .def("setStrobeDisable", &CameraControl::setStrobeDisable, DOC(dai, CameraControl, setStrobeDisable)) .def("setAutoFocusMode", &CameraControl::setAutoFocusMode, py::arg("mode"), DOC(dai, CameraControl, setAutoFocusMode)) .def("setAutoFocusTrigger", &CameraControl::setAutoFocusTrigger, DOC(dai, CameraControl, setAutoFocusTrigger)) - .def("setAutoFocusLensRange", &CameraControl::setAutoFocusLensRange, py::arg("infinityPosition"), py::arg("macroPosition"), DOC(dai, CameraControl, setAutoFocusLensRange)) - .def("setAutoFocusRegion", &CameraControl::setAutoFocusRegion, py::arg("startX"), py::arg("startY"), py::arg("width"), py::arg("height"), DOC(dai, CameraControl, setAutoFocusRegion)) + .def("setAutoFocusLensRange", + &CameraControl::setAutoFocusLensRange, + py::arg("infinityPosition"), + py::arg("macroPosition"), + DOC(dai, CameraControl, setAutoFocusLensRange)) + .def("setAutoFocusRegion", + &CameraControl::setAutoFocusRegion, + py::arg("startX"), + py::arg("startY"), + py::arg("width"), + py::arg("height"), + DOC(dai, CameraControl, setAutoFocusRegion)) .def("setManualFocus", &CameraControl::setManualFocus, py::arg("lensPosition"), DOC(dai, CameraControl, setManualFocus)) .def("setManualFocusRaw", &CameraControl::setManualFocusRaw, py::arg("lensPositionRaw"), DOC(dai, CameraControl, setManualFocusRaw)) .def("setAutoExposureEnable", &CameraControl::setAutoExposureEnable, DOC(dai, CameraControl, setAutoExposureEnable)) .def("setAutoExposureLock", &CameraControl::setAutoExposureLock, py::arg("lock"), DOC(dai, CameraControl, setAutoExposureLock)) - .def("setAutoExposureRegion", &CameraControl::setAutoExposureRegion, py::arg("startX"), py::arg("startY"), py::arg("width"), py::arg("height"), DOC(dai, CameraControl, setAutoExposureRegion)) - .def("setAutoExposureCompensation", &CameraControl::setAutoExposureCompensation, py::arg("compensation"), DOC(dai, CameraControl, setAutoExposureCompensation)) - .def("setAutoExposureLimit", py::overload_cast(&CameraControl::setAutoExposureLimit), py::arg("maxExposureTimeUs"), DOC(dai, CameraControl, setAutoExposureLimit)) - .def("setAutoExposureLimit", py::overload_cast(&CameraControl::setAutoExposureLimit), py::arg("maxExposureTime"), DOC(dai, CameraControl, setAutoExposureLimit, 2)) + .def("setAutoExposureRegion", + &CameraControl::setAutoExposureRegion, + py::arg("startX"), + py::arg("startY"), + py::arg("width"), + py::arg("height"), + DOC(dai, CameraControl, setAutoExposureRegion)) + .def("setAutoExposureCompensation", + &CameraControl::setAutoExposureCompensation, + py::arg("compensation"), + DOC(dai, CameraControl, setAutoExposureCompensation)) + .def("setAutoExposureLimit", + py::overload_cast(&CameraControl::setAutoExposureLimit), + py::arg("maxExposureTimeUs"), + DOC(dai, CameraControl, setAutoExposureLimit)) + .def("setAutoExposureLimit", + py::overload_cast(&CameraControl::setAutoExposureLimit), + py::arg("maxExposureTime"), + DOC(dai, CameraControl, setAutoExposureLimit, 2)) .def("setAntiBandingMode", &CameraControl::setAntiBandingMode, py::arg("mode"), DOC(dai, CameraControl, setAntiBandingMode)) - .def("setManualExposure", py::overload_cast(&CameraControl::setManualExposure), py::arg("exposureTimeUs"), py::arg("sensitivityIso"), DOC(dai, CameraControl, setManualExposure)) - .def("setManualExposure", py::overload_cast(&CameraControl::setManualExposure), py::arg("exposureTime"), py::arg("sensitivityIso"), DOC(dai, CameraControl, setManualExposure, 2)) + .def("setManualExposure", + py::overload_cast(&CameraControl::setManualExposure), + py::arg("exposureTimeUs"), + py::arg("sensitivityIso"), + DOC(dai, CameraControl, setManualExposure)) + .def("setManualExposure", + py::overload_cast(&CameraControl::setManualExposure), + py::arg("exposureTime"), + py::arg("sensitivityIso"), + DOC(dai, CameraControl, setManualExposure, 2)) .def("setAutoWhiteBalanceMode", &CameraControl::setAutoWhiteBalanceMode, py::arg("mode"), DOC(dai, CameraControl, setAutoWhiteBalanceMode)) .def("setAutoWhiteBalanceLock", &CameraControl::setAutoWhiteBalanceLock, py::arg("lock"), DOC(dai, CameraControl, setAutoWhiteBalanceLock)) .def("setManualWhiteBalance", &CameraControl::setManualWhiteBalance, py::arg("colorTemperatureK"), DOC(dai, CameraControl, setManualWhiteBalance)) @@ -240,9 +257,17 @@ std::vector camCtrlAttr; .def("setChromaDenoise", &CameraControl::setChromaDenoise, py::arg("value"), DOC(dai, CameraControl, setChromaDenoise)) .def("setSceneMode", &CameraControl::setSceneMode, py::arg("mode"), DOC(dai, CameraControl, setSceneMode)) .def("setEffectMode", &CameraControl::setEffectMode, py::arg("mode"), DOC(dai, CameraControl, setEffectMode)) - .def("setMisc", py::overload_cast(&CameraControl::setMisc), py::arg("control"), py::arg("value"), DOC(dai, CameraControl, setMisc)) + .def("setMisc", + py::overload_cast(&CameraControl::setMisc), + py::arg("control"), + py::arg("value"), + DOC(dai, CameraControl, setMisc)) .def("setMisc", py::overload_cast(&CameraControl::setMisc), py::arg("control"), py::arg("value"), DOC(dai, CameraControl, setMisc, 2)) - .def("setMisc", py::overload_cast(&CameraControl::setMisc), py::arg("control"), py::arg("value"), DOC(dai, CameraControl, setMisc, 3)) + .def("setMisc", + py::overload_cast(&CameraControl::setMisc), + py::arg("control"), + py::arg("value"), + DOC(dai, CameraControl, setMisc, 3)) .def("clearMiscControls", &CameraControl::clearMiscControls, DOC(dai, CameraControl, clearMiscControls)) .def("setControlMode", &CameraControl::setControlMode, py::arg("mode"), DOC(dai, CameraControl, setControlMode)) .def("setCaptureIntent", &CameraControl::setCaptureIntent, py::arg("mode"), DOC(dai, CameraControl, setCaptureIntent)) @@ -258,9 +283,7 @@ std::vector camCtrlAttr; // .def("get", &CameraControl::get, DOC(dai, CameraControl, get)) ; // Add also enum attributes from CameraControl - for (const auto& a : camCtrlAttr) { + for(const auto& a : camCtrlAttr) { m.attr("CameraControl").attr(a) = m.attr("CameraControl").attr(a); } - - } diff --git a/bindings/python/src/pipeline/datatype/EdgeDetectorConfigBindings.cpp b/bindings/python/src/pipeline/datatype/EdgeDetectorConfigBindings.cpp index 9617e70ca..61abb6d5b 100644 --- a/bindings/python/src/pipeline/datatype/EdgeDetectorConfigBindings.cpp +++ b/bindings/python/src/pipeline/datatype/EdgeDetectorConfigBindings.cpp @@ -1,30 +1,33 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/EdgeDetectorConfig.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_edgedetectorconfig(pybind11::module& m, void* pCallstack){ - +void bind_edgedetectorconfig(pybind11::module& m, void* pCallstack) { using namespace dai; - py::class_ edgeDetectorConfigData(m, "EdgeDetectorConfigData", DOC(dai, EdgeDetectorConfig, EdgeDetectorConfigData)); - // py::class_> rawEdgeDetectorConfig(m, "RawEdgeDetectorConfig", DOC(dai, RawEdgeDetectorConfig)); - py::class_, Buffer, std::shared_ptr> edgeDetectorConfig(m, "EdgeDetectorConfig", DOC(dai, EdgeDetectorConfig)); + py::class_ edgeDetectorConfigData( + m, "EdgeDetectorConfigData", DOC(dai, EdgeDetectorConfig, EdgeDetectorConfigData)); + // py::class_> rawEdgeDetectorConfig(m, "RawEdgeDetectorConfig", DOC(dai, + // RawEdgeDetectorConfig)); + py::class_, Buffer, std::shared_ptr> edgeDetectorConfig( + m, "EdgeDetectorConfig", DOC(dai, EdgeDetectorConfig)); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -34,11 +37,13 @@ void bind_edgedetectorconfig(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Metadata / raw - edgeDetectorConfigData - .def(py::init<>()) - .def_readwrite("sobelFilterHorizontalKernel", &EdgeDetectorConfig::EdgeDetectorConfigData::sobelFilterHorizontalKernel, DOC(dai, EdgeDetectorConfig, EdgeDetectorConfigData, sobelFilterHorizontalKernel)) - .def_readwrite("sobelFilterVerticalKernel", &EdgeDetectorConfig::EdgeDetectorConfigData::sobelFilterVerticalKernel, DOC(dai, EdgeDetectorConfig, EdgeDetectorConfigData, sobelFilterVerticalKernel)) - ; + edgeDetectorConfigData.def(py::init<>()) + .def_readwrite("sobelFilterHorizontalKernel", + &EdgeDetectorConfig::EdgeDetectorConfigData::sobelFilterHorizontalKernel, + DOC(dai, EdgeDetectorConfig, EdgeDetectorConfigData, sobelFilterHorizontalKernel)) + .def_readwrite("sobelFilterVerticalKernel", + &EdgeDetectorConfig::EdgeDetectorConfigData::sobelFilterVerticalKernel, + DOC(dai, EdgeDetectorConfig, EdgeDetectorConfigData, sobelFilterVerticalKernel)); // rawEdgeDetectorConfig // .def(py::init<>()) @@ -46,13 +51,15 @@ void bind_edgedetectorconfig(pybind11::module& m, void* pCallstack){ // ; // Message - edgeDetectorConfig - .def(py::init<>()) + edgeDetectorConfig.def(py::init<>()) .def("__repr__", &EdgeDetectorConfig::str) - .def("setSobelFilterKernels", &EdgeDetectorConfig::setSobelFilterKernels, py::arg("horizontalKernel"), py::arg("verticalKernel"), DOC(dai, EdgeDetectorConfig, setSobelFilterKernels)) - .def("getConfigData", &EdgeDetectorConfig::getConfigData, DOC(dai, EdgeDetectorConfig, getConfigData)) + .def("setSobelFilterKernels", + &EdgeDetectorConfig::setSobelFilterKernels, + py::arg("horizontalKernel"), + py::arg("verticalKernel"), + DOC(dai, EdgeDetectorConfig, setSobelFilterKernels)) + .def("getConfigData", &EdgeDetectorConfig::getConfigData, DOC(dai, EdgeDetectorConfig, getConfigData)) // .def("get", &EdgeDetectorConfig::get, DOC(dai, EdgeDetectorConfig, get)) // .def("set", &EdgeDetectorConfig::set, py::arg("config"), DOC(dai, EdgeDetectorConfig, set)) ; - } diff --git a/bindings/python/src/pipeline/datatype/FeatureTrackerConfigBindings.cpp b/bindings/python/src/pipeline/datatype/FeatureTrackerConfigBindings.cpp index 5ca21b858..d69e278ca 100644 --- a/bindings/python/src/pipeline/datatype/FeatureTrackerConfigBindings.cpp +++ b/bindings/python/src/pipeline/datatype/FeatureTrackerConfigBindings.cpp @@ -1,36 +1,41 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/FeatureTrackerConfig.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_featuretrackerconfig(pybind11::module& m, void* pCallstack){ - +void bind_featuretrackerconfig(pybind11::module& m, void* pCallstack) { using namespace dai; - // py::class_> rawFeatureTrackerConfig(m, "RawFeatureTrackerConfig", DOC(dai, RawFeatureTrackerConfig)); - py::class_, Buffer, std::shared_ptr> featureTrackerConfig(m, "FeatureTrackerConfig", DOC(dai, FeatureTrackerConfig)); + // py::class_> rawFeatureTrackerConfig(m, "RawFeatureTrackerConfig", DOC(dai, + // RawFeatureTrackerConfig)); + py::class_, Buffer, std::shared_ptr> featureTrackerConfig( + m, "FeatureTrackerConfig", DOC(dai, FeatureTrackerConfig)); py::class_ cornerDetector(featureTrackerConfig, "CornerDetector", DOC(dai, FeatureTrackerConfig, CornerDetector)); py::enum_ cornerDetectorType(cornerDetector, "Type", DOC(dai, FeatureTrackerConfig, CornerDetector, Type)); - py::class_ cornerDetectorThresholds(cornerDetector, "Thresholds", DOC(dai, FeatureTrackerConfig, CornerDetector, Thresholds)); + py::class_ cornerDetectorThresholds( + cornerDetector, "Thresholds", DOC(dai, FeatureTrackerConfig, CornerDetector, Thresholds)); py::class_ motionEstimator(featureTrackerConfig, "MotionEstimator", DOC(dai, FeatureTrackerConfig, MotionEstimator)); py::enum_ motionEstimatorType(motionEstimator, "Type", DOC(dai, FeatureTrackerConfig, MotionEstimator, Type)); - py::class_ motionEstimatorOpticalFlow(motionEstimator, "OpticalFlow", DOC(dai, FeatureTrackerConfig, MotionEstimator, OpticalFlow)); - py::class_ featureMaintainer(featureTrackerConfig, "FeatureMaintainer", DOC(dai, FeatureTrackerConfig, FeatureMaintainer)); + py::class_ motionEstimatorOpticalFlow( + motionEstimator, "OpticalFlow", DOC(dai, FeatureTrackerConfig, MotionEstimator, OpticalFlow)); + py::class_ featureMaintainer( + featureTrackerConfig, "FeatureMaintainer", DOC(dai, FeatureTrackerConfig, FeatureMaintainer)); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -47,76 +52,114 @@ void bind_featuretrackerconfig(pybind11::module& m, void* pCallstack){ // .def_readwrite("featureMaintainer", &FeatureTrackerConfig::featureMaintainer, DOC(dai, FeatureTrackerConfig, featureMaintainer)) // ; - cornerDetectorType - .value("HARRIS", FeatureTrackerConfig::CornerDetector::Type::HARRIS) - .value("SHI_THOMASI", FeatureTrackerConfig::CornerDetector::Type::SHI_THOMASI) - ; + cornerDetectorType.value("HARRIS", FeatureTrackerConfig::CornerDetector::Type::HARRIS) + .value("SHI_THOMASI", FeatureTrackerConfig::CornerDetector::Type::SHI_THOMASI); - cornerDetectorThresholds - .def(py::init<>()) - .def_readwrite("initialValue", &FeatureTrackerConfig::CornerDetector::Thresholds::initialValue, DOC(dai, FeatureTrackerConfig, CornerDetector, Thresholds, initialValue)) + cornerDetectorThresholds.def(py::init<>()) + .def_readwrite("initialValue", + &FeatureTrackerConfig::CornerDetector::Thresholds::initialValue, + DOC(dai, FeatureTrackerConfig, CornerDetector, Thresholds, initialValue)) .def_readwrite("min", &FeatureTrackerConfig::CornerDetector::Thresholds::min, DOC(dai, FeatureTrackerConfig, CornerDetector, Thresholds, min)) .def_readwrite("max", &FeatureTrackerConfig::CornerDetector::Thresholds::max, DOC(dai, FeatureTrackerConfig, CornerDetector, Thresholds, max)) - .def_readwrite("decreaseFactor", &FeatureTrackerConfig::CornerDetector::Thresholds::decreaseFactor, DOC(dai, FeatureTrackerConfig, CornerDetector, Thresholds, decreaseFactor)) - .def_readwrite("increaseFactor", &FeatureTrackerConfig::CornerDetector::Thresholds::increaseFactor, DOC(dai, FeatureTrackerConfig, CornerDetector, Thresholds, increaseFactor)) - ; - - cornerDetector - .def(py::init<>()) + .def_readwrite("decreaseFactor", + &FeatureTrackerConfig::CornerDetector::Thresholds::decreaseFactor, + DOC(dai, FeatureTrackerConfig, CornerDetector, Thresholds, decreaseFactor)) + .def_readwrite("increaseFactor", + &FeatureTrackerConfig::CornerDetector::Thresholds::increaseFactor, + DOC(dai, FeatureTrackerConfig, CornerDetector, Thresholds, increaseFactor)); + + cornerDetector.def(py::init<>()) .def_readwrite("type", &FeatureTrackerConfig::CornerDetector::type, DOC(dai, FeatureTrackerConfig, CornerDetector, type)) - .def_readwrite("cellGridDimension", &FeatureTrackerConfig::CornerDetector::cellGridDimension, DOC(dai, FeatureTrackerConfig, CornerDetector, cellGridDimension)) - .def_readwrite("numTargetFeatures", &FeatureTrackerConfig::CornerDetector::numTargetFeatures, DOC(dai, FeatureTrackerConfig, CornerDetector, numTargetFeatures)) + .def_readwrite( + "cellGridDimension", &FeatureTrackerConfig::CornerDetector::cellGridDimension, DOC(dai, FeatureTrackerConfig, CornerDetector, cellGridDimension)) + .def_readwrite( + "numTargetFeatures", &FeatureTrackerConfig::CornerDetector::numTargetFeatures, DOC(dai, FeatureTrackerConfig, CornerDetector, numTargetFeatures)) .def_readwrite("numMaxFeatures", &FeatureTrackerConfig::CornerDetector::numMaxFeatures, DOC(dai, FeatureTrackerConfig, CornerDetector, numMaxFeatures)) .def_readwrite("enableSobel", &FeatureTrackerConfig::CornerDetector::enableSobel, DOC(dai, FeatureTrackerConfig, CornerDetector, enableSobel)) .def_readwrite("enableSorting", &FeatureTrackerConfig::CornerDetector::enableSorting, DOC(dai, FeatureTrackerConfig, CornerDetector, enableSorting)) - .def_readwrite("thresholds", &FeatureTrackerConfig::CornerDetector::thresholds, DOC(dai, FeatureTrackerConfig, CornerDetector, thresholds)) - ; - - motionEstimatorType - .value("LUCAS_KANADE_OPTICAL_FLOW", FeatureTrackerConfig::MotionEstimator::Type::LUCAS_KANADE_OPTICAL_FLOW) - .value("HW_MOTION_ESTIMATION", FeatureTrackerConfig::MotionEstimator::Type::HW_MOTION_ESTIMATION) - ; - - motionEstimatorOpticalFlow - .def(py::init<>()) - .def_readwrite("pyramidLevels", &FeatureTrackerConfig::MotionEstimator::OpticalFlow::pyramidLevels, DOC(dai, FeatureTrackerConfig, MotionEstimator, OpticalFlow, pyramidLevels)) - .def_readwrite("searchWindowWidth", &FeatureTrackerConfig::MotionEstimator::OpticalFlow::searchWindowWidth, DOC(dai, FeatureTrackerConfig, MotionEstimator, OpticalFlow, searchWindowWidth)) - .def_readwrite("searchWindowHeight", &FeatureTrackerConfig::MotionEstimator::OpticalFlow::searchWindowHeight, DOC(dai, FeatureTrackerConfig, MotionEstimator, OpticalFlow, searchWindowHeight)) - .def_readwrite("epsilon", &FeatureTrackerConfig::MotionEstimator::OpticalFlow::epsilon, DOC(dai, FeatureTrackerConfig, MotionEstimator, OpticalFlow, epsilon)) - .def_readwrite("maxIterations", &FeatureTrackerConfig::MotionEstimator::OpticalFlow::maxIterations, DOC(dai, FeatureTrackerConfig, MotionEstimator, OpticalFlow, maxIterations)) - ; - - motionEstimator - .def(py::init<>()) + .def_readwrite("thresholds", &FeatureTrackerConfig::CornerDetector::thresholds, DOC(dai, FeatureTrackerConfig, CornerDetector, thresholds)); + + motionEstimatorType.value("LUCAS_KANADE_OPTICAL_FLOW", FeatureTrackerConfig::MotionEstimator::Type::LUCAS_KANADE_OPTICAL_FLOW) + .value("HW_MOTION_ESTIMATION", FeatureTrackerConfig::MotionEstimator::Type::HW_MOTION_ESTIMATION); + + motionEstimatorOpticalFlow.def(py::init<>()) + .def_readwrite("pyramidLevels", + &FeatureTrackerConfig::MotionEstimator::OpticalFlow::pyramidLevels, + DOC(dai, FeatureTrackerConfig, MotionEstimator, OpticalFlow, pyramidLevels)) + .def_readwrite("searchWindowWidth", + &FeatureTrackerConfig::MotionEstimator::OpticalFlow::searchWindowWidth, + DOC(dai, FeatureTrackerConfig, MotionEstimator, OpticalFlow, searchWindowWidth)) + .def_readwrite("searchWindowHeight", + &FeatureTrackerConfig::MotionEstimator::OpticalFlow::searchWindowHeight, + DOC(dai, FeatureTrackerConfig, MotionEstimator, OpticalFlow, searchWindowHeight)) + .def_readwrite( + "epsilon", &FeatureTrackerConfig::MotionEstimator::OpticalFlow::epsilon, DOC(dai, FeatureTrackerConfig, MotionEstimator, OpticalFlow, epsilon)) + .def_readwrite("maxIterations", + &FeatureTrackerConfig::MotionEstimator::OpticalFlow::maxIterations, + DOC(dai, FeatureTrackerConfig, MotionEstimator, OpticalFlow, maxIterations)); + + motionEstimator.def(py::init<>()) .def_readwrite("enable", &FeatureTrackerConfig::MotionEstimator::enable, DOC(dai, FeatureTrackerConfig, MotionEstimator, enable)) .def_readwrite("type", &FeatureTrackerConfig::MotionEstimator::type, DOC(dai, FeatureTrackerConfig, MotionEstimator, type)) - .def_readwrite("opticalFlow", &FeatureTrackerConfig::MotionEstimator::opticalFlow, DOC(dai, FeatureTrackerConfig, MotionEstimator, opticalFlow)) - ; + .def_readwrite("opticalFlow", &FeatureTrackerConfig::MotionEstimator::opticalFlow, DOC(dai, FeatureTrackerConfig, MotionEstimator, opticalFlow)); - featureMaintainer - .def(py::init<>()) + featureMaintainer.def(py::init<>()) .def_readwrite("enable", &FeatureTrackerConfig::FeatureMaintainer::enable, DOC(dai, FeatureTrackerConfig, FeatureMaintainer, enable)) - .def_readwrite("minimumDistanceBetweenFeatures", &FeatureTrackerConfig::FeatureMaintainer::minimumDistanceBetweenFeatures, DOC(dai, FeatureTrackerConfig, FeatureMaintainer, minimumDistanceBetweenFeatures)) - .def_readwrite("lostFeatureErrorThreshold", &FeatureTrackerConfig::FeatureMaintainer::lostFeatureErrorThreshold, DOC(dai, FeatureTrackerConfig, FeatureMaintainer, lostFeatureErrorThreshold)) - .def_readwrite("trackedFeatureThreshold", &FeatureTrackerConfig::FeatureMaintainer::trackedFeatureThreshold, DOC(dai, FeatureTrackerConfig, FeatureMaintainer, trackedFeatureThreshold)) - ; + .def_readwrite("minimumDistanceBetweenFeatures", + &FeatureTrackerConfig::FeatureMaintainer::minimumDistanceBetweenFeatures, + DOC(dai, FeatureTrackerConfig, FeatureMaintainer, minimumDistanceBetweenFeatures)) + .def_readwrite("lostFeatureErrorThreshold", + &FeatureTrackerConfig::FeatureMaintainer::lostFeatureErrorThreshold, + DOC(dai, FeatureTrackerConfig, FeatureMaintainer, lostFeatureErrorThreshold)) + .def_readwrite("trackedFeatureThreshold", + &FeatureTrackerConfig::FeatureMaintainer::trackedFeatureThreshold, + DOC(dai, FeatureTrackerConfig, FeatureMaintainer, trackedFeatureThreshold)); // Message - featureTrackerConfig - .def(py::init<>()) + featureTrackerConfig.def(py::init<>()) .def("__repr__", &FeatureTrackerConfig::str) // .def(py::init>()) - .def("setCornerDetector", static_cast(&FeatureTrackerConfig::setCornerDetector), py::arg("cornerDetector"), DOC(dai, FeatureTrackerConfig, setCornerDetector)) - .def("setCornerDetector", static_cast(&FeatureTrackerConfig::setCornerDetector), py::arg("config"), DOC(dai, FeatureTrackerConfig, setCornerDetector, 2)) - .def("setMotionEstimator", static_cast(&FeatureTrackerConfig::setMotionEstimator), py::arg("enable"), DOC(dai, FeatureTrackerConfig, setMotionEstimator)) - .def("setMotionEstimator", static_cast(&FeatureTrackerConfig::setMotionEstimator), py::arg("config"), DOC(dai, FeatureTrackerConfig, setMotionEstimator, 2)) - .def("setOpticalFlow", static_cast(&FeatureTrackerConfig::setOpticalFlow), DOC(dai, FeatureTrackerConfig, setOpticalFlow)) - .def("setOpticalFlow", static_cast(&FeatureTrackerConfig::setOpticalFlow), py::arg("config"), DOC(dai, FeatureTrackerConfig, setOpticalFlow, 2)) + .def("setCornerDetector", + static_cast( + &FeatureTrackerConfig::setCornerDetector), + py::arg("cornerDetector"), + DOC(dai, FeatureTrackerConfig, setCornerDetector)) + .def("setCornerDetector", + static_cast(&FeatureTrackerConfig::setCornerDetector), + py::arg("config"), + DOC(dai, FeatureTrackerConfig, setCornerDetector, 2)) + .def("setMotionEstimator", + static_cast(&FeatureTrackerConfig::setMotionEstimator), + py::arg("enable"), + DOC(dai, FeatureTrackerConfig, setMotionEstimator)) + .def( + "setMotionEstimator", + static_cast(&FeatureTrackerConfig::setMotionEstimator), + py::arg("config"), + DOC(dai, FeatureTrackerConfig, setMotionEstimator, 2)) + .def("setOpticalFlow", + static_cast(&FeatureTrackerConfig::setOpticalFlow), + DOC(dai, FeatureTrackerConfig, setOpticalFlow)) + .def("setOpticalFlow", + static_cast( + &FeatureTrackerConfig::setOpticalFlow), + py::arg("config"), + DOC(dai, FeatureTrackerConfig, setOpticalFlow, 2)) .def("setHwMotionEstimation", &FeatureTrackerConfig::setHwMotionEstimation, DOC(dai, FeatureTrackerConfig, setHwMotionEstimation)) - .def("setFeatureMaintainer", static_cast(&FeatureTrackerConfig::setFeatureMaintainer), py::arg("enable"), DOC(dai, FeatureTrackerConfig, setFeatureMaintainer)) - .def("setFeatureMaintainer", static_cast(&FeatureTrackerConfig::setFeatureMaintainer), py::arg("config"), DOC(dai, FeatureTrackerConfig, setFeatureMaintainer, 2)) - .def("setNumTargetFeatures", &FeatureTrackerConfig::setNumTargetFeatures, py::arg("numTargetFeatures"), DOC(dai, FeatureTrackerConfig, setNumTargetFeatures)) + .def("setFeatureMaintainer", + static_cast(&FeatureTrackerConfig::setFeatureMaintainer), + py::arg("enable"), + DOC(dai, FeatureTrackerConfig, setFeatureMaintainer)) + .def("setFeatureMaintainer", + static_cast( + &FeatureTrackerConfig::setFeatureMaintainer), + py::arg("config"), + DOC(dai, FeatureTrackerConfig, setFeatureMaintainer, 2)) + .def("setNumTargetFeatures", + &FeatureTrackerConfig::setNumTargetFeatures, + py::arg("numTargetFeatures"), + DOC(dai, FeatureTrackerConfig, setNumTargetFeatures)) // .def("set", &FeatureTrackerConfig::set, py::arg("config"), DOC(dai, FeatureTrackerConfig, set)) // .def("get", &FeatureTrackerConfig::get, DOC(dai, FeatureTrackerConfig, get)) @@ -126,5 +169,4 @@ void bind_featuretrackerconfig(pybind11::module& m, void* pCallstack){ m.attr("FeatureTrackerConfig").attr("CornerDetector") = m.attr("FeatureTrackerConfig").attr("CornerDetector"); m.attr("FeatureTrackerConfig").attr("MotionEstimator") = m.attr("FeatureTrackerConfig").attr("MotionEstimator"); m.attr("FeatureTrackerConfig").attr("FeatureMaintainer") = m.attr("FeatureTrackerConfig").attr("FeatureMaintainer"); - } diff --git a/bindings/python/src/pipeline/datatype/IMUDataBindings.cpp b/bindings/python/src/pipeline/datatype/IMUDataBindings.cpp index eba2ff3b0..a8e7ed72b 100644 --- a/bindings/python/src/pipeline/datatype/IMUDataBindings.cpp +++ b/bindings/python/src/pipeline/datatype/IMUDataBindings.cpp @@ -1,27 +1,30 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/IMUData.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_imudata(pybind11::module& m, void* pCallstack){ - +void bind_imudata(pybind11::module& m, void* pCallstack) { using namespace dai; py::class_> imuReport(m, "IMUReport", DOC(dai, IMUReport)); py::enum_ imuReportAccuracy(imuReport, "Accuracy"); - py::class_> imuReportAccelerometer(m, "IMUReportAccelerometer", DOC(dai, IMUReportAccelerometer)); + py::class_> imuReportAccelerometer( + m, "IMUReportAccelerometer", DOC(dai, IMUReportAccelerometer)); py::class_> imuReportGyroscope(m, "IMUReportGyroscope", DOC(dai, IMUReportGyroscope)); - py::class_> imuReportMagneticField(m, "IMUReportMagneticField", DOC(dai, IMUReportMagneticField)); - py::class_> imuReportRotationVectorWAcc(m, "IMUReportRotationVectorWAcc", DOC(dai, IMUReportRotationVectorWAcc)); + py::class_> imuReportMagneticField( + m, "IMUReportMagneticField", DOC(dai, IMUReportMagneticField)); + py::class_> imuReportRotationVectorWAcc( + m, "IMUReportRotationVectorWAcc", DOC(dai, IMUReportRotationVectorWAcc)); py::class_ imuPacket(m, "IMUPacket", DOC(dai, IMUPacket)); // py::class_> rawIMUPackets(m, "RawIMUData", DOC(dai, RawIMUData)); py::class_, Buffer, std::shared_ptr> imuData(m, "IMUData", DOC(dai, IMUData)); @@ -30,7 +33,7 @@ void bind_imudata(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -40,53 +43,41 @@ void bind_imudata(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Metadata / raw - imuReport - .def(py::init<>()) + imuReport.def(py::init<>()) .def_readwrite("sequence", &IMUReport::sequence) .def_readwrite("accuracy", &IMUReport::accuracy) .def_readwrite("timestamp", &IMUReport::timestamp) .def_readwrite("tsDevice", &IMUReport::tsDevice) .def("getTimestamp", &IMUReport::getTimestamp, DOC(dai, IMUReport, getTimestamp)) .def("getTimestampDevice", &IMUReport::getTimestampDevice, DOC(dai, IMUReport, getTimestampDevice)) - .def("getSequenceNum", &IMUReport::getSequenceNum, DOC(dai, IMUReport, getSequenceNum)) - ; + .def("getSequenceNum", &IMUReport::getSequenceNum, DOC(dai, IMUReport, getSequenceNum)); - imuReportAccuracy - .value("UNRELIABLE", IMUReport::Accuracy::UNRELIABLE) + imuReportAccuracy.value("UNRELIABLE", IMUReport::Accuracy::UNRELIABLE) .value("LOW", IMUReport::Accuracy::LOW) .value("MEDIUM", IMUReport::Accuracy::MEDIUM) - .value("HIGH", IMUReport::Accuracy::HIGH) - ; + .value("HIGH", IMUReport::Accuracy::HIGH); - imuReportAccelerometer - .def(py::init<>()) + imuReportAccelerometer.def(py::init<>()) .def_readwrite("x", &IMUReportAccelerometer::x) .def_readwrite("y", &IMUReportAccelerometer::y) - .def_readwrite("z", &IMUReportAccelerometer::z) - ; + .def_readwrite("z", &IMUReportAccelerometer::z); - imuReportGyroscope - .def(py::init<>()) + imuReportGyroscope.def(py::init<>()) .def_readwrite("x", &IMUReportGyroscope::x) .def_readwrite("y", &IMUReportGyroscope::y) - .def_readwrite("z", &IMUReportGyroscope::z) - ; + .def_readwrite("z", &IMUReportGyroscope::z); - imuReportMagneticField - .def(py::init<>()) + imuReportMagneticField.def(py::init<>()) .def_readwrite("x", &IMUReportMagneticField::x) .def_readwrite("y", &IMUReportMagneticField::y) - .def_readwrite("z", &IMUReportMagneticField::z) - ; + .def_readwrite("z", &IMUReportMagneticField::z); - imuReportRotationVectorWAcc - .def(py::init<>()) + imuReportRotationVectorWAcc.def(py::init<>()) .def_readwrite("i", &IMUReportRotationVectorWAcc::i) .def_readwrite("j", &IMUReportRotationVectorWAcc::j) .def_readwrite("k", &IMUReportRotationVectorWAcc::k) .def_readwrite("real", &IMUReportRotationVectorWAcc::real) - .def_readwrite("rotationVectorAccuracy", &IMUReportRotationVectorWAcc::rotationVectorAccuracy) - ; + .def_readwrite("rotationVectorAccuracy", &IMUReportRotationVectorWAcc::rotationVectorAccuracy); #if 0 py::class_>(m, "IMUReportRotationVector", DOC(dai, IMUReportRotationVector)) @@ -130,8 +121,7 @@ void bind_imudata(pybind11::module& m, void* pCallstack){ #endif - imuPacket - .def(py::init<>()) + imuPacket.def(py::init<>()) .def_readwrite("acceleroMeter", &IMUPacket::acceleroMeter) .def_readwrite("gyroscope", &IMUPacket::gyroscope) .def_readwrite("magneticField", &IMUPacket::magneticField) @@ -158,10 +148,11 @@ void bind_imudata(pybind11::module& m, void* pCallstack){ // ; // Message - imuData - .def(py::init<>()) + imuData.def(py::init<>()) .def("__repr__", &IMUData::str) - .def_property("packets", [](IMUData& imuDta) { return &imuDta.packets; }, [](IMUData& imuDta, std::vector val) { imuDta.packets = val; }, DOC(dai, IMUData, packets)) - ; - + .def_property( + "packets", + [](IMUData& imuDta) { return &imuDta.packets; }, + [](IMUData& imuDta, std::vector val) { imuDta.packets = val; }, + DOC(dai, IMUData, packets)); } diff --git a/bindings/python/src/pipeline/datatype/ImageAlignConfigBindings.cpp b/bindings/python/src/pipeline/datatype/ImageAlignConfigBindings.cpp index 85e46990f..a4f00fe09 100644 --- a/bindings/python/src/pipeline/datatype/ImageAlignConfigBindings.cpp +++ b/bindings/python/src/pipeline/datatype/ImageAlignConfigBindings.cpp @@ -1,26 +1,27 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/ImageAlignConfig.hpp" -//pybind +// pybind #include #include -void bind_imagealignconfig(pybind11::module& m, void* pCallstack){ - +void bind_imagealignconfig(pybind11::module& m, void* pCallstack) { using namespace dai; - py::class_, Buffer, std::shared_ptr> imageAlignConfig(m, "ImageAlignConfig", DOC(dai, ImageAlignConfig)); + py::class_, Buffer, std::shared_ptr> imageAlignConfig( + m, "ImageAlignConfig", DOC(dai, ImageAlignConfig)); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -30,10 +31,7 @@ void bind_imagealignconfig(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Message - imageAlignConfig - .def(py::init<>()) + imageAlignConfig.def(py::init<>()) .def("__repr__", &ImageAlignConfig::str) - .def_readwrite("staticDepthPlane", &ImageAlignConfig::staticDepthPlane, DOC(dai, ImageAlignConfig, staticDepthPlane)) - ; - + .def_readwrite("staticDepthPlane", &ImageAlignConfig::staticDepthPlane, DOC(dai, ImageAlignConfig, staticDepthPlane)); } diff --git a/bindings/python/src/pipeline/datatype/ImageManipConfigBindings.cpp b/bindings/python/src/pipeline/datatype/ImageManipConfigBindings.cpp index 873e3ff30..240d8cacb 100644 --- a/bindings/python/src/pipeline/datatype/ImageManipConfigBindings.cpp +++ b/bindings/python/src/pipeline/datatype/ImageManipConfigBindings.cpp @@ -88,8 +88,7 @@ void bind_imagemanipconfig(pybind11::module& m, void* pCallstack) { // Message - imageManipConfig - .def(py::init<>()) + imageManipConfig.def(py::init<>()) .def("__repr__", &ImageManipConfig::str) // setters .def("setCropRect", diff --git a/bindings/python/src/pipeline/datatype/ImageManipConfigV2Bindings.cpp b/bindings/python/src/pipeline/datatype/ImageManipConfigV2Bindings.cpp index 36c29a82c..9a3593e93 100644 --- a/bindings/python/src/pipeline/datatype/ImageManipConfigV2Bindings.cpp +++ b/bindings/python/src/pipeline/datatype/ImageManipConfigV2Bindings.cpp @@ -41,13 +41,22 @@ void bind_imagemanipconfigv2(pybind11::module& m, void* pCallstack) { // Message - imageManipConfig - .def(py::init<>()) + imageManipConfig.def(py::init<>()) .def("__repr__", &ImageManipConfigV2::str) // New API Setters .def("clearOps", &ImageManipConfigV2::clearOps, DOC(dai, ImageManipConfigV2, clearOps)) - .def("addCrop", static_cast(&ImageManipConfigV2::addCrop), py::arg("x"), py::arg("y"), py::arg("w"), py::arg("h"), DOC(dai, ImageManipConfigV2, addCrop)) - .def("addCrop", static_cast(&ImageManipConfigV2::addCrop), py::arg("rect"), py::arg("normalizedCoords"), DOC(dai, ImageManipConfigV2, addCrop)) + .def("addCrop", + static_cast(&ImageManipConfigV2::addCrop), + py::arg("x"), + py::arg("y"), + py::arg("w"), + py::arg("h"), + DOC(dai, ImageManipConfigV2, addCrop)) + .def("addCrop", + static_cast(&ImageManipConfigV2::addCrop), + py::arg("rect"), + py::arg("normalizedCoords"), + DOC(dai, ImageManipConfigV2, addCrop)) .def("addCropRotatedRect", &ImageManipConfigV2::addCropRotatedRect, py::arg("rect"), @@ -91,7 +100,12 @@ void bind_imagemanipconfigv2(pybind11::module& m, void* pCallstack) { static_cast(&ImageManipConfigV2::setBackgroundColor), py::arg("val"), DOC(dai, ImageManipConfigV2, setBackgroundColor)) - .def("setOutputSize", &ImageManipConfigV2::setOutputSize, py::arg("w"), py::arg("h"), py::arg("mode") = ImageManipConfigV2::ResizeMode::STRETCH, DOC(dai, ImageManipConfigV2, setOutputSize)) + .def("setOutputSize", + &ImageManipConfigV2::setOutputSize, + py::arg("w"), + py::arg("h"), + py::arg("mode") = ImageManipConfigV2::ResizeMode::STRETCH, + DOC(dai, ImageManipConfigV2, setOutputSize)) .def("setOutputCenter", &ImageManipConfigV2::setOutputCenter, py::arg("c"), DOC(dai, ImageManipConfigV2, setOutputCenter)) .def("setReusePreviousImage", &ImageManipConfigV2::setReusePreviousImage, py::arg("reuse"), DOC(dai, ImageManipConfigV2, setReusePreviousImage)) .def("setSkipCurrentImage", &ImageManipConfigV2::setSkipCurrentImage, py::arg("skip"), DOC(dai, ImageManipConfigV2, setSkipCurrentImage)) diff --git a/bindings/python/src/pipeline/datatype/ImgAnnotationsBindings.cpp b/bindings/python/src/pipeline/datatype/ImgAnnotationsBindings.cpp index c49d74d81..669e41d2a 100644 --- a/bindings/python/src/pipeline/datatype/ImgAnnotationsBindings.cpp +++ b/bindings/python/src/pipeline/datatype/ImgAnnotationsBindings.cpp @@ -1,20 +1,20 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/ImgAnnotations.hpp" -//pybind +// pybind #include #include #include // #include "spdlog/spdlog.h" - PYBIND11_MAKE_OPAQUE(std::vector); PYBIND11_MAKE_OPAQUE(std::vector); PYBIND11_MAKE_OPAQUE(std::vector); @@ -22,33 +22,28 @@ PYBIND11_MAKE_OPAQUE(std::vector); PYBIND11_MAKE_OPAQUE(std::vector); PYBIND11_MAKE_OPAQUE(std::vector); -void bind_imageannotations(pybind11::module& m, void* pCallstack){ - +void bind_imageannotations(pybind11::module& m, void* pCallstack) { using namespace dai; py::class_, Buffer, std::shared_ptr> imageAnnotations(m, "ImgAnnotations", DOC(dai, ImgAnnotations)); - py::class_ circleAnnotation(m, "CircleAnnotation", DOC(dai, CircleAnnotation)); - py::enum_pointsAnnotationType (m, "PointsAnnotationType", DOC(dai, PointsAnnotationType)); - py::class_ pointsAnnotation(m, "PointsAnnotation", DOC(dai, PointsAnnotation)); - py::class_ textAnnotation(m, "TextAnnotation", DOC(dai, TextAnnotation)); + py::class_ circleAnnotation(m, "CircleAnnotation", DOC(dai, CircleAnnotation)); + py::enum_ pointsAnnotationType(m, "PointsAnnotationType", DOC(dai, PointsAnnotationType)); + py::class_ pointsAnnotation(m, "PointsAnnotation", DOC(dai, PointsAnnotation)); + py::class_ textAnnotation(m, "TextAnnotation", DOC(dai, TextAnnotation)); py::class_ imageAnnotation(m, "ImgAnnotation", DOC(dai, ImgAnnotation)); - - - py::bind_vector>(m, "VectorColor"); - py::bind_vector>(m, "VectorPoint2f"); - py::bind_vector>(m, "VectorCircleAnnotation"); - py::bind_vector>(m, "VectorPointsAnnotation"); - py::bind_vector>(m, "VectorTextAnnotation"); - py::bind_vector>(m, "VectorImgAnnotation"); - - + py::bind_vector>(m, "VectorColor"); + py::bind_vector>(m, "VectorPoint2f"); + py::bind_vector>(m, "VectorCircleAnnotation"); + py::bind_vector>(m, "VectorPointsAnnotation"); + py::bind_vector>(m, "VectorTextAnnotation"); + py::bind_vector>(m, "VectorImgAnnotation"); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -58,58 +53,44 @@ void bind_imageannotations(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Metadata / raw - circleAnnotation - .def(py::init<>()) - .def_readwrite("position", &CircleAnnotation::position) - .def_readwrite("diameter", &CircleAnnotation::diameter) - .def_readwrite("thickness", &CircleAnnotation::thickness) - .def_readwrite("fillColor", &CircleAnnotation::fillColor) - .def_readwrite("outlineColor", &CircleAnnotation::outlineColor) - ; - - pointsAnnotationType - .value("UNKNOWN", PointsAnnotationType::UNKNOWN) - .value("POINTS", PointsAnnotationType::POINTS) - .value("LINE_LOOP", PointsAnnotationType::LINE_LOOP) - .value("LINE_STRIP", PointsAnnotationType::LINE_STRIP) - .value("LINE_LIST", PointsAnnotationType::LINE_LIST) - .export_values(); - pointsAnnotation - .def(py::init<>()) - .def_readwrite("type", &PointsAnnotation::type) - .def_readwrite("points", &PointsAnnotation::points) - .def_readwrite("outlineColor", &PointsAnnotation::outlineColor) - .def_readwrite("outlineColors", &PointsAnnotation::outlineColors) - .def_readwrite("fillColor", &PointsAnnotation::fillColor) - .def_readwrite("thickness", &PointsAnnotation::thickness) - ; - - textAnnotation - .def(py::init<>()) - .def_readwrite("position", &TextAnnotation::position) - .def_readwrite("text", &TextAnnotation::text) - .def_readwrite("fontSize", &TextAnnotation::fontSize) - .def_readwrite("textColor", &TextAnnotation::textColor) - .def_readwrite("backgroundColor", &TextAnnotation::backgroundColor) - ; - - imageAnnotation - .def(py::init<>()) - .def_readwrite("circles", &ImgAnnotation::circles) - .def_readwrite("points", &ImgAnnotation::points) - .def_readwrite("texts", &ImgAnnotation::texts) - ; - + circleAnnotation.def(py::init<>()) + .def_readwrite("position", &CircleAnnotation::position) + .def_readwrite("diameter", &CircleAnnotation::diameter) + .def_readwrite("thickness", &CircleAnnotation::thickness) + .def_readwrite("fillColor", &CircleAnnotation::fillColor) + .def_readwrite("outlineColor", &CircleAnnotation::outlineColor); + + pointsAnnotationType.value("UNKNOWN", PointsAnnotationType::UNKNOWN) + .value("POINTS", PointsAnnotationType::POINTS) + .value("LINE_LOOP", PointsAnnotationType::LINE_LOOP) + .value("LINE_STRIP", PointsAnnotationType::LINE_STRIP) + .value("LINE_LIST", PointsAnnotationType::LINE_LIST) + .export_values(); + pointsAnnotation.def(py::init<>()) + .def_readwrite("type", &PointsAnnotation::type) + .def_readwrite("points", &PointsAnnotation::points) + .def_readwrite("outlineColor", &PointsAnnotation::outlineColor) + .def_readwrite("outlineColors", &PointsAnnotation::outlineColors) + .def_readwrite("fillColor", &PointsAnnotation::fillColor) + .def_readwrite("thickness", &PointsAnnotation::thickness); + + textAnnotation.def(py::init<>()) + .def_readwrite("position", &TextAnnotation::position) + .def_readwrite("text", &TextAnnotation::text) + .def_readwrite("fontSize", &TextAnnotation::fontSize) + .def_readwrite("textColor", &TextAnnotation::textColor) + .def_readwrite("backgroundColor", &TextAnnotation::backgroundColor); + + imageAnnotation.def(py::init<>()) + .def_readwrite("circles", &ImgAnnotation::circles) + .def_readwrite("points", &ImgAnnotation::points) + .def_readwrite("texts", &ImgAnnotation::texts); // Message - imageAnnotations - .def(py::init<>(), DOC(dai, ImgAnnotations, ImgAnnotations)) - .def(py::init&>(), DOC(dai, ImgAnnotations, ImgAnnotations, 2)) - .def_readwrite("annotations", &ImgAnnotations::annotations) + imageAnnotations.def(py::init<>(), DOC(dai, ImgAnnotations, ImgAnnotations)) + .def(py::init&>(), DOC(dai, ImgAnnotations, ImgAnnotations, 2)) + .def_readwrite("annotations", &ImgAnnotations::annotations) .def("getTimestamp", &ImgAnnotations::Buffer::getTimestamp, DOC(dai, Buffer, getTimestamp)) .def("getTimestampDevice", &ImgAnnotations::Buffer::getTimestampDevice, DOC(dai, Buffer, getTimestampDevice)) - .def("getSequenceNum", &ImgAnnotations::Buffer::getSequenceNum, DOC(dai, Buffer, getSequenceNum)) - ; - - + .def("getSequenceNum", &ImgAnnotations::Buffer::getSequenceNum, DOC(dai, Buffer, getSequenceNum)); } diff --git a/bindings/python/src/pipeline/datatype/ImgDetectionsBindings.cpp b/bindings/python/src/pipeline/datatype/ImgDetectionsBindings.cpp index 10ea2f9a6..3067f4559 100644 --- a/bindings/python/src/pipeline/datatype/ImgDetectionsBindings.cpp +++ b/bindings/python/src/pipeline/datatype/ImgDetectionsBindings.cpp @@ -1,19 +1,19 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/ImgDetections.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_imgdetections(pybind11::module& m, void* pCallstack){ - +void bind_imgdetections(pybind11::module& m, void* pCallstack) { using namespace dai; // py::class_> rawImgDetections(m, "RawImgDetections", DOC(dai, RawImgDetections)); @@ -24,7 +24,7 @@ void bind_imgdetections(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -34,15 +34,13 @@ void bind_imgdetections(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Metadata / raw - imgDetection - .def(py::init<>()) + imgDetection.def(py::init<>()) .def_readwrite("label", &ImgDetection::label) .def_readwrite("confidence", &ImgDetection::confidence) .def_readwrite("xmin", &ImgDetection::xmin) .def_readwrite("ymin", &ImgDetection::ymin) .def_readwrite("xmax", &ImgDetection::xmax) - .def_readwrite("ymax", &ImgDetection::ymax) - ; + .def_readwrite("ymax", &ImgDetection::ymax); // rawImgDetections // .def(py::init<>()) @@ -71,19 +69,20 @@ void bind_imgdetections(pybind11::module& m, void* pCallstack){ // ; // Message - imgDetections - .def(py::init<>(), DOC(dai, ImgDetections, ImgDetections)) + imgDetections.def(py::init<>(), DOC(dai, ImgDetections, ImgDetections)) .def("__repr__", &ImgDetections::str) - .def_property("detections", [](ImgDetections& det) { return &det.detections; }, [](ImgDetections& det, std::vector val) { det.detections = val; }, DOC(dai, ImgDetections, detections)) + .def_property( + "detections", + [](ImgDetections& det) { return &det.detections; }, + [](ImgDetections& det, std::vector val) { det.detections = val; }, + DOC(dai, ImgDetections, detections)) .def("getTimestamp", &ImgDetections::Buffer::getTimestamp, DOC(dai, Buffer, getTimestamp)) .def("getTimestampDevice", &ImgDetections::Buffer::getTimestampDevice, DOC(dai, Buffer, getTimestampDevice)) .def("getSequenceNum", &ImgDetections::Buffer::getSequenceNum, DOC(dai, Buffer, getSequenceNum)) - .def("getTransformation", [](ImgDetections& msg) {return msg.transformation;}) - .def("setTransformation", [](ImgDetections& msg, const std::optional& transformation) {msg.transformation = transformation;}) + .def("getTransformation", [](ImgDetections& msg) { return msg.transformation; }) + .def("setTransformation", [](ImgDetections& msg, const std::optional& transformation) { msg.transformation = transformation; }) // .def("setTimestamp", &ImgDetections::setTimestamp, DOC(dai, Buffer, setTimestamp)) // .def("setTimestampDevice", &ImgDetections::setTimestampDevice, DOC(dai, Buffer, setTimestampDevice)) // .def("setSequenceNum", &ImgDetections::setSequenceNum, DOC(dai, ImgDetections, setSequenceNum)) ; - - } diff --git a/bindings/python/src/pipeline/datatype/ImgFrameBindings.cpp b/bindings/python/src/pipeline/datatype/ImgFrameBindings.cpp index 6752646e8..ff98ff37f 100644 --- a/bindings/python/src/pipeline/datatype/ImgFrameBindings.cpp +++ b/bindings/python/src/pipeline/datatype/ImgFrameBindings.cpp @@ -211,7 +211,7 @@ void bind_imgframe(pybind11::module& m, void* pCallstack) { .def("getSourceDFov", &ImgFrame::getSourceDFov, DOC(dai, ImgFrame, getSourceDFov)) .def("getSourceWidth", &ImgFrame::getSourceWidth, DOC(dai, ImgFrame, getSourceWidth)) .def("getSourceHeight", &ImgFrame::getSourceHeight, DOC(dai, ImgFrame, getSourceHeight)) - .def("getTransformation", [](ImgFrame& msg) {return msg.transformation;}) + .def("getTransformation", [](ImgFrame& msg) { return msg.transformation; }) .def("validateTransformations", &ImgFrame::validateTransformations, DOC(dai, ImgFrame, validateTransformations)) #ifdef DEPTHAI_HAVE_OPENCV_SUPPORT @@ -264,7 +264,7 @@ void bind_imgframe(pybind11::module& m, void* pCallstack) { py::arg("sizer"), DOC(dai, ImgFrame, setSize, 2)) .def("setType", &ImgFrame::setType, py::arg("type"), DOC(dai, ImgFrame, setType)) - .def("setTransformation", [](ImgFrame& msg, const ImgTransformation& transformation) {msg.transformation = transformation;}) + .def("setTransformation", [](ImgFrame& msg, const ImgTransformation& transformation) { msg.transformation = transformation; }) // .def("set", &ImgFrame::set, py::arg("type"), DOC(dai, ImgFrame, set)) ; // add aliases dai.ImgFrame.Type and dai.ImgFrame.Specs diff --git a/bindings/python/src/pipeline/datatype/MessageGroupBindings.cpp b/bindings/python/src/pipeline/datatype/MessageGroupBindings.cpp index ca13cff05..cc63d8024 100644 --- a/bindings/python/src/pipeline/datatype/MessageGroupBindings.cpp +++ b/bindings/python/src/pipeline/datatype/MessageGroupBindings.cpp @@ -1,20 +1,20 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "depthai/pipeline/datatype/MessageGroup.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/MessageGroup.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_message_group(pybind11::module& m, void* pCallstack){ - +void bind_message_group(pybind11::module& m, void* pCallstack) { using namespace dai; py::class_, Buffer, std::shared_ptr> messageGroup(m, "MessageGroup", DOC(dai, MessageGroup)); @@ -23,7 +23,7 @@ void bind_message_group(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -39,17 +39,14 @@ void bind_message_group(pybind11::module& m, void* pCallstack){ // ; // Message - messageGroup - .def(py::init<>()) + messageGroup.def(py::init<>()) .def("__repr__", &MessageGroup::str) - .def("__getitem__", [](MessageGroup& msg, const std::string& name) { - return msg[name]; - }) - .def("__setitem__", [](MessageGroup& msg, const std::string& name, std::shared_ptr data) { - return msg.add(name, data); - }) - .def("__iter__", [](MessageGroup& msg) { return py::make_iterator(msg.begin(), msg.end()); }, - py::keep_alive<0, 1>() /* Essential: keep object alive while iterator exists */) + .def("__getitem__", [](MessageGroup& msg, const std::string& name) { return msg[name]; }) + .def("__setitem__", [](MessageGroup& msg, const std::string& name, std::shared_ptr data) { return msg.add(name, data); }) + .def( + "__iter__", + [](MessageGroup& msg) { return py::make_iterator(msg.begin(), msg.end()); }, + py::keep_alive<0, 1>() /* Essential: keep object alive while iterator exists */) .def("isSynced", &MessageGroup::isSynced, DOC(dai, MessageGroup, isSynced)) .def("getIntervalNs", &MessageGroup::getIntervalNs, DOC(dai, MessageGroup, getIntervalNs)) .def("getNumMessages", &MessageGroup::getNumMessages, DOC(dai, MessageGroup, getNumMessages)) @@ -61,5 +58,4 @@ void bind_message_group(pybind11::module& m, void* pCallstack){ // .def("setTimestampDevice", &MessageGroup::setTimestampDevice, DOC(dai, MessageGroup, setTimestampDevice)) // .def("setSequenceNum", &MessageGroup::setSequenceNum, DOC(dai, MessageGroup, setSequenceNum)) ; - } diff --git a/bindings/python/src/pipeline/datatype/NNDataBindings.cpp b/bindings/python/src/pipeline/datatype/NNDataBindings.cpp index bd56ac0fb..63f6a5894 100644 --- a/bindings/python/src/pipeline/datatype/NNDataBindings.cpp +++ b/bindings/python/src/pipeline/datatype/NNDataBindings.cpp @@ -1,18 +1,19 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai -#include "depthai/pipeline/datatype/NNData.hpp" #include "depthai/common/TensorInfo.hpp" +#include "depthai/pipeline/datatype/NNData.hpp" -//pybind +// pybind #include #include #include -//xtensor +// xtensor #define FORCE_IMPORT_ARRAY #include @@ -20,22 +21,20 @@ // #include "spdlog/spdlog.h" -void bind_nndata(pybind11::module& m, void* pCallstack){ - +void bind_nndata(pybind11::module& m, void* pCallstack) { using namespace dai; // py::class_> rawNnData(m, "RawNNData", DOC(dai, RawNNData)); py::class_ tensorInfo(m, "TensorInfo", DOC(dai, TensorInfo)); - py::enum_tensorInfoDataType(tensorInfo, "DataType"); - py::enum_tensorInfoStorageOrder(tensorInfo, "StorageOrder"); + py::enum_ tensorInfoDataType(tensorInfo, "DataType"); + py::enum_ tensorInfoStorageOrder(tensorInfo, "StorageOrder"); py::class_, Buffer, std::shared_ptr> nnData(m, "NNData", DOC(dai, NNData)); - /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -73,8 +72,7 @@ void bind_nndata(pybind11::module& m, void* pCallstack){ // .def_readwrite("sequenceNum", &RawNNData::sequenceNum) // ; - tensorInfo - .def(py::init<>()) + tensorInfo.def(py::init<>()) .def("getTensorSize", &TensorInfo::getTensorSize) .def_readwrite("order", &TensorInfo::order) .def_readwrite("dataType", &TensorInfo::dataType) @@ -85,20 +83,16 @@ void bind_nndata(pybind11::module& m, void* pCallstack){ .def_readwrite("offset", &TensorInfo::offset) .def_readwrite("quantization", &TensorInfo::quantization) .def_readwrite("qpScale", &TensorInfo::qpScale) - .def_readwrite("qpZp", &TensorInfo::qpZp) - ; + .def_readwrite("qpZp", &TensorInfo::qpZp); - tensorInfoDataType - .value("FP16", TensorInfo::DataType::FP16) + tensorInfoDataType.value("FP16", TensorInfo::DataType::FP16) .value("U8F", TensorInfo::DataType::U8F) .value("INT", TensorInfo::DataType::INT) .value("FP32", TensorInfo::DataType::FP32) .value("I8", TensorInfo::DataType::I8) - .value("FP64", TensorInfo::DataType::FP64) - ; + .value("FP64", TensorInfo::DataType::FP64); - tensorInfoStorageOrder - .value("NHWC", TensorInfo::StorageOrder::NHWC) + tensorInfoStorageOrder.value("NHWC", TensorInfo::StorageOrder::NHWC) .value("NHCW", TensorInfo::StorageOrder::NHCW) .value("NCHW", TensorInfo::StorageOrder::NCHW) .value("HWC", TensorInfo::StorageOrder::HWC) @@ -111,9 +105,7 @@ void bind_nndata(pybind11::module& m, void* pCallstack){ .value("CN", TensorInfo::StorageOrder::CN) .value("C", TensorInfo::StorageOrder::C) .value("H", TensorInfo::StorageOrder::H) - .value("W", TensorInfo::StorageOrder::W) - ; - + .value("W", TensorInfo::StorageOrder::W); // Message @@ -148,14 +140,10 @@ void bind_nndata(pybind11::module& m, void* pCallstack){ // PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'getTensor()' // instead", 1); return obj.getLayer(name, tensor); // }, py::arg("name"), py::arg("tensor"), DOC(dai, NNData, getLayer)) - .def("hasLayer", &NNData::hasLayer, py::arg("name"), - DOC(dai, NNData, hasLayer)) - .def("getAllLayerNames", &NNData::getAllLayerNames, - DOC(dai, NNData, getAllLayerNames)) - .def("getAllLayers", &NNData::getAllLayers, - DOC(dai, NNData, getAllLayers)) - .def("getLayerDatatype", &NNData::getLayerDatatype, py::arg("name"), - py::arg("datatype"), DOC(dai, NNData, getLayerDatatype)) + .def("hasLayer", &NNData::hasLayer, py::arg("name"), DOC(dai, NNData, hasLayer)) + .def("getAllLayerNames", &NNData::getAllLayerNames, DOC(dai, NNData, getAllLayerNames)) + .def("getAllLayers", &NNData::getAllLayers, DOC(dai, NNData, getAllLayers)) + .def("getLayerDatatype", &NNData::getLayerDatatype, py::arg("name"), py::arg("datatype"), DOC(dai, NNData, getLayerDatatype)) // .def("getLayerUInt8", [](NNData& obj, const std::string& name){ // PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'getTensor()' // instead", 1); return obj.getLayerUInt8(name); @@ -188,97 +176,156 @@ void bind_nndata(pybind11::module& m, void* pCallstack){ // .def("setTimestampDevice", &NNData::setTimestampDevice, DOC(dai, NNData, setTimestampDevice)) // .def("setSequenceNum", &NNData::setSequenceNum, DOC(dai, NNData, setSequenceNum)) - .def("addTensor", static_cast&, TensorInfo::StorageOrder)>(&NNData::addTensor), py::arg("name"), py::arg("tensor"), py::arg("storageOrder"), DOC(dai, NNData, addTensor)) - .def("addTensor", static_cast&, TensorInfo::StorageOrder)>(&NNData::addTensor), py::arg("name"), py::arg("tensor"), py::arg("storageOrder"), DOC(dai, NNData, addTensor)) - .def("addTensor", static_cast&, TensorInfo::StorageOrder)>(&NNData::addTensor), py::arg("name"), py::arg("tensor"), py::arg("storageOrder"), DOC(dai, NNData, addTensor)) + .def("addTensor", + static_cast&, TensorInfo::StorageOrder)>(&NNData::addTensor), + py::arg("name"), + py::arg("tensor"), + py::arg("storageOrder"), + DOC(dai, NNData, addTensor)) + .def("addTensor", + static_cast&, TensorInfo::StorageOrder)>(&NNData::addTensor), + py::arg("name"), + py::arg("tensor"), + py::arg("storageOrder"), + DOC(dai, NNData, addTensor)) + .def("addTensor", + static_cast&, TensorInfo::StorageOrder)>(&NNData::addTensor), + py::arg("name"), + py::arg("tensor"), + py::arg("storageOrder"), + DOC(dai, NNData, addTensor)) - .def("addTensor", static_cast&, TensorInfo::StorageOrder)>(&NNData::addTensor), py::arg("name"), py::arg("tensor"), py::arg("storageOrder"), DOC(dai, NNData, addTensor, 2)) - .def("addTensor", static_cast&, TensorInfo::StorageOrder)>(&NNData::addTensor), py::arg("name"), py::arg("tensor"), py::arg("storageOrder"), DOC(dai, NNData, addTensor, 2)) - .def("addTensor", static_cast&, TensorInfo::StorageOrder)>(&NNData::addTensor), py::arg("name"), py::arg("tensor"), py::arg("storageOrder"), DOC(dai, NNData, addTensor, 2)) + .def("addTensor", + static_cast&, TensorInfo::StorageOrder)>(&NNData::addTensor), + py::arg("name"), + py::arg("tensor"), + py::arg("storageOrder"), + DOC(dai, NNData, addTensor, 2)) + .def("addTensor", + static_cast&, TensorInfo::StorageOrder)>(&NNData::addTensor), + py::arg("name"), + py::arg("tensor"), + py::arg("storageOrder"), + DOC(dai, NNData, addTensor, 2)) + .def("addTensor", + static_cast&, TensorInfo::StorageOrder)>(&NNData::addTensor), + py::arg("name"), + py::arg("tensor"), + py::arg("storageOrder"), + DOC(dai, NNData, addTensor, 2)) - .def("addTensor", [](NNData&obj, const std::string&name, py::object tensor_obj, dai::TensorInfo::DataType dataType){ - auto tensor = py::array(tensor_obj); - if (dataType == dai::TensorInfo::DataType::INT) - obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::INT); - else if (dataType == dai::TensorInfo::DataType::FP32) - obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::FP32); - else if(dataType == dai::TensorInfo::DataType::FP64) - obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::FP64); - else if(dataType == dai::TensorInfo::DataType::FP16) - obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::FP16); - else if (dataType == dai::TensorInfo::DataType::U8F) - obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::U8F); - else if (dataType == dai::TensorInfo::DataType::I8) - obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::I8); - else throw std::runtime_error("Unsupported datatype"); - }, py::arg("name"), py::arg("tensor"), py::arg("dataType"), DOC(dai, NNData, addTensor)) + .def( + "addTensor", + [](NNData& obj, const std::string& name, py::object tensor_obj, dai::TensorInfo::DataType dataType) { + auto tensor = py::array(tensor_obj); + if(dataType == dai::TensorInfo::DataType::INT) + obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::INT); + else if(dataType == dai::TensorInfo::DataType::FP32) + obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::FP32); + else if(dataType == dai::TensorInfo::DataType::FP64) + obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::FP64); + else if(dataType == dai::TensorInfo::DataType::FP16) + obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::FP16); + else if(dataType == dai::TensorInfo::DataType::U8F) + obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::U8F); + else if(dataType == dai::TensorInfo::DataType::I8) + obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::I8); + else + throw std::runtime_error("Unsupported datatype"); + }, + py::arg("name"), + py::arg("tensor"), + py::arg("dataType"), + DOC(dai, NNData, addTensor)) - .def("addTensor", [](NNData&obj, const std::string &name, py::object tensor_obj){ - auto tensor = py::array(tensor_obj); - auto dtype = tensor.dtype(); - if (dtype.is(py::dtype::of()) || dtype.is(py::dtype::of())) { - obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::FP32); - } else if (dtype.is(py::dtype::of()) || dtype.is(py::dtype::of()) ) { - obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::INT); - } else if (dtype.is(py::dtype("float16"))) { - obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::FP16); - } else if(dtype.is(py::dtype::of())){ - obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::I8); - } else if(dtype.is(py::dtype::of())){ - obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::U8F); - } else throw std::runtime_error("Unsupported object type"); - }, py::arg("name"), py::arg("tensor"), DOC(dai, NNData, addTensor, 2)) - + .def( + "addTensor", + [](NNData& obj, const std::string& name, py::object tensor_obj) { + auto tensor = py::array(tensor_obj); + auto dtype = tensor.dtype(); + if(dtype.is(py::dtype::of()) || dtype.is(py::dtype::of())) { + obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::FP32); + } else if(dtype.is(py::dtype::of()) || dtype.is(py::dtype::of())) { + obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::INT); + } else if(dtype.is(py::dtype("float16"))) { + obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::FP16); + } else if(dtype.is(py::dtype::of())) { + obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::I8); + } else if(dtype.is(py::dtype::of())) { + obj.addTensor(name, tensor.cast>(), dai::TensorInfo::DataType::U8F); + } else + throw std::runtime_error("Unsupported object type"); + }, + py::arg("name"), + py::arg("tensor"), + DOC(dai, NNData, addTensor, 2)) - .def("getTensor", [](NNData& obj, const std::string& name, bool dequantize) -> py::object { - const auto datatype = obj.getTensorDatatype(name); - if((datatype == dai::TensorInfo::DataType::U8F && !dequantize) || - (datatype == dai::TensorInfo::DataType::I8 && !dequantize) || - (datatype == dai::TensorInfo::DataType::INT && !dequantize)) { - // In case of dequantization, we should always return float - return py::cast(obj.getTensor(name)); - } else if(datatype == dai::TensorInfo::DataType::FP64) { - return py::cast(obj.getTensor(name, dequantize)); - } else { - return py::cast(obj.getTensor(name, dequantize)); - } - }, py::arg("name"), py::arg("dequantize") = false, DOC(dai, NNData, getTensor)) - .def("getTensor", [](NNData& obj, const std::string name, TensorInfo::StorageOrder order ,bool dequantize) -> py::object { - const auto datatype = obj.getTensorDatatype(name); - if(datatype == dai::TensorInfo::DataType::U8F && !dequantize) { - // In case of dequantization, we should always return float - return py::cast(obj.getTensor(name, order)); - } else { - return py::cast(obj.getTensor(name, order, dequantize)); - } - }, py::arg("name"), py::arg("storageOrder"), py::arg("dequantize") = false, DOC(dai, NNData, getTensor)) - .def("getFirstTensor", [](NNData& obj, bool dequantize) -> py::object { - const auto datatype = obj.getFirstTensorDatatype(); - if(datatype == dai::TensorInfo::DataType::U8F && !dequantize) { - // In case of dequantization, we should always return float - return py::cast(obj.getFirstTensor()); - } else { - return py::cast(obj.getFirstTensor(dequantize)); - } - }, py::arg("dequantize") = false, DOC(dai, NNData, getFirstTensor)) + .def( + "getTensor", + [](NNData& obj, const std::string& name, bool dequantize) -> py::object { + const auto datatype = obj.getTensorDatatype(name); + if((datatype == dai::TensorInfo::DataType::U8F && !dequantize) || (datatype == dai::TensorInfo::DataType::I8 && !dequantize) + || (datatype == dai::TensorInfo::DataType::INT && !dequantize)) { + // In case of dequantization, we should always return float + return py::cast(obj.getTensor(name)); + } else if(datatype == dai::TensorInfo::DataType::FP64) { + return py::cast(obj.getTensor(name, dequantize)); + } else { + return py::cast(obj.getTensor(name, dequantize)); + } + }, + py::arg("name"), + py::arg("dequantize") = false, + DOC(dai, NNData, getTensor)) + .def( + "getTensor", + [](NNData& obj, const std::string name, TensorInfo::StorageOrder order, bool dequantize) -> py::object { + const auto datatype = obj.getTensorDatatype(name); + if(datatype == dai::TensorInfo::DataType::U8F && !dequantize) { + // In case of dequantization, we should always return float + return py::cast(obj.getTensor(name, order)); + } else { + return py::cast(obj.getTensor(name, order, dequantize)); + } + }, + py::arg("name"), + py::arg("storageOrder"), + py::arg("dequantize") = false, + DOC(dai, NNData, getTensor)) + .def( + "getFirstTensor", + [](NNData& obj, bool dequantize) -> py::object { + const auto datatype = obj.getFirstTensorDatatype(); + if(datatype == dai::TensorInfo::DataType::U8F && !dequantize) { + // In case of dequantization, we should always return float + return py::cast(obj.getFirstTensor()); + } else { + return py::cast(obj.getFirstTensor(dequantize)); + } + }, + py::arg("dequantize") = false, + DOC(dai, NNData, getFirstTensor)) - .def("getFirstTensor", [](NNData& obj, TensorInfo::StorageOrder order, bool dequantize) -> py::object { - const auto datatype = obj.getFirstTensorDatatype(); - if(datatype == dai::TensorInfo::DataType::U8F && !dequantize) { - // In case of dequantization, we should always return float - return py::cast(obj.getFirstTensor(order)); - } else { - return py::cast(obj.getFirstTensor(order, dequantize)); - } - }, py::arg("storageOrder"), py::arg("dequantize") = false, DOC(dai, NNData, getFirstTensor, 2)) - // .def("getTensor", static_cast(NNData::*)(const std::string&)>(&NNData::getTensor), py::arg("name"), DOC(dai, NNData, getTensor)) - // .def("getTensor", static_cast(NNData::*)(const std::string&)>(&NNData::getTensor), py::arg("name"), DOC(dai, NNData, getTensor, 2)) - // .def("getTensor", static_cast(NNData::*)(const std::string&)>(&NNData::getTensor), py::arg("name"), DOC(dai, NNData, getTensor, 3)) + .def( + "getFirstTensor", + [](NNData& obj, TensorInfo::StorageOrder order, bool dequantize) -> py::object { + const auto datatype = obj.getFirstTensorDatatype(); + if(datatype == dai::TensorInfo::DataType::U8F && !dequantize) { + // In case of dequantization, we should always return float + return py::cast(obj.getFirstTensor(order)); + } else { + return py::cast(obj.getFirstTensor(order, dequantize)); + } + }, + py::arg("storageOrder"), + py::arg("dequantize") = false, + DOC(dai, NNData, getFirstTensor, 2)) + // .def("getTensor", static_cast(NNData::*)(const std::string&)>(&NNData::getTensor), py::arg("name"), DOC(dai, NNData, + // getTensor)) .def("getTensor", static_cast(NNData::*)(const std::string&)>(&NNData::getTensor), py::arg("name"), DOC(dai, + // NNData, getTensor, 2)) .def("getTensor", static_cast(NNData::*)(const std::string&)>(&NNData::getTensor), py::arg("name"), + // DOC(dai, NNData, getTensor, 3)) .def("getTensorDatatype", &NNData::getTensorDatatype, py::arg("name"), DOC(dai, NNData, getTensorDatatype)) .def("getTensorInfo", &NNData::getTensorInfo, py::arg("name"), DOC(dai, NNData, getTensorInfo)) - .def("getTransformation", [](NNData& msg) {return msg.transformation;}) - .def("setTransformation", [](NNData& msg, const std::optional& transformation) {msg.transformation = transformation;}) - ; - - + .def("getTransformation", [](NNData& msg) { return msg.transformation; }) + .def("setTransformation", [](NNData& msg, const std::optional& transformation) { msg.transformation = transformation; }); } diff --git a/bindings/python/src/pipeline/datatype/PointCloudConfigBindings.cpp b/bindings/python/src/pipeline/datatype/PointCloudConfigBindings.cpp index cd91b4e2e..8be62d62f 100644 --- a/bindings/python/src/pipeline/datatype/PointCloudConfigBindings.cpp +++ b/bindings/python/src/pipeline/datatype/PointCloudConfigBindings.cpp @@ -1,19 +1,19 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/PointCloudConfig.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_pointcloudconfig(pybind11::module& m, void* pCallstack){ - +void bind_pointcloudconfig(pybind11::module& m, void* pCallstack) { using namespace dai; // py::class_> rawConfig(m, "RawPointCloudConfig", DOC(dai, RawPointCloudConfig)); @@ -23,7 +23,7 @@ void bind_pointcloudconfig(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -40,8 +40,7 @@ void bind_pointcloudconfig(pybind11::module& m, void* pCallstack){ // ; // Message - config - .def(py::init<>()) + config.def(py::init<>()) .def("__repr__", &PointCloudConfig::str) // .def(py::init>()) @@ -50,15 +49,15 @@ void bind_pointcloudconfig(pybind11::module& m, void* pCallstack){ .def("getSparse", &PointCloudConfig::getSparse, DOC(dai, PointCloudConfig, getSparse)) .def("getTransformationMatrix", &PointCloudConfig::getTransformationMatrix, DOC(dai, PointCloudConfig, getTransformationMatrix)) .def("setSparse", &PointCloudConfig::setSparse, DOC(dai, PointCloudConfig, setSparse)) - .def("setTransformationMatrix", [](PointCloudConfig& cfg, std::array, 3> mat) { - return cfg.setTransformationMatrix(mat); - }, DOC(dai, PointCloudConfig, setTransformationMatrix)) + .def( + "setTransformationMatrix", + [](PointCloudConfig& cfg, std::array, 3> mat) { return cfg.setTransformationMatrix(mat); }, + DOC(dai, PointCloudConfig, setTransformationMatrix)) - .def("setTransformationMatrix", [](PointCloudConfig& cfg, std::array, 4> mat) { - return cfg.setTransformationMatrix(mat); - }, DOC(dai, PointCloudConfig, setTransformationMatrix)) - ; + .def( + "setTransformationMatrix", + [](PointCloudConfig& cfg, std::array, 4> mat) { return cfg.setTransformationMatrix(mat); }, + DOC(dai, PointCloudConfig, setTransformationMatrix)); // add aliases - } diff --git a/bindings/python/src/pipeline/datatype/PointCloudDataBindings.cpp b/bindings/python/src/pipeline/datatype/PointCloudDataBindings.cpp index 05ff629f4..71a5088a3 100644 --- a/bindings/python/src/pipeline/datatype/PointCloudDataBindings.cpp +++ b/bindings/python/src/pipeline/datatype/PointCloudDataBindings.cpp @@ -1,19 +1,19 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/PointCloudData.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_pointclouddata(pybind11::module& m, void* pCallstack){ - +void bind_pointclouddata(pybind11::module& m, void* pCallstack) { using namespace dai; // py::class_> rawPointCloudData(m, "RawPointCloudData", DOC(dai, RawPointCloudData)); @@ -23,7 +23,7 @@ void bind_pointclouddata(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -48,58 +48,60 @@ void bind_pointclouddata(pybind11::module& m, void* pCallstack){ // ; // Message - pointCloudData - .def(py::init<>()) + pointCloudData.def(py::init<>()) .def("__repr__", &PointCloudData::str) - // .def_property("points", [](PointCloudData& data) { return &data.getPoints(); }, [](PointCloudData& data, std::vector points) {data.getPoints() = points;}) - .def("getPoints", [](py::object &obj){ - dai::PointCloudData& data = obj.cast(); - if(data.isColor()){ - Point3fRGB* points = (Point3fRGB*)data.getData().data(); - unsigned long size = data.getData().size() / sizeof(Point3fRGB); - py::array_t arr({size, 3UL}); - auto ra = arr.mutable_unchecked(); - for (int i = 0; i < size; i++) { - ra(i, 0) = points[i].x; - ra(i, 1) = points[i].y; - ra(i, 2) = points[i].z; - } - return arr; - } - Point3f* points = (Point3f*)data.getData().data(); - unsigned long size = data.getData().size() / sizeof(Point3f); - py::array_t arr({size, 3UL}); - auto ra = arr.mutable_unchecked(); - for (int i = 0; i < size; i++) { - ra(i, 0) = points[i].x; - ra(i, 1) = points[i].y; - ra(i, 2) = points[i].z; - } - return arr; - }) - .def("getPointsRGB", [](py::object &obj){ - dai::PointCloudData& data = obj.cast(); - if(!data.isColor()) { - throw std::runtime_error("PointCloudData does not contain color data"); - } - Point3fRGB* points = (Point3fRGB*)data.getData().data(); - unsigned long size = data.getData().size() / sizeof(Point3fRGB); - py::array_t arr({size, 3UL}); - auto ra = arr.mutable_unchecked(); - for (int i = 0; i < size; i++) { - ra(i, 0) = points[i].x; - ra(i, 1) = points[i].y; - ra(i, 2) = points[i].z; - } - py::array_t arr2({size, 3UL}); - auto ra2 = arr2.mutable_unchecked(); - for (int i = 0; i < size; i++) { - ra2(i, 0) = points[i].r; - ra2(i, 1) = points[i].g; - ra2(i, 2) = points[i].b; - } - return py::make_tuple(arr, arr2); - }) + // .def_property("points", [](PointCloudData& data) { return &data.getPoints(); }, [](PointCloudData& data, std::vector points) + // {data.getPoints() = points;}) + .def("getPoints", + [](py::object& obj) { + dai::PointCloudData& data = obj.cast(); + if(data.isColor()) { + Point3fRGB* points = (Point3fRGB*)data.getData().data(); + unsigned long size = data.getData().size() / sizeof(Point3fRGB); + py::array_t arr({size, 3UL}); + auto ra = arr.mutable_unchecked(); + for(int i = 0; i < size; i++) { + ra(i, 0) = points[i].x; + ra(i, 1) = points[i].y; + ra(i, 2) = points[i].z; + } + return arr; + } + Point3f* points = (Point3f*)data.getData().data(); + unsigned long size = data.getData().size() / sizeof(Point3f); + py::array_t arr({size, 3UL}); + auto ra = arr.mutable_unchecked(); + for(int i = 0; i < size; i++) { + ra(i, 0) = points[i].x; + ra(i, 1) = points[i].y; + ra(i, 2) = points[i].z; + } + return arr; + }) + .def("getPointsRGB", + [](py::object& obj) { + dai::PointCloudData& data = obj.cast(); + if(!data.isColor()) { + throw std::runtime_error("PointCloudData does not contain color data"); + } + Point3fRGB* points = (Point3fRGB*)data.getData().data(); + unsigned long size = data.getData().size() / sizeof(Point3fRGB); + py::array_t arr({size, 3UL}); + auto ra = arr.mutable_unchecked(); + for(int i = 0; i < size; i++) { + ra(i, 0) = points[i].x; + ra(i, 1) = points[i].y; + ra(i, 2) = points[i].z; + } + py::array_t arr2({size, 3UL}); + auto ra2 = arr2.mutable_unchecked(); + for(int i = 0; i < size; i++) { + ra2(i, 0) = points[i].r; + ra2(i, 1) = points[i].g; + ra2(i, 2) = points[i].b; + } + return py::make_tuple(arr, arr2); + }) .def("getWidth", &PointCloudData::getWidth, DOC(dai, PointCloudData, getWidth)) .def("getHeight", &PointCloudData::getHeight, DOC(dai, PointCloudData, getHeight)) .def("isSparse", &PointCloudData::isSparse, DOC(dai, PointCloudData, isSparse)) @@ -116,15 +118,20 @@ void bind_pointclouddata(pybind11::module& m, void* pCallstack){ .def("getSequenceNum", &PointCloudData::Buffer::getSequenceNum, DOC(dai, Buffer, getSequenceNum)) .def("setWidth", &PointCloudData::setWidth, DOC(dai, PointCloudData, setWidth)) .def("setHeight", &PointCloudData::setHeight, DOC(dai, PointCloudData, setHeight)) - .def("setSize", static_cast(&PointCloudData::setSize), py::arg("width"), py::arg("height"), DOC(dai, PointCloudData, setSize)) - .def("setSize", static_cast)>(&PointCloudData::setSize), py::arg("size"), DOC(dai, PointCloudData, setSize, 2)) + .def("setSize", + static_cast(&PointCloudData::setSize), + py::arg("width"), + py::arg("height"), + DOC(dai, PointCloudData, setSize)) + .def("setSize", + static_cast)>(&PointCloudData::setSize), + py::arg("size"), + DOC(dai, PointCloudData, setSize, 2)) .def("setMinX", &PointCloudData::setMinX, DOC(dai, PointCloudData, setMinX)) .def("setMinY", &PointCloudData::setMinY, DOC(dai, PointCloudData, setMinY)) .def("setMinZ", &PointCloudData::setMinZ, DOC(dai, PointCloudData, setMinZ)) .def("setMaxX", &PointCloudData::setMaxX, DOC(dai, PointCloudData, setMaxX)) .def("setMaxY", &PointCloudData::setMaxY, DOC(dai, PointCloudData, setMaxY)) .def("setMaxZ", &PointCloudData::setMaxZ, DOC(dai, PointCloudData, setMaxZ)) - .def("setInstanceNum", &PointCloudData::setInstanceNum, DOC(dai, PointCloudData, setInstanceNum)) - ; - + .def("setInstanceNum", &PointCloudData::setInstanceNum, DOC(dai, PointCloudData, setInstanceNum)); } diff --git a/bindings/python/src/pipeline/datatype/SpatialImgDetectionsBindings.cpp b/bindings/python/src/pipeline/datatype/SpatialImgDetectionsBindings.cpp index 00e16610b..d89ec8cf2 100644 --- a/bindings/python/src/pipeline/datatype/SpatialImgDetectionsBindings.cpp +++ b/bindings/python/src/pipeline/datatype/SpatialImgDetectionsBindings.cpp @@ -1,30 +1,32 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/SpatialImgDetections.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_spatialimgdetections(pybind11::module& m, void* pCallstack){ - +void bind_spatialimgdetections(pybind11::module& m, void* pCallstack) { using namespace dai; - // py::class_> rawSpatialImgDetections(m, "RawSpatialImgDetections", DOC(dai, RawSpatialImgDetections)); + // py::class_> rawSpatialImgDetections(m, "RawSpatialImgDetections", DOC(dai, + // RawSpatialImgDetections)); py::class_ spatialImgDetection(m, "SpatialImgDetection", DOC(dai, SpatialImgDetection)); - py::class_, Buffer, std::shared_ptr> spatialImgDetections(m, "SpatialImgDetections", DOC(dai, SpatialImgDetections)); + py::class_, Buffer, std::shared_ptr> spatialImgDetections( + m, "SpatialImgDetections", DOC(dai, SpatialImgDetections)); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -34,11 +36,9 @@ void bind_spatialimgdetections(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Metadata / raw - spatialImgDetection - .def(py::init<>()) + spatialImgDetection.def(py::init<>()) .def_readwrite("spatialCoordinates", &SpatialImgDetection::spatialCoordinates) - .def_readwrite("boundingBoxMapping", &SpatialImgDetection::boundingBoxMapping) - ; + .def_readwrite("boundingBoxMapping", &SpatialImgDetection::boundingBoxMapping); // rawSpatialImgDetections // .def(py::init<>()) @@ -67,20 +67,20 @@ void bind_spatialimgdetections(pybind11::module& m, void* pCallstack){ // ; // Message - spatialImgDetections - .def(py::init<>()) + spatialImgDetections.def(py::init<>()) .def("__repr__", &SpatialImgDetections::str) - .def_property("detections", [](SpatialImgDetections& det) { return &det.detections; }, [](SpatialImgDetections& det, std::vector val) { det.detections = val; }) + .def_property( + "detections", + [](SpatialImgDetections& det) { return &det.detections; }, + [](SpatialImgDetections& det, std::vector val) { det.detections = val; }) .def("getTimestamp", &SpatialImgDetections::Buffer::getTimestamp, DOC(dai, Buffer, getTimestamp)) .def("getTimestampDevice", &SpatialImgDetections::Buffer::getTimestampDevice, DOC(dai, Buffer, getTimestampDevice)) .def("getSequenceNum", &SpatialImgDetections::Buffer::getSequenceNum, DOC(dai, Buffer, getSequenceNum)) - .def("getTransformation", [](SpatialImgDetections& msg) {return msg.transformation;}) - .def("setTransformation", [](SpatialImgDetections& msg, const std::optional& transformation) {msg.transformation = transformation;}) + .def("getTransformation", [](SpatialImgDetections& msg) { return msg.transformation; }) + .def("setTransformation", + [](SpatialImgDetections& msg, const std::optional& transformation) { msg.transformation = transformation; }) // .def("setTimestamp", &SpatialImgDetections::setTimestamp, DOC(dai, SpatialImgDetections, setTimestamp)) // .def("setTimestampDevice", &SpatialImgDetections::setTimestampDevice, DOC(dai, SpatialImgDetections, setTimestampDevice)) // .def("setSequenceNum", &SpatialImgDetections::setSequenceNum, DOC(dai, SpatialImgDetections, setSequenceNum)) ; - - - } diff --git a/bindings/python/src/pipeline/datatype/SpatialLocationCalculatorConfigBindings.cpp b/bindings/python/src/pipeline/datatype/SpatialLocationCalculatorConfigBindings.cpp index 007c1548d..3cc29af05 100644 --- a/bindings/python/src/pipeline/datatype/SpatialLocationCalculatorConfigBindings.cpp +++ b/bindings/python/src/pipeline/datatype/SpatialLocationCalculatorConfigBindings.cpp @@ -1,31 +1,35 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/SpatialLocationCalculatorConfig.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_spatiallocationcalculatorconfig(pybind11::module& m, void* pCallstack){ - +void bind_spatiallocationcalculatorconfig(pybind11::module& m, void* pCallstack) { using namespace dai; - py::class_ spatialLocationCalculatorConfigThresholds(m, "SpatialLocationCalculatorConfigThresholds", DOC(dai, SpatialLocationCalculatorConfigThresholds)); - py::enum_ spatialLocationCalculatorAlgorithm(m, "SpatialLocationCalculatorAlgorithm", DOC(dai, SpatialLocationCalculatorAlgorithm)); - py::class_ spatialLocationCalculatorConfigData(m, "SpatialLocationCalculatorConfigData", DOC(dai, SpatialLocationCalculatorConfigData)); - py::class_, Buffer, std::shared_ptr> spatialLocationCalculatorConfig(m, "SpatialLocationCalculatorConfig", DOC(dai, SpatialLocationCalculatorConfig)); + py::class_ spatialLocationCalculatorConfigThresholds( + m, "SpatialLocationCalculatorConfigThresholds", DOC(dai, SpatialLocationCalculatorConfigThresholds)); + py::enum_ spatialLocationCalculatorAlgorithm( + m, "SpatialLocationCalculatorAlgorithm", DOC(dai, SpatialLocationCalculatorAlgorithm)); + py::class_ spatialLocationCalculatorConfigData( + m, "SpatialLocationCalculatorConfigData", DOC(dai, SpatialLocationCalculatorConfigData)); + py::class_, Buffer, std::shared_ptr> + spatialLocationCalculatorConfig(m, "SpatialLocationCalculatorConfig", DOC(dai, SpatialLocationCalculatorConfig)); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -35,31 +39,26 @@ void bind_spatiallocationcalculatorconfig(pybind11::module& m, void* pCallstack) /////////////////////////////////////////////////////////////////////// // Metadata / raw - spatialLocationCalculatorConfigThresholds - .def(py::init<>()) + spatialLocationCalculatorConfigThresholds.def(py::init<>()) .def_readwrite("lowerThreshold", &SpatialLocationCalculatorConfigThresholds::lowerThreshold) - .def_readwrite("upperThreshold", &SpatialLocationCalculatorConfigThresholds::upperThreshold) - ; + .def_readwrite("upperThreshold", &SpatialLocationCalculatorConfigThresholds::upperThreshold); - spatialLocationCalculatorAlgorithm - .value("AVERAGE", SpatialLocationCalculatorAlgorithm::AVERAGE) + spatialLocationCalculatorAlgorithm.value("AVERAGE", SpatialLocationCalculatorAlgorithm::AVERAGE) .value("MEAN", SpatialLocationCalculatorAlgorithm::MEAN) .value("MIN", SpatialLocationCalculatorAlgorithm::MIN) .value("MAX", SpatialLocationCalculatorAlgorithm::MAX) .value("MODE", SpatialLocationCalculatorAlgorithm::MODE) - .value("MEDIAN", SpatialLocationCalculatorAlgorithm::MEDIAN) - ; + .value("MEDIAN", SpatialLocationCalculatorAlgorithm::MEDIAN); - spatialLocationCalculatorConfigData - .def(py::init<>()) + spatialLocationCalculatorConfigData.def(py::init<>()) .def_readwrite("roi", &SpatialLocationCalculatorConfigData::roi, DOC(dai, SpatialLocationCalculatorConfigData, roi)) .def_readwrite("depthThresholds", &SpatialLocationCalculatorConfigData::depthThresholds, DOC(dai, SpatialLocationCalculatorConfigData, depthThresholds)) - .def_readwrite("calculationAlgorithm", &SpatialLocationCalculatorConfigData::calculationAlgorithm, DOC(dai, SpatialLocationCalculatorConfigData, calculationAlgorithm)) - ; + .def_readwrite("calculationAlgorithm", + &SpatialLocationCalculatorConfigData::calculationAlgorithm, + DOC(dai, SpatialLocationCalculatorConfigData, calculationAlgorithm)); // Message - spatialLocationCalculatorConfig - .def(py::init<>()) + spatialLocationCalculatorConfig.def(py::init<>()) .def("__repr__", &SpatialLocationCalculatorConfig::str) // setters .def("setROIs", &SpatialLocationCalculatorConfig::setROIs, py::arg("ROIs"), DOC(dai, SpatialLocationCalculatorConfig, setROIs)) @@ -68,5 +67,4 @@ void bind_spatiallocationcalculatorconfig(pybind11::module& m, void* pCallstack) // .def("set", &SpatialLocationCalculatorConfig::set, py::arg("config"), DOC(dai, SpatialLocationCalculatorConfig, set)) // .def("get", &SpatialLocationCalculatorConfig::get, DOC(dai, SpatialLocationCalculatorConfig, get)) ; - } diff --git a/bindings/python/src/pipeline/datatype/SpatialLocationCalculatorDataBindings.cpp b/bindings/python/src/pipeline/datatype/SpatialLocationCalculatorDataBindings.cpp index 2848cfda0..d5dbbf08b 100644 --- a/bindings/python/src/pipeline/datatype/SpatialLocationCalculatorDataBindings.cpp +++ b/bindings/python/src/pipeline/datatype/SpatialLocationCalculatorDataBindings.cpp @@ -1,29 +1,30 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/SpatialLocationCalculatorData.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_spatiallocationcalculatordata(pybind11::module& m, void* pCallstack){ - +void bind_spatiallocationcalculatordata(pybind11::module& m, void* pCallstack) { using namespace dai; - py::class_, Buffer, std::shared_ptr> spatialLocationCalculatorData(m, "SpatialLocationCalculatorData", DOC(dai, SpatialLocationCalculatorData)); + py::class_, Buffer, std::shared_ptr> + spatialLocationCalculatorData(m, "SpatialLocationCalculatorData", DOC(dai, SpatialLocationCalculatorData)); py::class_ spatialLocations(m, "SpatialLocations", DOC(dai, SpatialLocations)); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -33,8 +34,7 @@ void bind_spatiallocationcalculatordata(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Metadata / raw - spatialLocations - .def(py::init<>()) + spatialLocations.def(py::init<>()) .def_readwrite("config", &SpatialLocations::config, DOC(dai, SpatialLocations, config)) .def_readwrite("depthAverage", &SpatialLocations::depthAverage, DOC(dai, SpatialLocations, depthAverage)) .def_readwrite("depthMode", &SpatialLocations::depthMode, DOC(dai, SpatialLocations, depthMode)) @@ -42,15 +42,17 @@ void bind_spatiallocationcalculatordata(pybind11::module& m, void* pCallstack){ .def_readwrite("depthMin", &SpatialLocations::depthMin, DOC(dai, SpatialLocations, depthMin)) .def_readwrite("depthMax", &SpatialLocations::depthMax, DOC(dai, SpatialLocations, depthMax)) .def_readwrite("depthAveragePixelCount", &SpatialLocations::depthAveragePixelCount, DOC(dai, SpatialLocations, depthAveragePixelCount)) - .def_readwrite("spatialCoordinates", &SpatialLocations::spatialCoordinates, DOC(dai, SpatialLocations, spatialCoordinates)) - ; + .def_readwrite("spatialCoordinates", &SpatialLocations::spatialCoordinates, DOC(dai, SpatialLocations, spatialCoordinates)); // Message - spatialLocationCalculatorData - .def(py::init<>()) + spatialLocationCalculatorData.def(py::init<>()) .def("__repr__", &SpatialLocationCalculatorData::str) .def("getSpatialLocations", &SpatialLocationCalculatorData::getSpatialLocations, DOC(dai, SpatialLocationCalculatorData, getSpatialLocations)) - .def_property("spatialLocations", [](SpatialLocationCalculatorData& loc) { return &loc.spatialLocations; }, [](SpatialLocationCalculatorData& loc, std::vector val) { loc.spatialLocations = val; }, DOC(dai, SpatialLocationCalculatorData, spatialLocations)) + .def_property( + "spatialLocations", + [](SpatialLocationCalculatorData& loc) { return &loc.spatialLocations; }, + [](SpatialLocationCalculatorData& loc, std::vector val) { loc.spatialLocations = val; }, + DOC(dai, SpatialLocationCalculatorData, spatialLocations)) .def("getTimestamp", &SpatialLocationCalculatorData::Buffer::getTimestamp, DOC(dai, Buffer, getTimestamp)) .def("getTimestampDevice", &SpatialLocationCalculatorData::Buffer::getTimestampDevice, DOC(dai, Buffer, getTimestampDevice)) .def("getSequenceNum", &SpatialLocationCalculatorData::Buffer::getSequenceNum, DOC(dai, Buffer, getSequenceNum)) @@ -58,6 +60,4 @@ void bind_spatiallocationcalculatordata(pybind11::module& m, void* pCallstack){ // .def("setTimestampDevice", &SpatialLocationCalculatorData::setTimestampDevice, DOC(dai, SpatialLocationCalculatorData, setTimestampDevice)) // .def("setSequenceNum", &SpatialLocationCalculatorData::setSequenceNum, DOC(dai, SpatialLocationCalculatorData, setSequenceNum)) ; - - } diff --git a/bindings/python/src/pipeline/datatype/StereoDepthConfigBindings.cpp b/bindings/python/src/pipeline/datatype/StereoDepthConfigBindings.cpp index b4750ffbb..2983c0f6c 100644 --- a/bindings/python/src/pipeline/datatype/StereoDepthConfigBindings.cpp +++ b/bindings/python/src/pipeline/datatype/StereoDepthConfigBindings.cpp @@ -1,53 +1,70 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/StereoDepthConfig.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_stereodepthconfig(pybind11::module& m, void* pCallstack){ - +void bind_stereodepthconfig(pybind11::module& m, void* pCallstack) { using namespace dai; - // py::class_> rawStereoDepthConfig(m, "RawStereoDepthConfig", DOC(dai, RawStereoDepthConfig)); - py::class_, Buffer, std::shared_ptr> stereoDepthConfig(m, "StereoDepthConfig", DOC(dai, StereoDepthConfig)); + // py::class_> rawStereoDepthConfig(m, "RawStereoDepthConfig", DOC(dai, + // RawStereoDepthConfig)); + py::class_, Buffer, std::shared_ptr> stereoDepthConfig( + m, "StereoDepthConfig", DOC(dai, StereoDepthConfig)); py::enum_ medianFilter(m, "MedianFilter", DOC(dai, MedianFilter)); py::class_ _ConfidenceMetrics(stereoDepthConfig, "ConfidenceMetrics", DOC(dai, StereoDepthConfig, ConfidenceMetrics)); py::class_ algorithmControl(stereoDepthConfig, "AlgorithmControl", DOC(dai, StereoDepthConfig, AlgorithmControl)); - py::enum_ depthAlign(algorithmControl, "DepthAlign", DOC(dai, StereoDepthConfig, AlgorithmControl, DepthAlign)); - py::enum_ depthUnit(algorithmControl, "DepthUnit", DOC(dai, StereoDepthConfig, AlgorithmControl, DepthUnit)); + py::enum_ depthAlign( + algorithmControl, "DepthAlign", DOC(dai, StereoDepthConfig, AlgorithmControl, DepthAlign)); + py::enum_ depthUnit( + algorithmControl, "DepthUnit", DOC(dai, StereoDepthConfig, AlgorithmControl, DepthUnit)); py::class_ postProcessing(stereoDepthConfig, "PostProcessing", DOC(dai, StereoDepthConfig, PostProcessing)); - py::class_ spatialFilter(postProcessing, "SpatialFilter", DOC(dai, StereoDepthConfig, PostProcessing, SpatialFilter)); - py::class_ temporalFilter(postProcessing, "TemporalFilter", DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter)); - py::enum_ persistencyMode(temporalFilter, "PersistencyMode", DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode)); - py::class_ thresholdFilter(postProcessing, "ThresholdFilter", DOC(dai, StereoDepthConfig, PostProcessing, ThresholdFilter)); - py::class_ brightnessFilter(postProcessing, "BrightnessFilter", DOC(dai, StereoDepthConfig, PostProcessing, BrightnessFilter)); - py::class_ speckleFilter(postProcessing, "SpeckleFilter", DOC(dai, StereoDepthConfig, PostProcessing, SpeckleFilter)); - py::class_ decimationFilter(postProcessing, "DecimationFilter", DOC(dai, StereoDepthConfig, PostProcessing, DecimationFilter)); - py::enum_ decimationMode(decimationFilter, "DecimationMode", DOC(dai, StereoDepthConfig, PostProcessing, DecimationFilter, DecimationMode)); - py::class_ _HoleFilling(postProcessing, "HoleFilling", DOC(dai, StereoDepthConfig, PostProcessing, HoleFilling)); - py::class_ _AdaptiveMedianFilter(postProcessing, "AdaptiveMedianFilter", DOC(dai, StereoDepthConfig, PostProcessing, AdaptiveMedianFilter)); + py::class_ spatialFilter( + postProcessing, "SpatialFilter", DOC(dai, StereoDepthConfig, PostProcessing, SpatialFilter)); + py::class_ temporalFilter( + postProcessing, "TemporalFilter", DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter)); + py::enum_ persistencyMode( + temporalFilter, "PersistencyMode", DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode)); + py::class_ thresholdFilter( + postProcessing, "ThresholdFilter", DOC(dai, StereoDepthConfig, PostProcessing, ThresholdFilter)); + py::class_ brightnessFilter( + postProcessing, "BrightnessFilter", DOC(dai, StereoDepthConfig, PostProcessing, BrightnessFilter)); + py::class_ speckleFilter( + postProcessing, "SpeckleFilter", DOC(dai, StereoDepthConfig, PostProcessing, SpeckleFilter)); + py::class_ decimationFilter( + postProcessing, "DecimationFilter", DOC(dai, StereoDepthConfig, PostProcessing, DecimationFilter)); + py::enum_ decimationMode( + decimationFilter, "DecimationMode", DOC(dai, StereoDepthConfig, PostProcessing, DecimationFilter, DecimationMode)); + py::class_ _HoleFilling( + postProcessing, "HoleFilling", DOC(dai, StereoDepthConfig, PostProcessing, HoleFilling)); + py::class_ _AdaptiveMedianFilter( + postProcessing, "AdaptiveMedianFilter", DOC(dai, StereoDepthConfig, PostProcessing, AdaptiveMedianFilter)); py::class_ costAggregation(stereoDepthConfig, "CostAggregation", DOC(dai, StereoDepthConfig, CostAggregation)); py::class_ _P1Config(costAggregation, "P1Config", DOC(dai, StereoDepthConfig, CostAggregation, P1Config)); py::class_ _P2Config(costAggregation, "P2Config", DOC(dai, StereoDepthConfig, CostAggregation, P2Config)); py::class_ costMatching(stereoDepthConfig, "CostMatching", DOC(dai, StereoDepthConfig, CostMatching)); - py::class_ costMatchingLinearEquationParameters(costMatching, "LinearEquationParameters", DOC(dai, StereoDepthConfig, CostMatching, LinearEquationParameters)); - py::enum_ costMatchingDisparityWidth(costMatching, "DisparityWidth", DOC(dai, StereoDepthConfig, CostMatching, DisparityWidth)); + py::class_ costMatchingLinearEquationParameters( + costMatching, "LinearEquationParameters", DOC(dai, StereoDepthConfig, CostMatching, LinearEquationParameters)); + py::enum_ costMatchingDisparityWidth( + costMatching, "DisparityWidth", DOC(dai, StereoDepthConfig, CostMatching, DisparityWidth)); py::class_ censusTransform(stereoDepthConfig, "CensusTransform", DOC(dai, StereoDepthConfig, CensusTransform)); - py::enum_ censusTransformKernelSize(censusTransform, "KernelSize", DOC(dai, StereoDepthConfig, CensusTransform, KernelSize)); + py::enum_ censusTransformKernelSize( + censusTransform, "KernelSize", DOC(dai, StereoDepthConfig, CensusTransform, KernelSize)); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -57,254 +74,335 @@ void bind_stereodepthconfig(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Metadata / raw - medianFilter - .value("MEDIAN_OFF", StereoDepthConfig::MedianFilter::MEDIAN_OFF) + medianFilter.value("MEDIAN_OFF", StereoDepthConfig::MedianFilter::MEDIAN_OFF) .value("KERNEL_3x3", StereoDepthConfig::MedianFilter::KERNEL_3x3) .value("KERNEL_5x5", StereoDepthConfig::MedianFilter::KERNEL_5x5) - .value("KERNEL_7x7", StereoDepthConfig::MedianFilter::KERNEL_7x7) - ; - //m.attr("StereoDepthProperties").attr("MedianFilter") = medianFilter; - + .value("KERNEL_7x7", StereoDepthConfig::MedianFilter::KERNEL_7x7); + // m.attr("StereoDepthProperties").attr("MedianFilter") = medianFilter; depthAlign - .value("RECTIFIED_RIGHT", StereoDepthConfig::AlgorithmControl::DepthAlign::RECTIFIED_RIGHT, DOC(dai, StereoDepthConfig, AlgorithmControl, DepthAlign, RECTIFIED_RIGHT)) - .value("RECTIFIED_LEFT", StereoDepthConfig::AlgorithmControl::DepthAlign::RECTIFIED_LEFT, DOC(dai, StereoDepthConfig, AlgorithmControl, DepthAlign, RECTIFIED_LEFT)) + .value("RECTIFIED_RIGHT", + StereoDepthConfig::AlgorithmControl::DepthAlign::RECTIFIED_RIGHT, + DOC(dai, StereoDepthConfig, AlgorithmControl, DepthAlign, RECTIFIED_RIGHT)) + .value("RECTIFIED_LEFT", + StereoDepthConfig::AlgorithmControl::DepthAlign::RECTIFIED_LEFT, + DOC(dai, StereoDepthConfig, AlgorithmControl, DepthAlign, RECTIFIED_LEFT)) .value("CENTER", StereoDepthConfig::AlgorithmControl::DepthAlign::CENTER, DOC(dai, StereoDepthConfig, AlgorithmControl, DepthAlign, CENTER)); - //m.attr("StereoDepthProperties").attr("DepthAlign") = depthAlign; + // m.attr("StereoDepthProperties").attr("DepthAlign") = depthAlign; - depthUnit - .value("METER", StereoDepthConfig::AlgorithmControl::DepthUnit::METER, DOC(dai, StereoDepthConfig, AlgorithmControl, DepthUnit, METER)) + depthUnit.value("METER", StereoDepthConfig::AlgorithmControl::DepthUnit::METER, DOC(dai, StereoDepthConfig, AlgorithmControl, DepthUnit, METER)) .value("CENTIMETER", StereoDepthConfig::AlgorithmControl::DepthUnit::CENTIMETER, DOC(dai, StereoDepthConfig, AlgorithmControl, DepthUnit, CENTIMETER)) .value("MILLIMETER", StereoDepthConfig::AlgorithmControl::DepthUnit::MILLIMETER, DOC(dai, StereoDepthConfig, AlgorithmControl, DepthUnit, MILLIMETER)) .value("INCH", StereoDepthConfig::AlgorithmControl::DepthUnit::INCH, DOC(dai, StereoDepthConfig, AlgorithmControl, DepthUnit, INCH)) .value("FOOT", StereoDepthConfig::AlgorithmControl::DepthUnit::FOOT, DOC(dai, StereoDepthConfig, AlgorithmControl, DepthUnit, FOOT)) - .value("CUSTOM", StereoDepthConfig::AlgorithmControl::DepthUnit::CUSTOM, DOC(dai, StereoDepthConfig, AlgorithmControl, DepthUnit, CUSTOM)) - ; + .value("CUSTOM", StereoDepthConfig::AlgorithmControl::DepthUnit::CUSTOM, DOC(dai, StereoDepthConfig, AlgorithmControl, DepthUnit, CUSTOM)); - algorithmControl - .def(py::init<>()) + algorithmControl.def(py::init<>()) .def_readwrite("depthAlign", &StereoDepthConfig::AlgorithmControl::depthAlign, DOC(dai, StereoDepthConfig, AlgorithmControl, depthAlign)) .def_readwrite("depthUnit", &StereoDepthConfig::AlgorithmControl::depthUnit, DOC(dai, StereoDepthConfig, AlgorithmControl, depthUnit)) - .def_readwrite("customDepthUnitMultiplier", &StereoDepthConfig::AlgorithmControl::customDepthUnitMultiplier, DOC(dai, StereoDepthConfig, AlgorithmControl, customDepthUnitMultiplier)) - .def_readwrite("enableLeftRightCheck", &StereoDepthConfig::AlgorithmControl::enableLeftRightCheck, DOC(dai, StereoDepthConfig, AlgorithmControl, enableLeftRightCheck)) + .def_readwrite("customDepthUnitMultiplier", + &StereoDepthConfig::AlgorithmControl::customDepthUnitMultiplier, + DOC(dai, StereoDepthConfig, AlgorithmControl, customDepthUnitMultiplier)) + .def_readwrite("enableLeftRightCheck", + &StereoDepthConfig::AlgorithmControl::enableLeftRightCheck, + DOC(dai, StereoDepthConfig, AlgorithmControl, enableLeftRightCheck)) .def_readwrite("enableExtended", &StereoDepthConfig::AlgorithmControl::enableExtended, DOC(dai, StereoDepthConfig, AlgorithmControl, enableExtended)) .def_readwrite("enableSubpixel", &StereoDepthConfig::AlgorithmControl::enableSubpixel, DOC(dai, StereoDepthConfig, AlgorithmControl, enableSubpixel)) - .def_readwrite("leftRightCheckThreshold", &StereoDepthConfig::AlgorithmControl::leftRightCheckThreshold, DOC(dai, StereoDepthConfig, AlgorithmControl, leftRightCheckThreshold)) - .def_readwrite("subpixelFractionalBits", &StereoDepthConfig::AlgorithmControl::subpixelFractionalBits, DOC(dai, StereoDepthConfig, AlgorithmControl, subpixelFractionalBits)) + .def_readwrite("leftRightCheckThreshold", + &StereoDepthConfig::AlgorithmControl::leftRightCheckThreshold, + DOC(dai, StereoDepthConfig, AlgorithmControl, leftRightCheckThreshold)) + .def_readwrite("subpixelFractionalBits", + &StereoDepthConfig::AlgorithmControl::subpixelFractionalBits, + DOC(dai, StereoDepthConfig, AlgorithmControl, subpixelFractionalBits)) .def_readwrite("disparityShift", &StereoDepthConfig::AlgorithmControl::disparityShift, DOC(dai, StereoDepthConfig, AlgorithmControl, disparityShift)) - .def_readwrite("centerAlignmentShiftFactor", &StereoDepthConfig::AlgorithmControl::centerAlignmentShiftFactor, DOC(dai, StereoDepthConfig, AlgorithmControl, centerAlignmentShiftFactor)) - .def_readwrite("numInvalidateEdgePixels", &StereoDepthConfig::AlgorithmControl::numInvalidateEdgePixels, DOC(dai, StereoDepthConfig, AlgorithmControl, numInvalidateEdgePixels)) - ; - - _ConfidenceMetrics - .def(py::init<>()) - .def_readwrite("occlusionConfidenceWeight", &StereoDepthConfig::ConfidenceMetrics::occlusionConfidenceWeight, DOC(dai, StereoDepthConfig, ConfidenceMetrics, occlusionConfidenceWeight)) - .def_readwrite("motionVectorConfidenceWeight", &StereoDepthConfig::ConfidenceMetrics::motionVectorConfidenceWeight, DOC(dai, StereoDepthConfig, ConfidenceMetrics, motionVectorConfidenceWeight)) - .def_readwrite("motionVectorConfidenceThreshold", &StereoDepthConfig::ConfidenceMetrics::motionVectorConfidenceThreshold, DOC(dai, StereoDepthConfig, ConfidenceMetrics, motionVectorConfidenceThreshold)) - .def_readwrite("flatnessConfidenceWeight", &StereoDepthConfig::ConfidenceMetrics::flatnessConfidenceWeight, DOC(dai, StereoDepthConfig, ConfidenceMetrics, flatnessConfidenceWeight)) - .def_readwrite("flatnessConfidenceThreshold", &StereoDepthConfig::ConfidenceMetrics::flatnessConfidenceThreshold, DOC(dai, StereoDepthConfig, ConfidenceMetrics, flatnessConfidenceThreshold)) - .def_readwrite("flatnessOverride", &StereoDepthConfig::ConfidenceMetrics::flatnessOverride, DOC(dai, StereoDepthConfig, ConfidenceMetrics, flatnessOverride)) - ; - - spatialFilter - .def(py::init<>()) + .def_readwrite("centerAlignmentShiftFactor", + &StereoDepthConfig::AlgorithmControl::centerAlignmentShiftFactor, + DOC(dai, StereoDepthConfig, AlgorithmControl, centerAlignmentShiftFactor)) + .def_readwrite("numInvalidateEdgePixels", + &StereoDepthConfig::AlgorithmControl::numInvalidateEdgePixels, + DOC(dai, StereoDepthConfig, AlgorithmControl, numInvalidateEdgePixels)); + + _ConfidenceMetrics.def(py::init<>()) + .def_readwrite("occlusionConfidenceWeight", + &StereoDepthConfig::ConfidenceMetrics::occlusionConfidenceWeight, + DOC(dai, StereoDepthConfig, ConfidenceMetrics, occlusionConfidenceWeight)) + .def_readwrite("motionVectorConfidenceWeight", + &StereoDepthConfig::ConfidenceMetrics::motionVectorConfidenceWeight, + DOC(dai, StereoDepthConfig, ConfidenceMetrics, motionVectorConfidenceWeight)) + .def_readwrite("motionVectorConfidenceThreshold", + &StereoDepthConfig::ConfidenceMetrics::motionVectorConfidenceThreshold, + DOC(dai, StereoDepthConfig, ConfidenceMetrics, motionVectorConfidenceThreshold)) + .def_readwrite("flatnessConfidenceWeight", + &StereoDepthConfig::ConfidenceMetrics::flatnessConfidenceWeight, + DOC(dai, StereoDepthConfig, ConfidenceMetrics, flatnessConfidenceWeight)) + .def_readwrite("flatnessConfidenceThreshold", + &StereoDepthConfig::ConfidenceMetrics::flatnessConfidenceThreshold, + DOC(dai, StereoDepthConfig, ConfidenceMetrics, flatnessConfidenceThreshold)) + .def_readwrite( + "flatnessOverride", &StereoDepthConfig::ConfidenceMetrics::flatnessOverride, DOC(dai, StereoDepthConfig, ConfidenceMetrics, flatnessOverride)); + + spatialFilter.def(py::init<>()) .def_readwrite("enable", &StereoDepthConfig::PostProcessing::SpatialFilter::enable, DOC(dai, StereoDepthConfig, PostProcessing, SpatialFilter, enable)) - .def_readwrite("holeFillingRadius", &StereoDepthConfig::PostProcessing::SpatialFilter::holeFillingRadius, DOC(dai, StereoDepthConfig, PostProcessing, SpatialFilter, holeFillingRadius)) + .def_readwrite("holeFillingRadius", + &StereoDepthConfig::PostProcessing::SpatialFilter::holeFillingRadius, + DOC(dai, StereoDepthConfig, PostProcessing, SpatialFilter, holeFillingRadius)) .def_readwrite("alpha", &StereoDepthConfig::PostProcessing::SpatialFilter::alpha, DOC(dai, StereoDepthConfig, PostProcessing, SpatialFilter, alpha)) .def_readwrite("delta", &StereoDepthConfig::PostProcessing::SpatialFilter::delta, DOC(dai, StereoDepthConfig, PostProcessing, SpatialFilter, delta)) - .def_readwrite("numIterations", &StereoDepthConfig::PostProcessing::SpatialFilter::numIterations, DOC(dai, StereoDepthConfig, PostProcessing, SpatialFilter, numIterations)) - ; + .def_readwrite("numIterations", + &StereoDepthConfig::PostProcessing::SpatialFilter::numIterations, + DOC(dai, StereoDepthConfig, PostProcessing, SpatialFilter, numIterations)); persistencyMode - .value("PERSISTENCY_OFF", StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::PERSISTENCY_OFF, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, PERSISTENCY_OFF)) - .value("VALID_8_OUT_OF_8", StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::VALID_8_OUT_OF_8, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, VALID_8_OUT_OF_8)) - .value("VALID_2_IN_LAST_3", StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::VALID_2_IN_LAST_3, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, VALID_2_IN_LAST_3)) - .value("VALID_2_IN_LAST_4", StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::VALID_2_IN_LAST_4, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, VALID_2_IN_LAST_4)) - .value("VALID_2_OUT_OF_8", StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::VALID_2_OUT_OF_8, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, VALID_2_OUT_OF_8)) - .value("VALID_1_IN_LAST_2", StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::VALID_1_IN_LAST_2, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, VALID_1_IN_LAST_2)) - .value("VALID_1_IN_LAST_5", StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::VALID_1_IN_LAST_5, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, VALID_1_IN_LAST_5)) - .value("VALID_1_IN_LAST_8", StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::VALID_1_IN_LAST_8, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, VALID_1_IN_LAST_8)) - .value("PERSISTENCY_INDEFINITELY", StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::PERSISTENCY_INDEFINITELY, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, PERSISTENCY_INDEFINITELY)) - ; - - temporalFilter - .def(py::init<>()) - .def_readwrite("enable", &StereoDepthConfig::PostProcessing::TemporalFilter::enable, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, enable)) - .def_readwrite("persistencyMode", &StereoDepthConfig::PostProcessing::TemporalFilter::persistencyMode, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, persistencyMode)) + .value("PERSISTENCY_OFF", + StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::PERSISTENCY_OFF, + DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, PERSISTENCY_OFF)) + .value("VALID_8_OUT_OF_8", + StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::VALID_8_OUT_OF_8, + DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, VALID_8_OUT_OF_8)) + .value("VALID_2_IN_LAST_3", + StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::VALID_2_IN_LAST_3, + DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, VALID_2_IN_LAST_3)) + .value("VALID_2_IN_LAST_4", + StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::VALID_2_IN_LAST_4, + DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, VALID_2_IN_LAST_4)) + .value("VALID_2_OUT_OF_8", + StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::VALID_2_OUT_OF_8, + DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, VALID_2_OUT_OF_8)) + .value("VALID_1_IN_LAST_2", + StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::VALID_1_IN_LAST_2, + DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, VALID_1_IN_LAST_2)) + .value("VALID_1_IN_LAST_5", + StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::VALID_1_IN_LAST_5, + DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, VALID_1_IN_LAST_5)) + .value("VALID_1_IN_LAST_8", + StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::VALID_1_IN_LAST_8, + DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, VALID_1_IN_LAST_8)) + .value("PERSISTENCY_INDEFINITELY", + StereoDepthConfig::PostProcessing::TemporalFilter::PersistencyMode::PERSISTENCY_INDEFINITELY, + DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, PersistencyMode, PERSISTENCY_INDEFINITELY)); + + temporalFilter.def(py::init<>()) + .def_readwrite( + "enable", &StereoDepthConfig::PostProcessing::TemporalFilter::enable, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, enable)) + .def_readwrite("persistencyMode", + &StereoDepthConfig::PostProcessing::TemporalFilter::persistencyMode, + DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, persistencyMode)) .def_readwrite("alpha", &StereoDepthConfig::PostProcessing::TemporalFilter::alpha, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, alpha)) - .def_readwrite("delta", &StereoDepthConfig::PostProcessing::TemporalFilter::delta, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, delta)) - ; - - thresholdFilter - .def(py::init<>()) - .def_readwrite("minRange", &StereoDepthConfig::PostProcessing::ThresholdFilter::minRange, DOC(dai, StereoDepthConfig, PostProcessing, ThresholdFilter, minRange)) - .def_readwrite("maxRange", &StereoDepthConfig::PostProcessing::ThresholdFilter::maxRange, DOC(dai, StereoDepthConfig, PostProcessing, ThresholdFilter, maxRange)) - ; - - brightnessFilter - .def(py::init<>()) - .def_readwrite("minBrightness", &StereoDepthConfig::PostProcessing::BrightnessFilter::minBrightness, DOC(dai, StereoDepthConfig, PostProcessing, BrightnessFilter, minBrightness)) - .def_readwrite("maxBrightness", &StereoDepthConfig::PostProcessing::BrightnessFilter::maxBrightness, DOC(dai, StereoDepthConfig, PostProcessing, BrightnessFilter, maxBrightness)) - ; - - speckleFilter - .def(py::init<>()) + .def_readwrite("delta", &StereoDepthConfig::PostProcessing::TemporalFilter::delta, DOC(dai, StereoDepthConfig, PostProcessing, TemporalFilter, delta)); + + thresholdFilter.def(py::init<>()) + .def_readwrite( + "minRange", &StereoDepthConfig::PostProcessing::ThresholdFilter::minRange, DOC(dai, StereoDepthConfig, PostProcessing, ThresholdFilter, minRange)) + .def_readwrite( + "maxRange", &StereoDepthConfig::PostProcessing::ThresholdFilter::maxRange, DOC(dai, StereoDepthConfig, PostProcessing, ThresholdFilter, maxRange)); + + brightnessFilter.def(py::init<>()) + .def_readwrite("minBrightness", + &StereoDepthConfig::PostProcessing::BrightnessFilter::minBrightness, + DOC(dai, StereoDepthConfig, PostProcessing, BrightnessFilter, minBrightness)) + .def_readwrite("maxBrightness", + &StereoDepthConfig::PostProcessing::BrightnessFilter::maxBrightness, + DOC(dai, StereoDepthConfig, PostProcessing, BrightnessFilter, maxBrightness)); + + speckleFilter.def(py::init<>()) .def_readwrite("enable", &StereoDepthConfig::PostProcessing::SpeckleFilter::enable, DOC(dai, StereoDepthConfig, PostProcessing, SpeckleFilter, enable)) - .def_readwrite("speckleRange", &StereoDepthConfig::PostProcessing::SpeckleFilter::speckleRange, DOC(dai, StereoDepthConfig, PostProcessing, SpeckleFilter, speckleRange)) - .def_readwrite("differenceThreshold", &StereoDepthConfig::PostProcessing::SpeckleFilter::differenceThreshold, DOC(dai, StereoDepthConfig, PostProcessing, SpeckleFilter, differenceThreshold)) - ; + .def_readwrite("speckleRange", + &StereoDepthConfig::PostProcessing::SpeckleFilter::speckleRange, + DOC(dai, StereoDepthConfig, PostProcessing, SpeckleFilter, speckleRange)) + .def_readwrite("differenceThreshold", + &StereoDepthConfig::PostProcessing::SpeckleFilter::differenceThreshold, + DOC(dai, StereoDepthConfig, PostProcessing, SpeckleFilter, differenceThreshold)); decimationMode - .value("PIXEL_SKIPPING", StereoDepthConfig::PostProcessing::DecimationFilter::DecimationMode::PIXEL_SKIPPING, DOC(dai, StereoDepthConfig, PostProcessing, DecimationFilter, DecimationMode, PIXEL_SKIPPING)) - .value("NON_ZERO_MEDIAN", StereoDepthConfig::PostProcessing::DecimationFilter::DecimationMode::NON_ZERO_MEDIAN, DOC(dai, StereoDepthConfig, PostProcessing, DecimationFilter, DecimationMode, NON_ZERO_MEDIAN)) - .value("NON_ZERO_MEAN", StereoDepthConfig::PostProcessing::DecimationFilter::DecimationMode::NON_ZERO_MEAN, DOC(dai, StereoDepthConfig, PostProcessing, DecimationFilter, DecimationMode, NON_ZERO_MEAN)) - ; - - decimationFilter - .def(py::init<>()) - .def_readwrite("decimationFactor", &StereoDepthConfig::PostProcessing::DecimationFilter::decimationFactor, DOC(dai, StereoDepthConfig, PostProcessing, DecimationFilter, decimationFactor)) - .def_readwrite("decimationMode", &StereoDepthConfig::PostProcessing::DecimationFilter::decimationMode, DOC(dai, StereoDepthConfig, PostProcessing, DecimationFilter, decimationMode)) - ; - - _HoleFilling - .def(py::init<>()) + .value("PIXEL_SKIPPING", + StereoDepthConfig::PostProcessing::DecimationFilter::DecimationMode::PIXEL_SKIPPING, + DOC(dai, StereoDepthConfig, PostProcessing, DecimationFilter, DecimationMode, PIXEL_SKIPPING)) + .value("NON_ZERO_MEDIAN", + StereoDepthConfig::PostProcessing::DecimationFilter::DecimationMode::NON_ZERO_MEDIAN, + DOC(dai, StereoDepthConfig, PostProcessing, DecimationFilter, DecimationMode, NON_ZERO_MEDIAN)) + .value("NON_ZERO_MEAN", + StereoDepthConfig::PostProcessing::DecimationFilter::DecimationMode::NON_ZERO_MEAN, + DOC(dai, StereoDepthConfig, PostProcessing, DecimationFilter, DecimationMode, NON_ZERO_MEAN)); + + decimationFilter.def(py::init<>()) + .def_readwrite("decimationFactor", + &StereoDepthConfig::PostProcessing::DecimationFilter::decimationFactor, + DOC(dai, StereoDepthConfig, PostProcessing, DecimationFilter, decimationFactor)) + .def_readwrite("decimationMode", + &StereoDepthConfig::PostProcessing::DecimationFilter::decimationMode, + DOC(dai, StereoDepthConfig, PostProcessing, DecimationFilter, decimationMode)); + + _HoleFilling.def(py::init<>()) .def_readwrite("enable", &StereoDepthConfig::PostProcessing::HoleFilling::enable, DOC(dai, StereoDepthConfig, PostProcessing, HoleFilling, enable)) - .def_readwrite("highConfidenceThreshold", &StereoDepthConfig::PostProcessing::HoleFilling::highConfidenceThreshold, DOC(dai, StereoDepthConfig, PostProcessing, HoleFilling, highConfidenceThreshold)) - .def_readwrite("fillConfidenceThreshold", &StereoDepthConfig::PostProcessing::HoleFilling::fillConfidenceThreshold, DOC(dai, StereoDepthConfig, PostProcessing, HoleFilling, fillConfidenceThreshold)) - .def_readwrite("minValidDisparity", &StereoDepthConfig::PostProcessing::HoleFilling::minValidDisparity, DOC(dai, StereoDepthConfig, PostProcessing, HoleFilling, minValidDisparity)) - .def_readwrite("invalidateDisparities", &StereoDepthConfig::PostProcessing::HoleFilling::invalidateDisparities, DOC(dai, StereoDepthConfig, PostProcessing, HoleFilling, invalidateDisparities)) - ; - - _AdaptiveMedianFilter - .def(py::init<>()) - .def_readwrite("enable", &StereoDepthConfig::PostProcessing::AdaptiveMedianFilter::enable, DOC(dai, StereoDepthConfig, PostProcessing, AdaptiveMedianFilter, enable)) - .def_readwrite("confidenceThreshold", &StereoDepthConfig::PostProcessing::AdaptiveMedianFilter::confidenceThreshold, DOC(dai, StereoDepthConfig, PostProcessing, AdaptiveMedianFilter, confidenceThreshold)) - ; - - postProcessing - .def(py::init<>()) + .def_readwrite("highConfidenceThreshold", + &StereoDepthConfig::PostProcessing::HoleFilling::highConfidenceThreshold, + DOC(dai, StereoDepthConfig, PostProcessing, HoleFilling, highConfidenceThreshold)) + .def_readwrite("fillConfidenceThreshold", + &StereoDepthConfig::PostProcessing::HoleFilling::fillConfidenceThreshold, + DOC(dai, StereoDepthConfig, PostProcessing, HoleFilling, fillConfidenceThreshold)) + .def_readwrite("minValidDisparity", + &StereoDepthConfig::PostProcessing::HoleFilling::minValidDisparity, + DOC(dai, StereoDepthConfig, PostProcessing, HoleFilling, minValidDisparity)) + .def_readwrite("invalidateDisparities", + &StereoDepthConfig::PostProcessing::HoleFilling::invalidateDisparities, + DOC(dai, StereoDepthConfig, PostProcessing, HoleFilling, invalidateDisparities)); + + _AdaptiveMedianFilter.def(py::init<>()) + .def_readwrite("enable", + &StereoDepthConfig::PostProcessing::AdaptiveMedianFilter::enable, + DOC(dai, StereoDepthConfig, PostProcessing, AdaptiveMedianFilter, enable)) + .def_readwrite("confidenceThreshold", + &StereoDepthConfig::PostProcessing::AdaptiveMedianFilter::confidenceThreshold, + DOC(dai, StereoDepthConfig, PostProcessing, AdaptiveMedianFilter, confidenceThreshold)); + + postProcessing.def(py::init<>()) .def_readwrite("filteringOrder", &StereoDepthConfig::PostProcessing::filteringOrder, DOC(dai, StereoDepthConfig, PostProcessing, filteringOrder)) .def_readwrite("median", &StereoDepthConfig::PostProcessing::median, DOC(dai, StereoDepthConfig, PostProcessing, median)) - .def_readwrite("bilateralSigmaValue", &StereoDepthConfig::PostProcessing::bilateralSigmaValue, DOC(dai, StereoDepthConfig, PostProcessing, bilateralSigmaValue)) + .def_readwrite( + "bilateralSigmaValue", &StereoDepthConfig::PostProcessing::bilateralSigmaValue, DOC(dai, StereoDepthConfig, PostProcessing, bilateralSigmaValue)) .def_readwrite("spatialFilter", &StereoDepthConfig::PostProcessing::spatialFilter, DOC(dai, StereoDepthConfig, PostProcessing, spatialFilter)) .def_readwrite("temporalFilter", &StereoDepthConfig::PostProcessing::temporalFilter, DOC(dai, StereoDepthConfig, PostProcessing, temporalFilter)) .def_readwrite("thresholdFilter", &StereoDepthConfig::PostProcessing::thresholdFilter, DOC(dai, StereoDepthConfig, PostProcessing, thresholdFilter)) .def_readwrite("brightnessFilter", &StereoDepthConfig::PostProcessing::brightnessFilter, DOC(dai, StereoDepthConfig, PostProcessing, brightnessFilter)) .def_readwrite("speckleFilter", &StereoDepthConfig::PostProcessing::speckleFilter, DOC(dai, StereoDepthConfig, PostProcessing, speckleFilter)) .def_readwrite("decimationFilter", &StereoDepthConfig::PostProcessing::decimationFilter, DOC(dai, StereoDepthConfig, PostProcessing, decimationFilter)) - .def_readwrite("adaptiveMedianFilter", &StereoDepthConfig::PostProcessing::adaptiveMedianFilter, DOC(dai, StereoDepthConfig, PostProcessing, adaptiveMedianFilter)) - .def_readwrite("holeFilling", &StereoDepthConfig::PostProcessing::holeFilling, DOC(dai, StereoDepthConfig, PostProcessing, holeFilling)) - ; + .def_readwrite( + "adaptiveMedianFilter", &StereoDepthConfig::PostProcessing::adaptiveMedianFilter, DOC(dai, StereoDepthConfig, PostProcessing, adaptiveMedianFilter)) + .def_readwrite("holeFilling", &StereoDepthConfig::PostProcessing::holeFilling, DOC(dai, StereoDepthConfig, PostProcessing, holeFilling)); // KernelSize censusTransformKernelSize .value("AUTO", StereoDepthConfig::CensusTransform::KernelSize::AUTO, DOC(dai, StereoDepthConfig, CensusTransform, KernelSize, AUTO)) .value("KERNEL_5x5", StereoDepthConfig::CensusTransform::KernelSize::KERNEL_5x5, DOC(dai, StereoDepthConfig, CensusTransform, KernelSize, KERNEL_5x5)) .value("KERNEL_7x7", StereoDepthConfig::CensusTransform::KernelSize::KERNEL_7x7, DOC(dai, StereoDepthConfig, CensusTransform, KernelSize, KERNEL_7x7)) - .value("KERNEL_7x9", StereoDepthConfig::CensusTransform::KernelSize::KERNEL_7x9, DOC(dai, StereoDepthConfig, CensusTransform, KernelSize, KERNEL_7x9)) - ; + .value("KERNEL_7x9", StereoDepthConfig::CensusTransform::KernelSize::KERNEL_7x9, DOC(dai, StereoDepthConfig, CensusTransform, KernelSize, KERNEL_7x9)); - censusTransform - .def(py::init<>()) + censusTransform.def(py::init<>()) .def_readwrite("kernelSize", &StereoDepthConfig::CensusTransform::kernelSize, DOC(dai, StereoDepthConfig, CensusTransform, kernelSize)) .def_readwrite("kernelMask", &StereoDepthConfig::CensusTransform::kernelMask, DOC(dai, StereoDepthConfig, CensusTransform, kernelMask)) .def_readwrite("enableMeanMode", &StereoDepthConfig::CensusTransform::enableMeanMode, DOC(dai, StereoDepthConfig, CensusTransform, enableMeanMode)) .def_readwrite("threshold", &StereoDepthConfig::CensusTransform::threshold, DOC(dai, StereoDepthConfig, CensusTransform, threshold)) - .def_readwrite("noiseThresholdOffset", &StereoDepthConfig::CensusTransform::noiseThresholdOffset, DOC(dai, StereoDepthConfig, CensusTransform, noiseThresholdOffset)) - .def_readwrite("noiseThresholdScale", &StereoDepthConfig::CensusTransform::noiseThresholdScale, DOC(dai, StereoDepthConfig, CensusTransform, noiseThresholdScale)) - ; - - costMatchingLinearEquationParameters - .def(py::init<>()) - .def_readwrite("alpha", &StereoDepthConfig::CostMatching::LinearEquationParameters::alpha, DOC(dai, StereoDepthConfig, CostMatching, LinearEquationParameters, alpha)) - .def_readwrite("beta", &StereoDepthConfig::CostMatching::LinearEquationParameters::beta, DOC(dai, StereoDepthConfig, CostMatching, LinearEquationParameters, beta)) - .def_readwrite("threshold", &StereoDepthConfig::CostMatching::LinearEquationParameters::threshold, DOC(dai, StereoDepthConfig, CostMatching, LinearEquationParameters, threshold)) - ; + .def_readwrite("noiseThresholdOffset", + &StereoDepthConfig::CensusTransform::noiseThresholdOffset, + DOC(dai, StereoDepthConfig, CensusTransform, noiseThresholdOffset)) + .def_readwrite( + "noiseThresholdScale", &StereoDepthConfig::CensusTransform::noiseThresholdScale, DOC(dai, StereoDepthConfig, CensusTransform, noiseThresholdScale)); + + costMatchingLinearEquationParameters.def(py::init<>()) + .def_readwrite("alpha", + &StereoDepthConfig::CostMatching::LinearEquationParameters::alpha, + DOC(dai, StereoDepthConfig, CostMatching, LinearEquationParameters, alpha)) + .def_readwrite( + "beta", &StereoDepthConfig::CostMatching::LinearEquationParameters::beta, DOC(dai, StereoDepthConfig, CostMatching, LinearEquationParameters, beta)) + .def_readwrite("threshold", + &StereoDepthConfig::CostMatching::LinearEquationParameters::threshold, + DOC(dai, StereoDepthConfig, CostMatching, LinearEquationParameters, threshold)); // Disparity width costMatchingDisparityWidth - .value("DISPARITY_64", StereoDepthConfig::CostMatching::DisparityWidth::DISPARITY_64, DOC(dai, StereoDepthConfig, CostMatching, DisparityWidth, DISPARITY_64)) - .value("DISPARITY_96", StereoDepthConfig::CostMatching::DisparityWidth::DISPARITY_96, DOC(dai, StereoDepthConfig, CostMatching, DisparityWidth, DISPARITY_96)) - ; - - costMatching - .def(py::init<>()) + .value("DISPARITY_64", + StereoDepthConfig::CostMatching::DisparityWidth::DISPARITY_64, + DOC(dai, StereoDepthConfig, CostMatching, DisparityWidth, DISPARITY_64)) + .value("DISPARITY_96", + StereoDepthConfig::CostMatching::DisparityWidth::DISPARITY_96, + DOC(dai, StereoDepthConfig, CostMatching, DisparityWidth, DISPARITY_96)); + + costMatching.def(py::init<>()) .def_readwrite("disparityWidth", &StereoDepthConfig::CostMatching::disparityWidth, DOC(dai, StereoDepthConfig, CostMatching, disparityWidth)) .def_readwrite("enableCompanding", &StereoDepthConfig::CostMatching::enableCompanding, DOC(dai, StereoDepthConfig, CostMatching, enableCompanding)) - .def_readwrite("invalidDisparityValue", &StereoDepthConfig::CostMatching::invalidDisparityValue, DOC(dai, StereoDepthConfig, CostMatching, invalidDisparityValue)) - .def_readwrite("confidenceThreshold", &StereoDepthConfig::CostMatching::confidenceThreshold, DOC(dai, StereoDepthConfig, CostMatching, confidenceThreshold)) - .def_readwrite("linearEquationParameters", &StereoDepthConfig::CostMatching::linearEquationParameters, DOC(dai, StereoDepthConfig, CostMatching, linearEquationParameters)) - ; - - _P1Config - .def(py::init<>()) - .def_readwrite("enableAdaptive", &StereoDepthConfig::CostAggregation::P1Config::enableAdaptive, DOC(dai, StereoDepthConfig, CostAggregation, P1Config, enableAdaptive)) - .def_readwrite("defaultValue", &StereoDepthConfig::CostAggregation::P1Config::defaultValue, DOC(dai, StereoDepthConfig, CostAggregation, P1Config, defaultValue)) + .def_readwrite( + "invalidDisparityValue", &StereoDepthConfig::CostMatching::invalidDisparityValue, DOC(dai, StereoDepthConfig, CostMatching, invalidDisparityValue)) + .def_readwrite( + "confidenceThreshold", &StereoDepthConfig::CostMatching::confidenceThreshold, DOC(dai, StereoDepthConfig, CostMatching, confidenceThreshold)) + .def_readwrite("linearEquationParameters", + &StereoDepthConfig::CostMatching::linearEquationParameters, + DOC(dai, StereoDepthConfig, CostMatching, linearEquationParameters)); + + _P1Config.def(py::init<>()) + .def_readwrite("enableAdaptive", + &StereoDepthConfig::CostAggregation::P1Config::enableAdaptive, + DOC(dai, StereoDepthConfig, CostAggregation, P1Config, enableAdaptive)) + .def_readwrite( + "defaultValue", &StereoDepthConfig::CostAggregation::P1Config::defaultValue, DOC(dai, StereoDepthConfig, CostAggregation, P1Config, defaultValue)) .def_readwrite("edgeValue", &StereoDepthConfig::CostAggregation::P1Config::edgeValue, DOC(dai, StereoDepthConfig, CostAggregation, P1Config, edgeValue)) - .def_readwrite("smoothValue", &StereoDepthConfig::CostAggregation::P1Config::smoothValue, DOC(dai, StereoDepthConfig, CostAggregation, P1Config, smoothValue)) - .def_readwrite("edgeThreshold", &StereoDepthConfig::CostAggregation::P1Config::edgeThreshold, DOC(dai, StereoDepthConfig, CostAggregation, P1Config, edgeThreshold)) - .def_readwrite("smoothThreshold", &StereoDepthConfig::CostAggregation::P1Config::smoothThreshold, DOC(dai, StereoDepthConfig, CostAggregation, P1Config, smoothThreshold)) - ; - - _P2Config - .def(py::init<>()) - .def_readwrite("enableAdaptive", &StereoDepthConfig::CostAggregation::P2Config::enableAdaptive, DOC(dai, StereoDepthConfig, CostAggregation, P2Config, enableAdaptive)) - .def_readwrite("defaultValue", &StereoDepthConfig::CostAggregation::P2Config::defaultValue, DOC(dai, StereoDepthConfig, CostAggregation, P2Config, defaultValue)) + .def_readwrite( + "smoothValue", &StereoDepthConfig::CostAggregation::P1Config::smoothValue, DOC(dai, StereoDepthConfig, CostAggregation, P1Config, smoothValue)) + .def_readwrite("edgeThreshold", + &StereoDepthConfig::CostAggregation::P1Config::edgeThreshold, + DOC(dai, StereoDepthConfig, CostAggregation, P1Config, edgeThreshold)) + .def_readwrite("smoothThreshold", + &StereoDepthConfig::CostAggregation::P1Config::smoothThreshold, + DOC(dai, StereoDepthConfig, CostAggregation, P1Config, smoothThreshold)); + + _P2Config.def(py::init<>()) + .def_readwrite("enableAdaptive", + &StereoDepthConfig::CostAggregation::P2Config::enableAdaptive, + DOC(dai, StereoDepthConfig, CostAggregation, P2Config, enableAdaptive)) + .def_readwrite( + "defaultValue", &StereoDepthConfig::CostAggregation::P2Config::defaultValue, DOC(dai, StereoDepthConfig, CostAggregation, P2Config, defaultValue)) .def_readwrite("edgeValue", &StereoDepthConfig::CostAggregation::P2Config::edgeValue, DOC(dai, StereoDepthConfig, CostAggregation, P2Config, edgeValue)) - .def_readwrite("smoothValue", &StereoDepthConfig::CostAggregation::P2Config::smoothValue, DOC(dai, StereoDepthConfig, CostAggregation, P2Config, smoothValue)) - ; + .def_readwrite( + "smoothValue", &StereoDepthConfig::CostAggregation::P2Config::smoothValue, DOC(dai, StereoDepthConfig, CostAggregation, P2Config, smoothValue)); - costAggregation - .def(py::init<>()) + costAggregation.def(py::init<>()) .def_readwrite("divisionFactor", &StereoDepthConfig::CostAggregation::divisionFactor, DOC(dai, StereoDepthConfig, CostAggregation, divisionFactor)) - .def_readwrite("horizontalPenaltyCostP1", &StereoDepthConfig::CostAggregation::horizontalPenaltyCostP1, DOC(dai, StereoDepthConfig, CostAggregation, horizontalPenaltyCostP1)) - .def_readwrite("horizontalPenaltyCostP2", &StereoDepthConfig::CostAggregation::horizontalPenaltyCostP2, DOC(dai, StereoDepthConfig, CostAggregation, horizontalPenaltyCostP2)) - .def_readwrite("verticalPenaltyCostP1", &StereoDepthConfig::CostAggregation::verticalPenaltyCostP1, DOC(dai, StereoDepthConfig, CostAggregation, verticalPenaltyCostP1)) - .def_readwrite("verticalPenaltyCostP2", &StereoDepthConfig::CostAggregation::verticalPenaltyCostP2, DOC(dai, StereoDepthConfig, CostAggregation, verticalPenaltyCostP2)) + .def_readwrite("horizontalPenaltyCostP1", + &StereoDepthConfig::CostAggregation::horizontalPenaltyCostP1, + DOC(dai, StereoDepthConfig, CostAggregation, horizontalPenaltyCostP1)) + .def_readwrite("horizontalPenaltyCostP2", + &StereoDepthConfig::CostAggregation::horizontalPenaltyCostP2, + DOC(dai, StereoDepthConfig, CostAggregation, horizontalPenaltyCostP2)) + .def_readwrite("verticalPenaltyCostP1", + &StereoDepthConfig::CostAggregation::verticalPenaltyCostP1, + DOC(dai, StereoDepthConfig, CostAggregation, verticalPenaltyCostP1)) + .def_readwrite("verticalPenaltyCostP2", + &StereoDepthConfig::CostAggregation::verticalPenaltyCostP2, + DOC(dai, StereoDepthConfig, CostAggregation, verticalPenaltyCostP2)) .def_readwrite("p1Config", &StereoDepthConfig::CostAggregation::p1Config, DOC(dai, StereoDepthConfig, CostAggregation, p1Config)) - .def_readwrite("p2Config", &StereoDepthConfig::CostAggregation::p2Config, DOC(dai, StereoDepthConfig, CostAggregation, p2Config)) - ; - - stereoDepthConfig - .def(py::init<>()) - .def_readwrite("algorithmControl", &StereoDepthConfig::algorithmControl, DOC(dai, StereoDepthConfig, algorithmControl)) - .def_readwrite("postProcessing", &StereoDepthConfig::postProcessing, DOC(dai, StereoDepthConfig, postProcessing)) - .def_readwrite("censusTransform", &StereoDepthConfig::censusTransform, DOC(dai, StereoDepthConfig, censusTransform)) - .def_readwrite("costMatching", &StereoDepthConfig::costMatching, DOC(dai, StereoDepthConfig, costMatching)) - .def_readwrite("costAggregation", &StereoDepthConfig::costAggregation, DOC(dai, StereoDepthConfig, costAggregation)) - .def_readwrite("confidenceMetrics", &StereoDepthConfig::confidenceMetrics, DOC(dai, StereoDepthConfig, confidenceMetrics)) - ; + .def_readwrite("p2Config", &StereoDepthConfig::CostAggregation::p2Config, DOC(dai, StereoDepthConfig, CostAggregation, p2Config)); + + stereoDepthConfig.def(py::init<>()) + .def_readwrite("algorithmControl", &StereoDepthConfig::algorithmControl, DOC(dai, StereoDepthConfig, algorithmControl)) + .def_readwrite("postProcessing", &StereoDepthConfig::postProcessing, DOC(dai, StereoDepthConfig, postProcessing)) + .def_readwrite("censusTransform", &StereoDepthConfig::censusTransform, DOC(dai, StereoDepthConfig, censusTransform)) + .def_readwrite("costMatching", &StereoDepthConfig::costMatching, DOC(dai, StereoDepthConfig, costMatching)) + .def_readwrite("costAggregation", &StereoDepthConfig::costAggregation, DOC(dai, StereoDepthConfig, costAggregation)) + .def_readwrite("confidenceMetrics", &StereoDepthConfig::confidenceMetrics, DOC(dai, StereoDepthConfig, confidenceMetrics)); // legacy m.attr("StereoDepthConfig").attr("MedianFilter") = medianFilter; - // Message - stereoDepthConfig - .def(py::init<>()) + stereoDepthConfig.def(py::init<>()) .def("__repr__", &StereoDepthConfig::str) .def("setDepthAlign", &StereoDepthConfig::setDepthAlign, py::arg("align"), DOC(dai, StereoDepthConfig, setDepthAlign)) - .def("setConfidenceThreshold", &StereoDepthConfig::setConfidenceThreshold, py::arg("confThr"), DOC(dai, StereoDepthConfig, setConfidenceThreshold)) - .def("setMedianFilter", &StereoDepthConfig::setMedianFilter, py::arg("median"), DOC(dai, StereoDepthConfig, setMedianFilter)) + .def("setConfidenceThreshold", &StereoDepthConfig::setConfidenceThreshold, py::arg("confThr"), DOC(dai, StereoDepthConfig, setConfidenceThreshold)) + .def("setMedianFilter", &StereoDepthConfig::setMedianFilter, py::arg("median"), DOC(dai, StereoDepthConfig, setMedianFilter)) .def("setBilateralFilterSigma", &StereoDepthConfig::setBilateralFilterSigma, py::arg("sigma"), DOC(dai, StereoDepthConfig, setBilateralFilterSigma)) - .def("setLeftRightCheckThreshold", &StereoDepthConfig::setLeftRightCheckThreshold, py::arg("sigma"), DOC(dai, StereoDepthConfig, setLeftRightCheckThreshold)) - .def("getConfidenceThreshold", &StereoDepthConfig::getConfidenceThreshold, DOC(dai, StereoDepthConfig, getConfidenceThreshold)) - .def("getMedianFilter", &StereoDepthConfig::getMedianFilter, DOC(dai, StereoDepthConfig, getMedianFilter)) + .def("setLeftRightCheckThreshold", + &StereoDepthConfig::setLeftRightCheckThreshold, + py::arg("sigma"), + DOC(dai, StereoDepthConfig, setLeftRightCheckThreshold)) + .def("getConfidenceThreshold", &StereoDepthConfig::getConfidenceThreshold, DOC(dai, StereoDepthConfig, getConfidenceThreshold)) + .def("getMedianFilter", &StereoDepthConfig::getMedianFilter, DOC(dai, StereoDepthConfig, getMedianFilter)) .def("getBilateralFilterSigma", &StereoDepthConfig::getBilateralFilterSigma, DOC(dai, StereoDepthConfig, getBilateralFilterSigma)) - .def("getLeftRightCheckThreshold", &StereoDepthConfig::getLeftRightCheckThreshold, DOC(dai, StereoDepthConfig, getLeftRightCheckThreshold)) - .def("setLeftRightCheck", &StereoDepthConfig::setLeftRightCheck, py::arg("enable"), DOC(dai, StereoDepthConfig, setLeftRightCheck)) - .def("getLeftRightCheck", &StereoDepthConfig::getLeftRightCheck, DOC(dai, StereoDepthConfig, getLeftRightCheck)) - .def("setExtendedDisparity", &StereoDepthConfig::setExtendedDisparity, py::arg("enable"), DOC(dai, StereoDepthConfig, setExtendedDisparity)) - .def("getExtendedDisparity", &StereoDepthConfig::getExtendedDisparity, DOC(dai, StereoDepthConfig, getExtendedDisparity)) - .def("setSubpixel", &StereoDepthConfig::setSubpixel, py::arg("enable"), DOC(dai, StereoDepthConfig, setSubpixel)) - .def("getSubpixel", &StereoDepthConfig::getSubpixel, DOC(dai, StereoDepthConfig, getSubpixel)) - .def("setSubpixelFractionalBits", &StereoDepthConfig::setSubpixelFractionalBits, py::arg("subpixelFractionalBits"), DOC(dai, StereoDepthConfig, setSubpixelFractionalBits)) + .def("getLeftRightCheckThreshold", &StereoDepthConfig::getLeftRightCheckThreshold, DOC(dai, StereoDepthConfig, getLeftRightCheckThreshold)) + .def("setLeftRightCheck", &StereoDepthConfig::setLeftRightCheck, py::arg("enable"), DOC(dai, StereoDepthConfig, setLeftRightCheck)) + .def("getLeftRightCheck", &StereoDepthConfig::getLeftRightCheck, DOC(dai, StereoDepthConfig, getLeftRightCheck)) + .def("setExtendedDisparity", &StereoDepthConfig::setExtendedDisparity, py::arg("enable"), DOC(dai, StereoDepthConfig, setExtendedDisparity)) + .def("getExtendedDisparity", &StereoDepthConfig::getExtendedDisparity, DOC(dai, StereoDepthConfig, getExtendedDisparity)) + .def("setSubpixel", &StereoDepthConfig::setSubpixel, py::arg("enable"), DOC(dai, StereoDepthConfig, setSubpixel)) + .def("getSubpixel", &StereoDepthConfig::getSubpixel, DOC(dai, StereoDepthConfig, getSubpixel)) + .def("setSubpixelFractionalBits", + &StereoDepthConfig::setSubpixelFractionalBits, + py::arg("subpixelFractionalBits"), + DOC(dai, StereoDepthConfig, setSubpixelFractionalBits)) .def("getSubpixelFractionalBits", &StereoDepthConfig::getSubpixelFractionalBits, DOC(dai, StereoDepthConfig, getSubpixelFractionalBits)) - .def("getMaxDisparity", &StereoDepthConfig::getMaxDisparity, DOC(dai, StereoDepthConfig, getMaxDisparity)) - .def("setDepthUnit", &StereoDepthConfig::setDepthUnit, DOC(dai, StereoDepthConfig, setDepthUnit)) - .def("getDepthUnit", &StereoDepthConfig::getDepthUnit, DOC(dai, StereoDepthConfig, getDepthUnit)) - .def("setDisparityShift", &StereoDepthConfig::setDisparityShift, DOC(dai, StereoDepthConfig, setDisparityShift)) - .def("setNumInvalidateEdgePixels", &StereoDepthConfig::setNumInvalidateEdgePixels, DOC(dai, StereoDepthConfig, setNumInvalidateEdgePixels)) + .def("getMaxDisparity", &StereoDepthConfig::getMaxDisparity, DOC(dai, StereoDepthConfig, getMaxDisparity)) + .def("setDepthUnit", &StereoDepthConfig::setDepthUnit, DOC(dai, StereoDepthConfig, setDepthUnit)) + .def("getDepthUnit", &StereoDepthConfig::getDepthUnit, DOC(dai, StereoDepthConfig, getDepthUnit)) + .def("setDisparityShift", &StereoDepthConfig::setDisparityShift, DOC(dai, StereoDepthConfig, setDisparityShift)) + .def("setNumInvalidateEdgePixels", &StereoDepthConfig::setNumInvalidateEdgePixels, DOC(dai, StereoDepthConfig, setNumInvalidateEdgePixels)) // .def("set", &StereoDepthConfig::set, py::arg("config"), DOC(dai, StereoDepthConfig, set)) // .def("get", &StereoDepthConfig::get, DOC(dai, StereoDepthConfig, get)) ; @@ -314,6 +412,4 @@ void bind_stereodepthconfig(pybind11::module& m, void* pCallstack){ m.attr("StereoDepthConfig").attr("CensusTransform") = censusTransform; m.attr("StereoDepthConfig").attr("CostMatching") = costMatching; m.attr("StereoDepthConfig").attr("CostAggregation") = costAggregation; - - } diff --git a/bindings/python/src/pipeline/datatype/SystemInformationBindings.cpp b/bindings/python/src/pipeline/datatype/SystemInformationBindings.cpp index 97130e42b..6b0570a7a 100644 --- a/bindings/python/src/pipeline/datatype/SystemInformationBindings.cpp +++ b/bindings/python/src/pipeline/datatype/SystemInformationBindings.cpp @@ -1,30 +1,32 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/SystemInformation.hpp" #include "depthai/pipeline/datatype/SystemInformationS3.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_systeminformation(pybind11::module& m, void* pCallstack){ - +void bind_systeminformation(pybind11::module& m, void* pCallstack) { using namespace dai; - // py::class_> rawSystemInformation(m, "RawSystemInformation", DOC(dai, RawSystemInformation)); - py::class_, Buffer, std::shared_ptr> systemInformation(m, "SystemInformation", DOC(dai, SystemInformation)); + // py::class_> rawSystemInformation(m, "RawSystemInformation", DOC(dai, + // RawSystemInformation)); + py::class_, Buffer, std::shared_ptr> systemInformation( + m, "SystemInformation", DOC(dai, SystemInformation)); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -46,26 +48,37 @@ void bind_systeminformation(pybind11::module& m, void* pCallstack){ // ; // Message - systemInformation - .def(py::init<>()) + systemInformation.def(py::init<>()) .def("__repr__", &SystemInformation::str) - .def_property("ddrMemoryUsage", [](SystemInformation& i) { return &i.ddrMemoryUsage; }, [](SystemInformation& i, MemoryInfo val) { i.ddrMemoryUsage = val; } ) - .def_property("cmxMemoryUsage", [](SystemInformation& i) { return &i.cmxMemoryUsage; }, [](SystemInformation& i, MemoryInfo val) { i.cmxMemoryUsage = val; } ) - .def_property("leonCssMemoryUsage", [](SystemInformation& i) { return &i.leonCssMemoryUsage; }, [](SystemInformation& i, MemoryInfo val) { i.leonCssMemoryUsage = val; } ) - .def_property("leonMssMemoryUsage", [](SystemInformation& i) { return &i.leonMssMemoryUsage; }, [](SystemInformation& i, MemoryInfo val) { i.leonMssMemoryUsage = val; } ) - .def_property("leonCssCpuUsage", [](SystemInformation& i) { return &i.leonCssCpuUsage; }, [](SystemInformation& i, CpuUsage val) { i.leonCssCpuUsage = val; } ) - .def_property("leonMssCpuUsage", [](SystemInformation& i) { return &i.leonMssCpuUsage; }, [](SystemInformation& i, CpuUsage val) { i.leonMssCpuUsage = val; } ) - .def_property("chipTemperature", [](SystemInformation& i) { return &i.chipTemperature; }, [](SystemInformation& i, ChipTemperature val) { i.chipTemperature = val; } ) - ; - + .def_property( + "ddrMemoryUsage", [](SystemInformation& i) { return &i.ddrMemoryUsage; }, [](SystemInformation& i, MemoryInfo val) { i.ddrMemoryUsage = val; }) + .def_property( + "cmxMemoryUsage", [](SystemInformation& i) { return &i.cmxMemoryUsage; }, [](SystemInformation& i, MemoryInfo val) { i.cmxMemoryUsage = val; }) + .def_property( + "leonCssMemoryUsage", + [](SystemInformation& i) { return &i.leonCssMemoryUsage; }, + [](SystemInformation& i, MemoryInfo val) { i.leonCssMemoryUsage = val; }) + .def_property( + "leonMssMemoryUsage", + [](SystemInformation& i) { return &i.leonMssMemoryUsage; }, + [](SystemInformation& i, MemoryInfo val) { i.leonMssMemoryUsage = val; }) + .def_property( + "leonCssCpuUsage", [](SystemInformation& i) { return &i.leonCssCpuUsage; }, [](SystemInformation& i, CpuUsage val) { i.leonCssCpuUsage = val; }) + .def_property( + "leonMssCpuUsage", [](SystemInformation& i) { return &i.leonMssCpuUsage; }, [](SystemInformation& i, CpuUsage val) { i.leonMssCpuUsage = val; }) + .def_property( + "chipTemperature", + [](SystemInformation& i) { return &i.chipTemperature; }, + [](SystemInformation& i, ChipTemperature val) { i.chipTemperature = val; }); } void bind_systeminformationS3(pybind11::module& m, void* pCallstack) { using namespace dai; // py::class_> rawSystemInformationS3( - // m, "RawSystemInformationS3", DOC(dai, RawSystemInformationS3)); - py::class_, Buffer, std::shared_ptr> systemInformationS3(m, "SystemInformationS3", DOC(dai, SystemInformationS3)); + // m, "RawSystemInformationS3", DOC(dai, RawSystemInformationS3)); + py::class_, Buffer, std::shared_ptr> systemInformationS3( + m, "SystemInformationS3", DOC(dai, SystemInformationS3)); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// @@ -93,7 +106,8 @@ void bind_systeminformationS3(pybind11::module& m, void* pCallstack) { "ddrMemoryUsage", [](SystemInformationS3& i) { return &i.ddrMemoryUsage; }, [](SystemInformationS3& i, MemoryInfo val) { i.ddrMemoryUsage = val; }) .def_property( "cpuAvgUsage", [](SystemInformationS3& i) { return &i.cpuAvgUsage; }, [](SystemInformationS3& i, CpuUsage val) { i.cpuAvgUsage = val; }) - .def_property("cpuUsages", [](SystemInformationS3& i) { return &i.cpuUsages; }, [](SystemInformationS3& i, std::vector val) { i.cpuUsages = val; }) + .def_property( + "cpuUsages", [](SystemInformationS3& i) { return &i.cpuUsages; }, [](SystemInformationS3& i, std::vector val) { i.cpuUsages = val; }) .def_property( "chipTemperature", [](SystemInformationS3& i) { return &i.chipTemperature; }, diff --git a/bindings/python/src/pipeline/datatype/ThermalConfigBindings.cpp b/bindings/python/src/pipeline/datatype/ThermalConfigBindings.cpp index f82e54212..08552cd4d 100644 --- a/bindings/python/src/pipeline/datatype/ThermalConfigBindings.cpp +++ b/bindings/python/src/pipeline/datatype/ThermalConfigBindings.cpp @@ -31,11 +31,14 @@ void bind_thermalconfig(pybind11::module& m, void* pCallstack) { thermalAmbientParams.def(py::init<>()) .def_readwrite("distance", &ThermalConfig::ThermalAmbientParams::distance, DOC(dai, ThermalConfig, ThermalAmbientParams, distance)) + .def_readwrite("reflectionTemperature", + &ThermalConfig::ThermalAmbientParams::reflectionTemperature, + DOC(dai, ThermalConfig, ThermalAmbientParams, reflectionTemperature)) + .def_readwrite("atmosphericTemperature", + &ThermalConfig::ThermalAmbientParams::atmosphericTemperature, + DOC(dai, ThermalConfig, ThermalAmbientParams, atmosphericTemperature)) .def_readwrite( - "reflectionTemperature", &ThermalConfig::ThermalAmbientParams::reflectionTemperature, DOC(dai, ThermalConfig, ThermalAmbientParams, reflectionTemperature)) - .def_readwrite( - "atmosphericTemperature", &ThermalConfig::ThermalAmbientParams::atmosphericTemperature, DOC(dai, ThermalConfig, ThermalAmbientParams, atmosphericTemperature)) - .def_readwrite("targetEmissivity", &ThermalConfig::ThermalAmbientParams::targetEmissivity, DOC(dai, ThermalConfig, ThermalAmbientParams, targetEmissivity)) + "targetEmissivity", &ThermalConfig::ThermalAmbientParams::targetEmissivity, DOC(dai, ThermalConfig, ThermalAmbientParams, targetEmissivity)) .def_readwrite("atmosphericTransmittance", &ThermalConfig::ThermalAmbientParams::atmosphericTransmittance, DOC(dai, ThermalConfig, ThermalAmbientParams, atmosphericTransmittance)) @@ -60,11 +63,14 @@ void bind_thermalconfig(pybind11::module& m, void* pCallstack) { DOC(dai, ThermalConfig, ThermalFFCParams, antiFallProtectionThresholdLowGainMode)); thermalImageParams.def(py::init<>()) - .def_readwrite("timeNoiseFilterLevel", &ThermalConfig::ThermalImageParams::timeNoiseFilterLevel, DOC(dai, ThermalConfig, ThermalImageParams, timeNoiseFilterLevel)) - .def_readwrite( - "spatialNoiseFilterLevel", &ThermalConfig::ThermalImageParams::spatialNoiseFilterLevel, DOC(dai, ThermalConfig, ThermalImageParams, spatialNoiseFilterLevel)) .def_readwrite( - "digitalDetailEnhanceLevel", &ThermalConfig::ThermalImageParams::digitalDetailEnhanceLevel, DOC(dai, ThermalConfig, ThermalImageParams, digitalDetailEnhanceLevel)) + "timeNoiseFilterLevel", &ThermalConfig::ThermalImageParams::timeNoiseFilterLevel, DOC(dai, ThermalConfig, ThermalImageParams, timeNoiseFilterLevel)) + .def_readwrite("spatialNoiseFilterLevel", + &ThermalConfig::ThermalImageParams::spatialNoiseFilterLevel, + DOC(dai, ThermalConfig, ThermalImageParams, spatialNoiseFilterLevel)) + .def_readwrite("digitalDetailEnhanceLevel", + &ThermalConfig::ThermalImageParams::digitalDetailEnhanceLevel, + DOC(dai, ThermalConfig, ThermalImageParams, digitalDetailEnhanceLevel)) .def_readwrite("brightnessLevel", &ThermalConfig::ThermalImageParams::brightnessLevel, DOC(dai, ThermalConfig, ThermalImageParams, brightnessLevel)) .def_readwrite("contrastLevel", &ThermalConfig::ThermalImageParams::contrastLevel, DOC(dai, ThermalConfig, ThermalImageParams, contrastLevel)) .def_readwrite("orientation", &ThermalConfig::ThermalImageParams::orientation, DOC(dai, ThermalConfig, ThermalImageParams, orientation)); diff --git a/bindings/python/src/pipeline/datatype/ToFConfigBindings.cpp b/bindings/python/src/pipeline/datatype/ToFConfigBindings.cpp index d76d819f9..f0af106a6 100644 --- a/bindings/python/src/pipeline/datatype/ToFConfigBindings.cpp +++ b/bindings/python/src/pipeline/datatype/ToFConfigBindings.cpp @@ -1,19 +1,19 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/ToFConfig.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_tofconfig(pybind11::module& m, void* pCallstack){ - +void bind_tofconfig(pybind11::module& m, void* pCallstack) { using namespace dai; py::class_, Buffer, std::shared_ptr> toFConfig(m, "ToFConfig", DOC(dai, ToFConfig)); @@ -22,7 +22,7 @@ void bind_tofconfig(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -32,8 +32,7 @@ void bind_tofconfig(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Message - toFConfig - .def(py::init<>()) + toFConfig.def(py::init<>()) .def("__repr__", &ToFConfig::str) // .def(py::init>()) @@ -57,5 +56,4 @@ void bind_tofconfig(pybind11::module& m, void* pCallstack){ // add aliases // m.attr("ToFConfig").attr("DepthParams") = m.attr("ToFConfig").attr("DepthParams"); - } diff --git a/bindings/python/src/pipeline/datatype/TrackedFeaturesBindings.cpp b/bindings/python/src/pipeline/datatype/TrackedFeaturesBindings.cpp index a2172014b..480cb2dfb 100644 --- a/bindings/python/src/pipeline/datatype/TrackedFeaturesBindings.cpp +++ b/bindings/python/src/pipeline/datatype/TrackedFeaturesBindings.cpp @@ -1,19 +1,19 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/TrackedFeatures.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_trackedfeatures(pybind11::module& m, void* pCallstack){ - +void bind_trackedfeatures(pybind11::module& m, void* pCallstack) { using namespace dai; // py::class_> rawTrackedFeatures(m, "RawTrackedFeatures", DOC(dai, RawTrackedFeatures)); @@ -24,7 +24,7 @@ void bind_trackedfeatures(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -39,22 +39,22 @@ void bind_trackedfeatures(pybind11::module& m, void* pCallstack){ // .def_readwrite("trackedFeatures", &RawTrackedFeatures::trackedFeatures) // ; - trackedFeature - .def(py::init<>()) + trackedFeature.def(py::init<>()) .def_readwrite("position", &TrackedFeature::position, DOC(dai, TrackedFeature, position)) .def_readwrite("id", &TrackedFeature::id, DOC(dai, TrackedFeature, id)) .def_readwrite("age", &TrackedFeature::age, DOC(dai, TrackedFeature, age)) .def_readwrite("harrisScore", &TrackedFeature::harrisScore, DOC(dai, TrackedFeature, harrisScore)) .def_readwrite("trackingError", &TrackedFeature::trackingError, DOC(dai, TrackedFeature, trackingError)) - .def_readwrite("descriptor", &TrackedFeature::descriptor, DOC(dai, TrackedFeature, descriptor)) - ; - + .def_readwrite("descriptor", &TrackedFeature::descriptor, DOC(dai, TrackedFeature, descriptor)); // Message - trackedFeatures - .def(py::init<>()) + trackedFeatures.def(py::init<>()) .def("__repr__", &TrackedFeatures::str) - .def_property("trackedFeatures", [](TrackedFeatures& feat) { return &feat.trackedFeatures; }, [](TrackedFeatures& feat, std::vector val) { feat.trackedFeatures = val; }, DOC(dai, TrackedFeatures, trackedFeatures)) + .def_property( + "trackedFeatures", + [](TrackedFeatures& feat) { return &feat.trackedFeatures; }, + [](TrackedFeatures& feat, std::vector val) { feat.trackedFeatures = val; }, + DOC(dai, TrackedFeatures, trackedFeatures)) .def("getTimestamp", &TrackedFeatures::Buffer::getTimestamp, DOC(dai, Buffer, getTimestamp)) .def("getTimestampDevice", &TrackedFeatures::Buffer::getTimestampDevice, DOC(dai, Buffer, getTimestampDevice)) .def("getSequenceNum", &TrackedFeatures::Buffer::getSequenceNum, DOC(dai, Buffer, getSequenceNum)) @@ -62,6 +62,4 @@ void bind_trackedfeatures(pybind11::module& m, void* pCallstack){ // .def("setTimestampDevice", &TrackedFeatures::setTimestampDevice, DOC(dai, TrackedFeatures, setTimestampDevice)) // .def("setSequenceNum", &TrackedFeatures::setSequenceNum, DOC(dai, TrackedFeatures, setSequenceNum)) ; - } - diff --git a/bindings/python/src/pipeline/datatype/TrackletsBindings.cpp b/bindings/python/src/pipeline/datatype/TrackletsBindings.cpp index 774119821..0c5c4dd6d 100644 --- a/bindings/python/src/pipeline/datatype/TrackletsBindings.cpp +++ b/bindings/python/src/pipeline/datatype/TrackletsBindings.cpp @@ -1,19 +1,19 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/Tracklets.hpp" -//pybind +// pybind #include #include // #include "spdlog/spdlog.h" -void bind_tracklets(pybind11::module& m, void* pCallstack){ - +void bind_tracklets(pybind11::module& m, void* pCallstack) { using namespace dai; // py::class_> rawTacklets(m, "RawTracklets", DOC(dai, RawTracklets)); @@ -25,7 +25,7 @@ void bind_tracklets(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -35,23 +35,19 @@ void bind_tracklets(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Metadata / raw - tracklet - .def(py::init<>()) + tracklet.def(py::init<>()) .def_readwrite("roi", &Tracklet::roi) .def_readwrite("id", &Tracklet::id) .def_readwrite("label", &Tracklet::label) .def_readwrite("age", &Tracklet::age) .def_readwrite("status", &Tracklet::status) .def_readwrite("srcImgDetection", &Tracklet::srcImgDetection) - .def_readwrite("spatialCoordinates", &Tracklet::spatialCoordinates) - ; + .def_readwrite("spatialCoordinates", &Tracklet::spatialCoordinates); - trackletTrackingStatus - .value("NEW", Tracklet::TrackingStatus::NEW) + trackletTrackingStatus.value("NEW", Tracklet::TrackingStatus::NEW) .value("TRACKED", Tracklet::TrackingStatus::TRACKED) .value("LOST", Tracklet::TrackingStatus::LOST) - .value("REMOVED", Tracklet::TrackingStatus::REMOVED) - ; + .value("REMOVED", Tracklet::TrackingStatus::REMOVED); // rawTacklets // .def(py::init<>()) @@ -59,10 +55,13 @@ void bind_tracklets(pybind11::module& m, void* pCallstack){ // ; // Message - tracklets - .def(py::init<>()) + tracklets.def(py::init<>()) .def("__repr__", &Tracklets::str) - .def_property("tracklets", [](Tracklets& track) { return &track.tracklets; }, [](Tracklets& track, std::vector val) { track.tracklets = val; }, DOC(dai, Tracklets, tracklets)) + .def_property( + "tracklets", + [](Tracklets& track) { return &track.tracklets; }, + [](Tracklets& track, std::vector val) { track.tracklets = val; }, + DOC(dai, Tracklets, tracklets)) .def("getTimestamp", &Tracklets::Buffer::getTimestamp, DOC(dai, Buffer, getTimestamp)) .def("getTimestampDevice", &Tracklets::Buffer::getTimestampDevice, DOC(dai, Buffer, getTimestampDevice)) .def("getSequenceNum", &Tracklets::Buffer::getSequenceNum, DOC(dai, Buffer, getSequenceNum)) @@ -70,5 +69,4 @@ void bind_tracklets(pybind11::module& m, void* pCallstack){ // .def("setTimestampDevice", &Tracklets::setTimestampDevice, DOC(dai, Tracklets, setTimestampDevice)) // .def("setSequenceNum", &Tracklets::setSequenceNum, DOC(dai, Tracklets, setSequenceNum)) ; - } diff --git a/bindings/python/src/pipeline/datatype/TransformDataBindings.cpp b/bindings/python/src/pipeline/datatype/TransformDataBindings.cpp index 945d16e72..60ff9e067 100644 --- a/bindings/python/src/pipeline/datatype/TransformDataBindings.cpp +++ b/bindings/python/src/pipeline/datatype/TransformDataBindings.cpp @@ -1,17 +1,17 @@ +#include +#include + #include "DatatypeBindings.hpp" #include "pipeline/CommonBindings.hpp" -#include -#include // depthai #include "depthai/pipeline/datatype/TransformData.hpp" -//pybind +// pybind #include #include -void bind_transformdata(pybind11::module& m, void* pCallstack){ - +void bind_transformdata(pybind11::module& m, void* pCallstack) { using namespace dai; py::class_, Buffer, std::shared_ptr> transformData(m, "TransformData", DOC(dai, TransformData)); @@ -20,7 +20,7 @@ void bind_transformdata(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -30,8 +30,7 @@ void bind_transformdata(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Metadata / raw - transformData - .def(py::init<>()) + transformData.def(py::init<>()) .def("__repr__", &TransformData::str) .def("getTranslation", &TransformData::getTranslation, DOC(dai, TransformData, getTranslation)) .def("getRotationEuler", &TransformData::getRotationEuler, DOC(dai, TransformData, getRotationEuler)) diff --git a/bindings/python/src/pipeline/node/AprilTagBindings.cpp b/bindings/python/src/pipeline/node/AprilTagBindings.cpp index 4d83681a6..376442d38 100644 --- a/bindings/python/src/pipeline/node/AprilTagBindings.cpp +++ b/bindings/python/src/pipeline/node/AprilTagBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/AprilTag.hpp" -void bind_apriltag(pybind11::module& m, void* pCallstack){ - +void bind_apriltag(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -18,7 +16,7 @@ void bind_apriltag(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -28,11 +26,9 @@ void bind_apriltag(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - aprilTagProperties - .def_readwrite("initialConfig", &AprilTagProperties::initialConfig, DOC(dai, AprilTagProperties, initialConfig)) + aprilTagProperties.def_readwrite("initialConfig", &AprilTagProperties::initialConfig, DOC(dai, AprilTagProperties, initialConfig)) .def_readwrite("inputConfigSync", &AprilTagProperties::inputConfigSync, DOC(dai, AprilTagProperties, inputConfigSync)) - .def_readwrite("numThreads", &AprilTagProperties::numThreads, DOC(dai, AprilTagProperties, numThreads)) - ; + .def_readwrite("numThreads", &AprilTagProperties::numThreads, DOC(dai, AprilTagProperties, numThreads)); // Node aprilTag.def_readonly("inputConfig", &AprilTag::inputConfig, DOC(dai, node, AprilTag, inputConfig)) .def_readonly("inputImage", &AprilTag::inputImage, DOC(dai, node, AprilTag, inputImage)) @@ -44,8 +40,6 @@ void bind_apriltag(pybind11::module& m, void* pCallstack){ .def("runOnHost", &AprilTag::runOnHost, DOC(dai, node, AprilTag, runOnHost)) .def("setRunOnHost", &AprilTag::setRunOnHost, DOC(dai, node, AprilTag, setRunOnHost)) .def("setNumThreads", &AprilTag::setNumThreads, py::arg("numThreads"), DOC(dai, node, AprilTag, setNumThreads)) - .def("getNumThreads", &AprilTag::getNumThreads, DOC(dai, node, AprilTag, getNumThreads)) - ; - daiNodeModule.attr("AprilTag").attr("Properties") = aprilTagProperties; - + .def("getNumThreads", &AprilTag::getNumThreads, DOC(dai, node, AprilTag, getNumThreads)); + daiNodeModule.attr("AprilTag").attr("Properties") = aprilTagProperties; } diff --git a/bindings/python/src/pipeline/node/BasaltVIOBindings.cpp b/bindings/python/src/pipeline/node/BasaltVIOBindings.cpp index ae9e62fdf..76107d0b0 100644 --- a/bindings/python/src/pipeline/node/BasaltVIOBindings.cpp +++ b/bindings/python/src/pipeline/node/BasaltVIOBindings.cpp @@ -1,13 +1,13 @@ +#include + #include "Common.hpp" #include "NodeBindings.hpp" -#include "depthai/pipeline/ThreadedHostNode.hpp" #include "depthai/basalt/BasaltVIO.hpp" - -#include +#include "depthai/pipeline/ThreadedHostNode.hpp" extern py::handle daiNodeModule; -void bind_basaltnode(pybind11::module& m, void* pCallstack){ +void bind_basaltnode(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -18,7 +18,7 @@ void bind_basaltnode(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -28,8 +28,10 @@ void bind_basaltnode(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // BasaltVIO Node basaltNode - .def_property_readonly("left", [](BasaltVIO& node){ return &node.left; }, py::return_value_policy::reference_internal) - .def_property_readonly("right", [](BasaltVIO& node){ return &node.right; }, py::return_value_policy::reference_internal) + .def_property_readonly( + "left", [](BasaltVIO& node) { return &node.left; }, py::return_value_policy::reference_internal) + .def_property_readonly( + "right", [](BasaltVIO& node) { return &node.right; }, py::return_value_policy::reference_internal) .def_readonly("imu", &BasaltVIO::imu, DOC(dai, node, BasaltVIO, imu)) .def_readonly("transform", &BasaltVIO::transform, DOC(dai, node, BasaltVIO, transform)) .def_readonly("passthrough", &BasaltVIO::passthrough, DOC(dai, node, BasaltVIO, passthrough)) @@ -38,71 +40,70 @@ void bind_basaltnode(pybind11::module& m, void* pCallstack){ .def_readwrite("vioConfig", &BasaltVIO::vioConfig) .def("setLocalTransform", &BasaltVIO::setLocalTransform, py::arg("transform"), DOC(dai, node, BasaltVIO, setLocalTransform)); // VioConfig - vioConfig - .def(py::init<>()) - .def_readwrite("optical_flow_type", &basalt::VioConfig::optical_flow_type) - .def_readwrite("optical_flow_detection_grid_size", &basalt::VioConfig::optical_flow_detection_grid_size) - .def_readwrite("optical_flow_detection_num_points_cell", &basalt::VioConfig::optical_flow_detection_num_points_cell) - .def_readwrite("optical_flow_detection_min_threshold", &basalt::VioConfig::optical_flow_detection_min_threshold) - .def_readwrite("optical_flow_detection_max_threshold", &basalt::VioConfig::optical_flow_detection_max_threshold) - .def_readwrite("optical_flow_detection_nonoverlap", &basalt::VioConfig::optical_flow_detection_nonoverlap) - .def_readwrite("optical_flow_max_recovered_dist2", &basalt::VioConfig::optical_flow_max_recovered_dist2) - .def_readwrite("optical_flow_pattern", &basalt::VioConfig::optical_flow_pattern) - .def_readwrite("optical_flow_max_iterations", &basalt::VioConfig::optical_flow_max_iterations) - .def_readwrite("optical_flow_epipolar_error", &basalt::VioConfig::optical_flow_epipolar_error) - .def_readwrite("optical_flow_levels", &basalt::VioConfig::optical_flow_levels) - .def_readwrite("optical_flow_skip_frames", &basalt::VioConfig::optical_flow_skip_frames) - .def_readwrite("optical_flow_matching_guess_type", &basalt::VioConfig::optical_flow_matching_guess_type) - .def_readwrite("optical_flow_matching_default_depth", &basalt::VioConfig::optical_flow_matching_default_depth) - .def_readwrite("optical_flow_image_safe_radius", &basalt::VioConfig::optical_flow_image_safe_radius) - .def_readwrite("optical_flow_recall_enable", &basalt::VioConfig::optical_flow_recall_enable) - .def_readwrite("optical_flow_recall_all_cams", &basalt::VioConfig::optical_flow_recall_all_cams) - .def_readwrite("optical_flow_recall_num_points_cell", &basalt::VioConfig::optical_flow_recall_num_points_cell) - .def_readwrite("optical_flow_recall_over_tracking", &basalt::VioConfig::optical_flow_recall_over_tracking) - .def_readwrite("optical_flow_recall_update_patch_viewpoint", &basalt::VioConfig::optical_flow_recall_update_patch_viewpoint) - .def_readwrite("optical_flow_recall_max_patch_dist", &basalt::VioConfig::optical_flow_recall_max_patch_dist) - .def_readwrite("optical_flow_recall_max_patch_norms", &basalt::VioConfig::optical_flow_recall_max_patch_norms) - .def_readwrite("vio_linearization_type", &basalt::VioConfig::vio_linearization_type) - .def_readwrite("vio_sqrt_marg", &basalt::VioConfig::vio_sqrt_marg) - .def_readwrite("vio_max_states", &basalt::VioConfig::vio_max_states) - .def_readwrite("vio_max_kfs", &basalt::VioConfig::vio_max_kfs) - .def_readwrite("vio_min_frames_after_kf", &basalt::VioConfig::vio_min_frames_after_kf) - .def_readwrite("vio_new_kf_keypoints_thresh", &basalt::VioConfig::vio_new_kf_keypoints_thresh) - .def_readwrite("vio_debug", &basalt::VioConfig::vio_debug) - .def_readwrite("vio_extended_logging", &basalt::VioConfig::vio_extended_logging) - .def_readwrite("vio_obs_std_dev", &basalt::VioConfig::vio_obs_std_dev) - .def_readwrite("vio_obs_huber_thresh", &basalt::VioConfig::vio_obs_huber_thresh) - .def_readwrite("vio_min_triangulation_dist", &basalt::VioConfig::vio_min_triangulation_dist) - .def_readwrite("vio_max_iterations", &basalt::VioConfig::vio_max_iterations) - .def_readwrite("vio_enforce_realtime", &basalt::VioConfig::vio_enforce_realtime) - .def_readwrite("vio_use_lm", &basalt::VioConfig::vio_use_lm) - .def_readwrite("vio_lm_lambda_initial", &basalt::VioConfig::vio_lm_lambda_initial) - .def_readwrite("vio_lm_lambda_min", &basalt::VioConfig::vio_lm_lambda_min) - .def_readwrite("vio_lm_lambda_max", &basalt::VioConfig::vio_lm_lambda_max) - .def_readwrite("vio_scale_jacobian", &basalt::VioConfig::vio_scale_jacobian) - .def_readwrite("vio_init_pose_weight", &basalt::VioConfig::vio_init_pose_weight) - .def_readwrite("vio_init_ba_weight", &basalt::VioConfig::vio_init_ba_weight) - .def_readwrite("vio_init_bg_weight", &basalt::VioConfig::vio_init_bg_weight) - .def_readwrite("vio_marg_lost_landmarks", &basalt::VioConfig::vio_marg_lost_landmarks) - .def_readwrite("vio_fix_long_term_keyframes", &basalt::VioConfig::vio_fix_long_term_keyframes) - .def_readwrite("vio_kf_marg_feature_ratio", &basalt::VioConfig::vio_kf_marg_feature_ratio) - .def_readwrite("vio_kf_marg_criteria", &basalt::VioConfig::vio_kf_marg_criteria) - .def_readwrite("mapper_obs_std_dev", &basalt::VioConfig::mapper_obs_std_dev) - .def_readwrite("mapper_obs_huber_thresh", &basalt::VioConfig::mapper_obs_huber_thresh) - .def_readwrite("mapper_detection_num_points", &basalt::VioConfig::mapper_detection_num_points) - .def_readwrite("mapper_num_frames_to_match", &basalt::VioConfig::mapper_num_frames_to_match) - .def_readwrite("mapper_frames_to_match_threshold", &basalt::VioConfig::mapper_frames_to_match_threshold) - .def_readwrite("mapper_min_matches", &basalt::VioConfig::mapper_min_matches) - .def_readwrite("mapper_ransac_threshold", &basalt::VioConfig::mapper_ransac_threshold) - .def_readwrite("mapper_min_track_length", &basalt::VioConfig::mapper_min_track_length) - .def_readwrite("mapper_max_hamming_distance", &basalt::VioConfig::mapper_max_hamming_distance) - .def_readwrite("mapper_second_best_test_ratio", &basalt::VioConfig::mapper_second_best_test_ratio) - .def_readwrite("mapper_bow_num_bits", &basalt::VioConfig::mapper_bow_num_bits) - .def_readwrite("mapper_min_triangulation_dist", &basalt::VioConfig::mapper_min_triangulation_dist) - .def_readwrite("mapper_no_factor_weights", &basalt::VioConfig::mapper_no_factor_weights) - .def_readwrite("mapper_use_factors", &basalt::VioConfig::mapper_use_factors) - .def_readwrite("mapper_use_lm", &basalt::VioConfig::mapper_use_lm) - .def_readwrite("mapper_lm_lambda_min", &basalt::VioConfig::mapper_lm_lambda_min) - .def_readwrite("mapper_lm_lambda_max", &basalt::VioConfig::mapper_lm_lambda_max); + vioConfig.def(py::init<>()) + .def_readwrite("optical_flow_type", &basalt::VioConfig::optical_flow_type) + .def_readwrite("optical_flow_detection_grid_size", &basalt::VioConfig::optical_flow_detection_grid_size) + .def_readwrite("optical_flow_detection_num_points_cell", &basalt::VioConfig::optical_flow_detection_num_points_cell) + .def_readwrite("optical_flow_detection_min_threshold", &basalt::VioConfig::optical_flow_detection_min_threshold) + .def_readwrite("optical_flow_detection_max_threshold", &basalt::VioConfig::optical_flow_detection_max_threshold) + .def_readwrite("optical_flow_detection_nonoverlap", &basalt::VioConfig::optical_flow_detection_nonoverlap) + .def_readwrite("optical_flow_max_recovered_dist2", &basalt::VioConfig::optical_flow_max_recovered_dist2) + .def_readwrite("optical_flow_pattern", &basalt::VioConfig::optical_flow_pattern) + .def_readwrite("optical_flow_max_iterations", &basalt::VioConfig::optical_flow_max_iterations) + .def_readwrite("optical_flow_epipolar_error", &basalt::VioConfig::optical_flow_epipolar_error) + .def_readwrite("optical_flow_levels", &basalt::VioConfig::optical_flow_levels) + .def_readwrite("optical_flow_skip_frames", &basalt::VioConfig::optical_flow_skip_frames) + .def_readwrite("optical_flow_matching_guess_type", &basalt::VioConfig::optical_flow_matching_guess_type) + .def_readwrite("optical_flow_matching_default_depth", &basalt::VioConfig::optical_flow_matching_default_depth) + .def_readwrite("optical_flow_image_safe_radius", &basalt::VioConfig::optical_flow_image_safe_radius) + .def_readwrite("optical_flow_recall_enable", &basalt::VioConfig::optical_flow_recall_enable) + .def_readwrite("optical_flow_recall_all_cams", &basalt::VioConfig::optical_flow_recall_all_cams) + .def_readwrite("optical_flow_recall_num_points_cell", &basalt::VioConfig::optical_flow_recall_num_points_cell) + .def_readwrite("optical_flow_recall_over_tracking", &basalt::VioConfig::optical_flow_recall_over_tracking) + .def_readwrite("optical_flow_recall_update_patch_viewpoint", &basalt::VioConfig::optical_flow_recall_update_patch_viewpoint) + .def_readwrite("optical_flow_recall_max_patch_dist", &basalt::VioConfig::optical_flow_recall_max_patch_dist) + .def_readwrite("optical_flow_recall_max_patch_norms", &basalt::VioConfig::optical_flow_recall_max_patch_norms) + .def_readwrite("vio_linearization_type", &basalt::VioConfig::vio_linearization_type) + .def_readwrite("vio_sqrt_marg", &basalt::VioConfig::vio_sqrt_marg) + .def_readwrite("vio_max_states", &basalt::VioConfig::vio_max_states) + .def_readwrite("vio_max_kfs", &basalt::VioConfig::vio_max_kfs) + .def_readwrite("vio_min_frames_after_kf", &basalt::VioConfig::vio_min_frames_after_kf) + .def_readwrite("vio_new_kf_keypoints_thresh", &basalt::VioConfig::vio_new_kf_keypoints_thresh) + .def_readwrite("vio_debug", &basalt::VioConfig::vio_debug) + .def_readwrite("vio_extended_logging", &basalt::VioConfig::vio_extended_logging) + .def_readwrite("vio_obs_std_dev", &basalt::VioConfig::vio_obs_std_dev) + .def_readwrite("vio_obs_huber_thresh", &basalt::VioConfig::vio_obs_huber_thresh) + .def_readwrite("vio_min_triangulation_dist", &basalt::VioConfig::vio_min_triangulation_dist) + .def_readwrite("vio_max_iterations", &basalt::VioConfig::vio_max_iterations) + .def_readwrite("vio_enforce_realtime", &basalt::VioConfig::vio_enforce_realtime) + .def_readwrite("vio_use_lm", &basalt::VioConfig::vio_use_lm) + .def_readwrite("vio_lm_lambda_initial", &basalt::VioConfig::vio_lm_lambda_initial) + .def_readwrite("vio_lm_lambda_min", &basalt::VioConfig::vio_lm_lambda_min) + .def_readwrite("vio_lm_lambda_max", &basalt::VioConfig::vio_lm_lambda_max) + .def_readwrite("vio_scale_jacobian", &basalt::VioConfig::vio_scale_jacobian) + .def_readwrite("vio_init_pose_weight", &basalt::VioConfig::vio_init_pose_weight) + .def_readwrite("vio_init_ba_weight", &basalt::VioConfig::vio_init_ba_weight) + .def_readwrite("vio_init_bg_weight", &basalt::VioConfig::vio_init_bg_weight) + .def_readwrite("vio_marg_lost_landmarks", &basalt::VioConfig::vio_marg_lost_landmarks) + .def_readwrite("vio_fix_long_term_keyframes", &basalt::VioConfig::vio_fix_long_term_keyframes) + .def_readwrite("vio_kf_marg_feature_ratio", &basalt::VioConfig::vio_kf_marg_feature_ratio) + .def_readwrite("vio_kf_marg_criteria", &basalt::VioConfig::vio_kf_marg_criteria) + .def_readwrite("mapper_obs_std_dev", &basalt::VioConfig::mapper_obs_std_dev) + .def_readwrite("mapper_obs_huber_thresh", &basalt::VioConfig::mapper_obs_huber_thresh) + .def_readwrite("mapper_detection_num_points", &basalt::VioConfig::mapper_detection_num_points) + .def_readwrite("mapper_num_frames_to_match", &basalt::VioConfig::mapper_num_frames_to_match) + .def_readwrite("mapper_frames_to_match_threshold", &basalt::VioConfig::mapper_frames_to_match_threshold) + .def_readwrite("mapper_min_matches", &basalt::VioConfig::mapper_min_matches) + .def_readwrite("mapper_ransac_threshold", &basalt::VioConfig::mapper_ransac_threshold) + .def_readwrite("mapper_min_track_length", &basalt::VioConfig::mapper_min_track_length) + .def_readwrite("mapper_max_hamming_distance", &basalt::VioConfig::mapper_max_hamming_distance) + .def_readwrite("mapper_second_best_test_ratio", &basalt::VioConfig::mapper_second_best_test_ratio) + .def_readwrite("mapper_bow_num_bits", &basalt::VioConfig::mapper_bow_num_bits) + .def_readwrite("mapper_min_triangulation_dist", &basalt::VioConfig::mapper_min_triangulation_dist) + .def_readwrite("mapper_no_factor_weights", &basalt::VioConfig::mapper_no_factor_weights) + .def_readwrite("mapper_use_factors", &basalt::VioConfig::mapper_use_factors) + .def_readwrite("mapper_use_lm", &basalt::VioConfig::mapper_use_lm) + .def_readwrite("mapper_lm_lambda_min", &basalt::VioConfig::mapper_lm_lambda_min) + .def_readwrite("mapper_lm_lambda_max", &basalt::VioConfig::mapper_lm_lambda_max); /////////////////////////////////////////////////////////////////////// } \ No newline at end of file diff --git a/bindings/python/src/pipeline/node/BenchmarkBindings.cpp b/bindings/python/src/pipeline/node/BenchmarkBindings.cpp index 79e6d23cc..b0a21b6a3 100644 --- a/bindings/python/src/pipeline/node/BenchmarkBindings.cpp +++ b/bindings/python/src/pipeline/node/BenchmarkBindings.cpp @@ -37,6 +37,9 @@ void bind_benchmark(pybind11::module& m, void* pCallstack) { .def_readonly("passthrough", &BenchmarkIn::passthrough, DOC(dai, node, BenchmarkIn, passthrough)) .def("setRunOnHost", &BenchmarkIn::setRunOnHost, py::arg("runOnHost"), DOC(dai, node, BenchmarkIn, setRunOnHost)) .def("logReportsAsWarnings", &BenchmarkIn::logReportsAsWarnings, py::arg("logReportsAsWarnings"), DOC(dai, node, BenchmarkIn, logReportsAsWarnings)) - .def("measureIndividualLatencies", &BenchmarkIn::measureIndividualLatencies, py::arg("attachLatencies"), DOC(dai, node, BenchmarkIn, measureIndividualLatencies)) + .def("measureIndividualLatencies", + &BenchmarkIn::measureIndividualLatencies, + py::arg("attachLatencies"), + DOC(dai, node, BenchmarkIn, measureIndividualLatencies)) .def("sendReportEveryNMessages", &BenchmarkIn::sendReportEveryNMessages, py::arg("num"), DOC(dai, node, BenchmarkIn, sendReportEveryNMessages)); } diff --git a/bindings/python/src/pipeline/node/ColorCameraBindings.cpp b/bindings/python/src/pipeline/node/ColorCameraBindings.cpp index 471f169a5..df871ffe7 100644 --- a/bindings/python/src/pipeline/node/ColorCameraBindings.cpp +++ b/bindings/python/src/pipeline/node/ColorCameraBindings.cpp @@ -1,27 +1,28 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/ColorCamera.hpp" -void bind_colorcamera(pybind11::module& m, void* pCallstack){ - +void bind_colorcamera(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; // Node and Properties declare upfront py::class_ colorCameraProperties(m, "ColorCameraProperties", DOC(dai, ColorCameraProperties)); - py::enum_ colorCameraPropertiesSensorResolution(colorCameraProperties, "SensorResolution", DOC(dai, ColorCameraProperties, SensorResolution)); - py::enum_ colorCameraPropertiesColorOrder(colorCameraProperties, "ColorOrder", DOC(dai, ColorCameraProperties, ColorOrder)); - py::enum_ colorCameraPropertiesWarpMeshSource(colorCameraProperties, "WarpMeshSource", DOC(dai, ColorCameraProperties, WarpMeshSource)); + py::enum_ colorCameraPropertiesSensorResolution( + colorCameraProperties, "SensorResolution", DOC(dai, ColorCameraProperties, SensorResolution)); + py::enum_ colorCameraPropertiesColorOrder( + colorCameraProperties, "ColorOrder", DOC(dai, ColorCameraProperties, ColorOrder)); + py::enum_ colorCameraPropertiesWarpMeshSource( + colorCameraProperties, "WarpMeshSource", DOC(dai, ColorCameraProperties, WarpMeshSource)); auto colorCamera = ADD_NODE(ColorCamera); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -31,8 +32,7 @@ void bind_colorcamera(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // ColorCamera Properties - colorCameraPropertiesSensorResolution - .value("THE_1080_P", ColorCameraProperties::SensorResolution::THE_1080_P) + colorCameraPropertiesSensorResolution.value("THE_1080_P", ColorCameraProperties::SensorResolution::THE_1080_P) .value("THE_1200_P", ColorCameraProperties::SensorResolution::THE_1200_P) .value("THE_4_K", ColorCameraProperties::SensorResolution::THE_4_K) .value("THE_5_MP", ColorCameraProperties::SensorResolution::THE_5_MP) @@ -50,23 +50,16 @@ void bind_colorcamera(pybind11::module& m, void* pCallstack){ .value("THE_2104X1560", ColorCameraProperties::SensorResolution::THE_2104X1560) .value("THE_1440X1080", ColorCameraProperties::SensorResolution::THE_1440X1080) .value("THE_1352X1012", ColorCameraProperties::SensorResolution::THE_1352X1012) - .value("THE_2024X1520", ColorCameraProperties::SensorResolution::THE_2024X1520) - ; + .value("THE_2024X1520", ColorCameraProperties::SensorResolution::THE_2024X1520); - colorCameraPropertiesColorOrder - .value("BGR", ColorCameraProperties::ColorOrder::BGR) - .value("RGB", ColorCameraProperties::ColorOrder::RGB) - ; + colorCameraPropertiesColorOrder.value("BGR", ColorCameraProperties::ColorOrder::BGR).value("RGB", ColorCameraProperties::ColorOrder::RGB); - colorCameraPropertiesWarpMeshSource - .value("AUTO", ColorCameraProperties::WarpMeshSource::AUTO) + colorCameraPropertiesWarpMeshSource.value("AUTO", ColorCameraProperties::WarpMeshSource::AUTO) .value("NONE", ColorCameraProperties::WarpMeshSource::NONE) .value("CALIBRATION", ColorCameraProperties::WarpMeshSource::CALIBRATION) - .value("URI", ColorCameraProperties::WarpMeshSource::URI) - ; + .value("URI", ColorCameraProperties::WarpMeshSource::URI); - colorCameraProperties - .def_readwrite("initialControl", &ColorCameraProperties::initialControl) + colorCameraProperties.def_readwrite("initialControl", &ColorCameraProperties::initialControl) .def_readwrite("boardSocket", &ColorCameraProperties::boardSocket) .def_readwrite("imageOrientation", &ColorCameraProperties::imageOrientation) .def_readwrite("previewHeight", &ColorCameraProperties::previewHeight) @@ -94,8 +87,7 @@ void bind_colorcamera(pybind11::module& m, void* pCallstack){ .def_readwrite("calibAlpha", &ColorCameraProperties::calibAlpha) .def_readwrite("warpMeshStepWidth", &ColorCameraProperties::warpMeshStepWidth) .def_readwrite("warpMeshStepHeight", &ColorCameraProperties::warpMeshStepHeight) - .def_readwrite("eventFilter", &ColorCameraProperties::eventFilter) - ; + .def_readwrite("eventFilter", &ColorCameraProperties::eventFilter); // ColorCamera node colorCamera @@ -111,23 +103,25 @@ void bind_colorcamera(pybind11::module& m, void* pCallstack){ .def_readonly("still", &ColorCamera::still, DOC(dai, node, ColorCamera, still)) .def_readonly("isp", &ColorCamera::isp, DOC(dai, node, ColorCamera, isp)) .def_readonly("raw", &ColorCamera::raw, DOC(dai, node, ColorCamera, raw)) - .def_readonly("frameEvent", &ColorCamera::frameEvent, DOC(dai, node, ColorCamera, frameEvent)) - .def("setCamId", [](ColorCamera& c, int64_t id) { - // Issue an deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "setCamId() is deprecated, use setBoardSocket() instead.", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - c.setCamId(id); - HEDLEY_DIAGNOSTIC_POP - }) - .def("getCamId", [](ColorCamera& c) { - // Issue an deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "getCamId() is deprecated, use getBoardSocket() instead.", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - return c.getCamId(); - HEDLEY_DIAGNOSTIC_POP - }) + .def_readonly("frameEvent", &ColorCamera::frameEvent, DOC(dai, node, ColorCamera, frameEvent)) + .def("setCamId", + [](ColorCamera& c, int64_t id) { + // Issue an deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "setCamId() is deprecated, use setBoardSocket() instead.", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + c.setCamId(id); + HEDLEY_DIAGNOSTIC_POP + }) + .def("getCamId", + [](ColorCamera& c) { + // Issue an deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "getCamId() is deprecated, use getBoardSocket() instead.", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + return c.getCamId(); + HEDLEY_DIAGNOSTIC_POP + }) .def("setBoardSocket", &ColorCamera::setBoardSocket, py::arg("boardSocket"), DOC(dai, node, ColorCamera, setBoardSocket)) .def("getBoardSocket", &ColorCamera::getBoardSocket, DOC(dai, node, ColorCamera, getBoardSocket)) .def("setImageOrientation", &ColorCamera::setImageOrientation, py::arg("imageOrientation"), DOC(dai, node, ColorCamera, setImageOrientation)) @@ -138,12 +132,33 @@ void bind_colorcamera(pybind11::module& m, void* pCallstack){ .def("getInterleaved", &ColorCamera::getInterleaved, DOC(dai, node, ColorCamera, getInterleaved)) .def("setFp16", &ColorCamera::setFp16, py::arg("fp16"), DOC(dai, node, ColorCamera, setFp16)) .def("getFp16", &ColorCamera::getFp16, DOC(dai, node, ColorCamera, getFp16)) - .def("setPreviewSize", static_cast(&ColorCamera::setPreviewSize), py::arg("width"), py::arg("height"), DOC(dai, node, ColorCamera, setPreviewSize)) - .def("setPreviewSize", static_cast)>(&ColorCamera::setPreviewSize), py::arg("size"), DOC(dai, node, ColorCamera, setPreviewSize, 2)) - .def("setVideoSize", static_cast(&ColorCamera::setVideoSize), py::arg("width"), py::arg("height"), DOC(dai, node, ColorCamera, setVideoSize)) - .def("setVideoSize", static_cast)>(&ColorCamera::setVideoSize), py::arg("size"), DOC(dai, node, ColorCamera, setVideoSize, 2)) - .def("setStillSize", static_cast(&ColorCamera::setStillSize), py::arg("width"), py::arg("height"), DOC(dai, node, ColorCamera, setStillSize)) - .def("setStillSize", static_cast)>(&ColorCamera::setStillSize), py::arg("size"), DOC(dai, node, ColorCamera, setStillSize, 2)) + .def("setPreviewSize", + static_cast(&ColorCamera::setPreviewSize), + py::arg("width"), + py::arg("height"), + DOC(dai, node, ColorCamera, setPreviewSize)) + .def("setPreviewSize", + static_cast)>(&ColorCamera::setPreviewSize), + py::arg("size"), + DOC(dai, node, ColorCamera, setPreviewSize, 2)) + .def("setVideoSize", + static_cast(&ColorCamera::setVideoSize), + py::arg("width"), + py::arg("height"), + DOC(dai, node, ColorCamera, setVideoSize)) + .def("setVideoSize", + static_cast)>(&ColorCamera::setVideoSize), + py::arg("size"), + DOC(dai, node, ColorCamera, setVideoSize, 2)) + .def("setStillSize", + static_cast(&ColorCamera::setStillSize), + py::arg("width"), + py::arg("height"), + DOC(dai, node, ColorCamera, setStillSize)) + .def("setStillSize", + static_cast)>(&ColorCamera::setStillSize), + py::arg("size"), + DOC(dai, node, ColorCamera, setStillSize, 2)) .def("setResolution", &ColorCamera::setResolution, py::arg("resolution"), DOC(dai, node, ColorCamera, setResolution)) .def("getResolution", &ColorCamera::getResolution, DOC(dai, node, ColorCamera, getResolution)) .def("setFps", &ColorCamera::setFps, py::arg("fps"), DOC(dai, node, ColorCamera, setFps)) @@ -169,30 +184,54 @@ void bind_colorcamera(pybind11::module& m, void* pCallstack){ .def("getSensorCropX", &ColorCamera::getSensorCropX, DOC(dai, node, ColorCamera, getSensorCropX)) .def("getSensorCropY", &ColorCamera::getSensorCropY, DOC(dai, node, ColorCamera, getSensorCropY)) - .def("setWaitForConfigInput", [](ColorCamera& cam, bool wait){ - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - cam.setWaitForConfigInput(wait); - HEDLEY_DIAGNOSTIC_POP - }, py::arg("wait"), DOC(dai, node, ColorCamera, setWaitForConfigInput)) + .def( + "setWaitForConfigInput", + [](ColorCamera& cam, bool wait) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + cam.setWaitForConfigInput(wait); + HEDLEY_DIAGNOSTIC_POP + }, + py::arg("wait"), + DOC(dai, node, ColorCamera, setWaitForConfigInput)) - .def("getWaitForConfigInput", [](ColorCamera& cam){ - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - return cam.getWaitForConfigInput(); - HEDLEY_DIAGNOSTIC_POP - }, DOC(dai, node, ColorCamera, getWaitForConfigInput)) + .def( + "getWaitForConfigInput", + [](ColorCamera& cam) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + return cam.getWaitForConfigInput(); + HEDLEY_DIAGNOSTIC_POP + }, + DOC(dai, node, ColorCamera, getWaitForConfigInput)) .def("setPreviewKeepAspectRatio", &ColorCamera::setPreviewKeepAspectRatio, py::arg("keep"), DOC(dai, node, ColorCamera, setPreviewKeepAspectRatio)) .def("getPreviewKeepAspectRatio", &ColorCamera::getPreviewKeepAspectRatio, DOC(dai, node, ColorCamera, getPreviewKeepAspectRatio)) - .def("setIspScale", static_cast(&ColorCamera::setIspScale), py::arg("numerator"), py::arg("denominator"), DOC(dai, node, ColorCamera, setIspScale)) - .def("setIspScale", static_cast)>(&ColorCamera::setIspScale), py::arg("scale"), DOC(dai, node, ColorCamera, setIspScale, 2)) - .def("setIspScale", static_cast(&ColorCamera::setIspScale), py::arg("horizNum"), py::arg("horizDenom"), py::arg("vertNum"), py::arg("vertDenom"), DOC(dai, node, ColorCamera, setIspScale, 3)) - .def("setIspScale", static_cast,std::tuple)>(&ColorCamera::setIspScale), py::arg("horizScale"), py::arg("vertScale"), DOC(dai, node, ColorCamera, setIspScale, 4)) + .def("setIspScale", + static_cast(&ColorCamera::setIspScale), + py::arg("numerator"), + py::arg("denominator"), + DOC(dai, node, ColorCamera, setIspScale)) + .def("setIspScale", + static_cast)>(&ColorCamera::setIspScale), + py::arg("scale"), + DOC(dai, node, ColorCamera, setIspScale, 2)) + .def("setIspScale", + static_cast(&ColorCamera::setIspScale), + py::arg("horizNum"), + py::arg("horizDenom"), + py::arg("vertNum"), + py::arg("vertDenom"), + DOC(dai, node, ColorCamera, setIspScale, 3)) + .def("setIspScale", + static_cast, std::tuple)>(&ColorCamera::setIspScale), + py::arg("horizScale"), + py::arg("vertScale"), + DOC(dai, node, ColorCamera, setIspScale, 4)) .def("getIspSize", &ColorCamera::getIspSize, DOC(dai, node, ColorCamera, getIspSize)) .def("getIspWidth", &ColorCamera::getIspWidth, DOC(dai, node, ColorCamera, getIspWidth)) .def("getIspHeight", &ColorCamera::getIspHeight, DOC(dai, node, ColorCamera, getIspHeight)) @@ -202,7 +241,14 @@ void bind_colorcamera(pybind11::module& m, void* pCallstack){ .def("setStillNumFramesPool", &ColorCamera::setStillNumFramesPool, DOC(dai, node, ColorCamera, setStillNumFramesPool)) .def("setRawNumFramesPool", &ColorCamera::setRawNumFramesPool, DOC(dai, node, ColorCamera, setRawNumFramesPool)) .def("setIspNumFramesPool", &ColorCamera::setIspNumFramesPool, DOC(dai, node, ColorCamera, setIspNumFramesPool)) - .def("setNumFramesPool", &ColorCamera::setNumFramesPool, py::arg("raw"), py::arg("isp"), py::arg("preview"), py::arg("video"), py::arg("still"), DOC(dai, node, ColorCamera, setNumFramesPool)) + .def("setNumFramesPool", + &ColorCamera::setNumFramesPool, + py::arg("raw"), + py::arg("isp"), + py::arg("preview"), + py::arg("video"), + py::arg("still"), + DOC(dai, node, ColorCamera, setNumFramesPool)) .def("getPreviewNumFramesPool", &ColorCamera::getPreviewNumFramesPool, DOC(dai, node, ColorCamera, getPreviewNumFramesPool)) .def("getVideoNumFramesPool", &ColorCamera::getVideoNumFramesPool, DOC(dai, node, ColorCamera, getVideoNumFramesPool)) @@ -211,7 +257,7 @@ void bind_colorcamera(pybind11::module& m, void* pCallstack){ .def("getIspNumFramesPool", &ColorCamera::getIspNumFramesPool, DOC(dai, node, ColorCamera, getIspNumFramesPool)) .def("setCamera", &ColorCamera::setCamera, py::arg("name"), DOC(dai, node, ColorCamera, setCamera)) .def("getCamera", &ColorCamera::getCamera, DOC(dai, node, ColorCamera, getCamera)) - + .def("setMeshSource", &ColorCamera::setMeshSource, py::arg("source"), DOC(dai, node, ColorCamera, setMeshSource)) .def("getMeshSource", &ColorCamera::getMeshSource, DOC(dai, node, ColorCamera, getMeshSource)) // .def("loadMeshFile", &ColorCamera::loadMeshFile, py::arg("warpMesh"), DOC(dai, node, ColorCamera, loadMeshFile)) @@ -222,11 +268,8 @@ void bind_colorcamera(pybind11::module& m, void* pCallstack){ .def("getMeshSize", &ColorCamera::getMeshSize, DOC(dai, node, ColorCamera, getMeshSize)) .def("setCalibrationAlpha", &ColorCamera::setCalibrationAlpha, py::arg("alpha"), DOC(dai, node, ColorCamera, setCalibrationAlpha)) .def("getCalibrationAlpha", &ColorCamera::getCalibrationAlpha, DOC(dai, node, ColorCamera, getCalibrationAlpha)) - - .def("setRawOutputPacked", &ColorCamera::setRawOutputPacked, py::arg("packed"), DOC(dai, node, ColorCamera, setRawOutputPacked)) - ; + .def("setRawOutputPacked", &ColorCamera::setRawOutputPacked, py::arg("packed"), DOC(dai, node, ColorCamera, setRawOutputPacked)); // ALIAS daiNodeModule.attr("ColorCamera").attr("Properties") = colorCameraProperties; - } diff --git a/bindings/python/src/pipeline/node/Common.hpp b/bindings/python/src/pipeline/node/Common.hpp index d809e685b..1f748d379 100644 --- a/bindings/python/src/pipeline/node/Common.hpp +++ b/bindings/python/src/pipeline/node/Common.hpp @@ -7,27 +7,24 @@ #include "hedley/hedley.h" // pybind11 -#include "pybind11/stl_bind.h" - -#include "depthai/pipeline/Pipeline.hpp" -#include "depthai/pipeline/Node.hpp" #include "depthai/pipeline/DeviceNode.hpp" +#include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" +#include "pybind11/stl_bind.h" // Map of python node classes and call to pipeline to create it extern std::vector(dai::Pipeline&, py::object class_)>>> pyNodeCreateMap; extern py::handle daiNodeModule; -template -py::class_> addNode(const char* name, const char* docstring = nullptr){ +template +py::class_> addNode(const char* name, const char* docstring = nullptr) { auto node = py::class_>(daiNodeModule, name, docstring); - pyNodeCreateMap.push_back(std::make_pair(node, [](dai::Pipeline& p, py::object class_){ - return p.create(); - })); + pyNodeCreateMap.push_back(std::make_pair(node, [](dai::Pipeline& p, py::object class_) { return p.create(); })); return node; } -template -py::class_> addNodeAbstract(const char* name, const char* docstring = nullptr){ +template +py::class_> addNodeAbstract(const char* name, const char* docstring = nullptr) { auto node = py::class_>(daiNodeModule, name, docstring); pyNodeCreateMap.push_back(std::make_pair(node, [](dai::Pipeline& p, py::object class_) -> std::shared_ptr { throw std::invalid_argument(std::string(py::str(class_)) + " is an abstract node. Choose an appropriate derived node instead"); diff --git a/bindings/python/src/pipeline/node/DetectionNetworkBindings.cpp b/bindings/python/src/pipeline/node/DetectionNetworkBindings.cpp index a88467d49..5a2fd8553 100644 --- a/bindings/python/src/pipeline/node/DetectionNetworkBindings.cpp +++ b/bindings/python/src/pipeline/node/DetectionNetworkBindings.cpp @@ -1,4 +1,5 @@ #include + #include #include "Common.hpp" @@ -36,17 +37,11 @@ void bind_detectionnetwork(pybind11::module& m, void* pCallstack) { // DetectionNetwork Node detectionNetwork -#define DETECTION_NETWORK_BUILD_ARGS \ - Node::Output& input, \ - NNArchive& nnArchive -#define DETECTION_NETWORK_BUILD_PYARGS \ - py::arg("input"), \ - py::arg("nnArchive") -#define DETECTION_NETWORK_ARGS \ - float confidenceThreshold -#define DETECTION_NETWORK_PYARGS \ - py::arg("confidenceThreshold") = 0.5 - // TODO (Zimamazim) Automatically fetch default arguments to avoid duplicity +#define DETECTION_NETWORK_BUILD_ARGS Node::Output &input, NNArchive &nnArchive +#define DETECTION_NETWORK_BUILD_PYARGS py::arg("input"), py::arg("nnArchive") +#define DETECTION_NETWORK_ARGS float confidenceThreshold +#define DETECTION_NETWORK_PYARGS py::arg("confidenceThreshold") = 0.5 + // TODO (Zimamazim) Automatically fetch default arguments to avoid duplicity #define DETECTION_NETWORK_CODE(OP) self OP setConfidenceThreshold(confidenceThreshold); .def( "build", @@ -94,15 +89,23 @@ void bind_detectionnetwork(pybind11::module& m, void* pCallstack) { py::arg("numNCEPerThread"), DOC(dai, node, DetectionNetwork, setNumNCEPerInferenceThread)) .def("getNumInferenceThreads", &DetectionNetwork::getNumInferenceThreads, DOC(dai, node, DetectionNetwork, getNumInferenceThreads)) - .def("setNNArchive", py::overload_cast(&DetectionNetwork::setNNArchive), py::arg("archive"), DOC(dai, node, DetectionNetwork, setNNArchive)) - .def("setNNArchive", py::overload_cast(&DetectionNetwork::setNNArchive), py::arg("archive"), py::arg("numShaves"), DOC(dai, node, DetectionNetwork, setNNArchive)) - .def("setFromModelZoo", py::overload_cast(&DetectionNetwork::setFromModelZoo), py::arg("description"), py::arg("useCached") = false, DOC(dai, node, DetectionNetwork, setFromModelZoo)) + .def("setNNArchive", + py::overload_cast(&DetectionNetwork::setNNArchive), + py::arg("archive"), + DOC(dai, node, DetectionNetwork, setNNArchive)) + .def("setNNArchive", + py::overload_cast(&DetectionNetwork::setNNArchive), + py::arg("archive"), + py::arg("numShaves"), + DOC(dai, node, DetectionNetwork, setNNArchive)) + .def("setFromModelZoo", + py::overload_cast(&DetectionNetwork::setFromModelZoo), + py::arg("description"), + py::arg("useCached") = false, + DOC(dai, node, DetectionNetwork, setFromModelZoo)) .def("setBlob", py::overload_cast(&DetectionNetwork::setBlob), py::arg("blob"), DOC(dai, node, DetectionNetwork, setBlob)) .def("setBlob", py::overload_cast(&DetectionNetwork::setBlob), py::arg("path"), DOC(dai, node, DetectionNetwork, setBlob, 2)) - .def("setModelPath", - &DetectionNetwork::setModelPath, - py::arg("modelPath"), - DOC(dai, node, DetectionNetwork, setModelPath)) + .def("setModelPath", &DetectionNetwork::setModelPath, py::arg("modelPath"), DOC(dai, node, DetectionNetwork, setModelPath)) .def("setNumShavesPerInferenceThread", &DetectionNetwork::setNumShavesPerInferenceThread, py::arg("numShavesPerInferenceThread"), @@ -139,7 +142,7 @@ void bind_detectionnetwork(pybind11::module& m, void* pCallstack) { .def("getConfidenceThreshold", &DetectionNetwork::getConfidenceThreshold, DOC(dai, node, DetectionNetwork, getConfidenceThreshold)); // ALIAS // daiNodeModule.attr("DetectionNetwork").attr("Properties") = detectionNetworkProperties; - + // YoloDetectionNetwork node yoloDetectionNetwork.def("setNumClasses", &YoloDetectionNetwork::setNumClasses, py::arg("numClasses"), DOC(dai, node, YoloDetectionNetwork, setNumClasses)) .def("setCoordinateSize", &YoloDetectionNetwork::setCoordinateSize, py::arg("coordinates"), DOC(dai, node, YoloDetectionNetwork, setCoordinateSize)) diff --git a/bindings/python/src/pipeline/node/DetectionParserBindings.cpp b/bindings/python/src/pipeline/node/DetectionParserBindings.cpp index bafdcf751..9b1f9ba1d 100644 --- a/bindings/python/src/pipeline/node/DetectionParserBindings.cpp +++ b/bindings/python/src/pipeline/node/DetectionParserBindings.cpp @@ -1,13 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/DetectionParser.hpp" - -void bind_detectionparser(pybind11::module& m, void* pCallstack){ - +void bind_detectionparser(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -19,7 +16,7 @@ void bind_detectionparser(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -29,9 +26,7 @@ void bind_detectionparser(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - detectionParserProperties - .def_readwrite("parser", &DetectionParserProperties::parser, DOC(dai, DetectionParserProperties, parser)) - ; + detectionParserProperties.def_readwrite("parser", &DetectionParserProperties::parser, DOC(dai, DetectionParserProperties, parser)); // Node detectionParser.def_readonly("input", &DetectionParser::input, DOC(dai, node, DetectionParser, input)) .def_readonly("out", &DetectionParser::out, DOC(dai, node, DetectionParser, out)) @@ -76,5 +71,4 @@ void bind_detectionparser(pybind11::module& m, void* pCallstack){ .def("getIouThreshold", &DetectionParser::getIouThreshold, DOC(dai, node, DetectionParser, getIouThreshold)) .def("build", &DetectionParser::build, DOC(dai, node, DetectionParser, build)); daiNodeModule.attr("DetectionParser").attr("Properties") = detectionParserProperties; - } diff --git a/bindings/python/src/pipeline/node/EdgeDetectorBindings.cpp b/bindings/python/src/pipeline/node/EdgeDetectorBindings.cpp index 0c6f167b4..71e6fef30 100644 --- a/bindings/python/src/pipeline/node/EdgeDetectorBindings.cpp +++ b/bindings/python/src/pipeline/node/EdgeDetectorBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/EdgeDetector.hpp" -void bind_edgedetector(pybind11::module& m, void* pCallstack){ - +void bind_edgedetector(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -18,7 +16,7 @@ void bind_edgedetector(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -28,40 +26,42 @@ void bind_edgedetector(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - edgeDetectorProperties - .def_readwrite("initialConfig", &EdgeDetectorProperties::initialConfig, DOC(dai, EdgeDetectorProperties, initialConfig)) + edgeDetectorProperties.def_readwrite("initialConfig", &EdgeDetectorProperties::initialConfig, DOC(dai, EdgeDetectorProperties, initialConfig)) .def_readwrite("outputFrameSize", &EdgeDetectorProperties::outputFrameSize, DOC(dai, EdgeDetectorProperties, outputFrameSize)) - .def_readwrite("numFramesPool", &EdgeDetectorProperties::numFramesPool, DOC(dai, EdgeDetectorProperties, numFramesPool)) - ; + .def_readwrite("numFramesPool", &EdgeDetectorProperties::numFramesPool, DOC(dai, EdgeDetectorProperties, numFramesPool)); // Node - edgeDetector - .def_readonly("initialConfig", &EdgeDetector::initialConfig, DOC(dai, node, EdgeDetector, initialConfig)) + edgeDetector.def_readonly("initialConfig", &EdgeDetector::initialConfig, DOC(dai, node, EdgeDetector, initialConfig)) .def_readonly("inputConfig", &EdgeDetector::inputConfig, DOC(dai, node, EdgeDetector, inputConfig)) .def_readonly("inputImage", &EdgeDetector::inputImage, DOC(dai, node, EdgeDetector, inputImage)) .def_readonly("outputImage", &EdgeDetector::outputImage, DOC(dai, node, EdgeDetector, outputImage)) - .def("setWaitForConfigInput", [](EdgeDetector& obj, bool wait){ - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - obj.setWaitForConfigInput(wait); - HEDLEY_DIAGNOSTIC_POP - }, py::arg("wait"), DOC(dai, node, EdgeDetector, setWaitForConfigInput)) + .def( + "setWaitForConfigInput", + [](EdgeDetector& obj, bool wait) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + obj.setWaitForConfigInput(wait); + HEDLEY_DIAGNOSTIC_POP + }, + py::arg("wait"), + DOC(dai, node, EdgeDetector, setWaitForConfigInput)) - .def("getWaitForConfigInput", [](EdgeDetector& obj){ - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - return obj.getWaitForConfigInput(); - HEDLEY_DIAGNOSTIC_POP - }, DOC(dai, node, EdgeDetector, getWaitForConfigInput)) + .def( + "getWaitForConfigInput", + [](EdgeDetector& obj) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + return obj.getWaitForConfigInput(); + HEDLEY_DIAGNOSTIC_POP + }, + DOC(dai, node, EdgeDetector, getWaitForConfigInput)) .def("setNumFramesPool", &EdgeDetector::setNumFramesPool, DOC(dai, node, EdgeDetector, setNumFramesPool)) - .def("setMaxOutputFrameSize", &EdgeDetector::setMaxOutputFrameSize, DOC(dai, node, EdgeDetector, setMaxOutputFrameSize)) - ; + .def("setMaxOutputFrameSize", &EdgeDetector::setMaxOutputFrameSize, DOC(dai, node, EdgeDetector, setMaxOutputFrameSize)); daiNodeModule.attr("EdgeDetector").attr("Properties") = edgeDetectorProperties; - } diff --git a/bindings/python/src/pipeline/node/FeatureTrackerBindings.cpp b/bindings/python/src/pipeline/node/FeatureTrackerBindings.cpp index 5ef2c4130..b30e57984 100644 --- a/bindings/python/src/pipeline/node/FeatureTrackerBindings.cpp +++ b/bindings/python/src/pipeline/node/FeatureTrackerBindings.cpp @@ -1,13 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/FeatureTracker.hpp" - -void bind_featuretracker(pybind11::module& m, void* pCallstack){ - +void bind_featuretracker(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -19,7 +16,7 @@ void bind_featuretracker(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -29,40 +26,46 @@ void bind_featuretracker(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // FeatureTracker properties - featureTrackerProperties - .def_readwrite("initialConfig", &FeatureTrackerProperties::initialConfig, DOC(dai, FeatureTrackerProperties, initialConfig)) + featureTrackerProperties.def_readwrite("initialConfig", &FeatureTrackerProperties::initialConfig, DOC(dai, FeatureTrackerProperties, initialConfig)) .def_readwrite("numShaves", &FeatureTrackerProperties::numShaves, DOC(dai, FeatureTrackerProperties, numShaves)) - .def_readwrite("numMemorySlices", &FeatureTrackerProperties::numMemorySlices, DOC(dai, FeatureTrackerProperties, numMemorySlices)) - ; + .def_readwrite("numMemorySlices", &FeatureTrackerProperties::numMemorySlices, DOC(dai, FeatureTrackerProperties, numMemorySlices)); // FeatureTracker Node - featureTracker - .def_readonly("inputConfig", &FeatureTracker::inputConfig, DOC(dai, node, FeatureTracker, inputConfig)) + featureTracker.def_readonly("inputConfig", &FeatureTracker::inputConfig, DOC(dai, node, FeatureTracker, inputConfig)) .def_readonly("inputImage", &FeatureTracker::inputImage, DOC(dai, node, FeatureTracker, inputImage)) .def_readonly("outputFeatures", &FeatureTracker::outputFeatures, DOC(dai, node, FeatureTracker, outputFeatures)) .def_readonly("passthroughInputImage", &FeatureTracker::passthroughInputImage, DOC(dai, node, FeatureTracker, passthroughInputImage)) .def_readonly("initialConfig", &FeatureTracker::initialConfig, DOC(dai, node, FeatureTracker, initialConfig)) - .def("setWaitForConfigInput", [](FeatureTracker& obj, bool wait){ - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - obj.setWaitForConfigInput(wait); - HEDLEY_DIAGNOSTIC_POP - }, py::arg("wait"), DOC(dai, node, FeatureTracker, setWaitForConfigInput)) + .def( + "setWaitForConfigInput", + [](FeatureTracker& obj, bool wait) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + obj.setWaitForConfigInput(wait); + HEDLEY_DIAGNOSTIC_POP + }, + py::arg("wait"), + DOC(dai, node, FeatureTracker, setWaitForConfigInput)) - .def("getWaitForConfigInput", [](FeatureTracker& obj){ - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - return obj.getWaitForConfigInput(); - HEDLEY_DIAGNOSTIC_POP - }, DOC(dai, node, FeatureTracker, getWaitForConfigInput)) + .def( + "getWaitForConfigInput", + [](FeatureTracker& obj) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + return obj.getWaitForConfigInput(); + HEDLEY_DIAGNOSTIC_POP + }, + DOC(dai, node, FeatureTracker, getWaitForConfigInput)) - .def("setHardwareResources", &FeatureTracker::setHardwareResources, py::arg("numShaves"), py::arg("numMemorySlices"), DOC(dai, node, FeatureTracker, setHardwareResources)) - ; + .def("setHardwareResources", + &FeatureTracker::setHardwareResources, + py::arg("numShaves"), + py::arg("numMemorySlices"), + DOC(dai, node, FeatureTracker, setHardwareResources)); daiNodeModule.attr("FeatureTracker").attr("Properties") = featureTrackerProperties; - } diff --git a/bindings/python/src/pipeline/node/HostNodeBindings.cpp b/bindings/python/src/pipeline/node/HostNodeBindings.cpp index 3b749d214..e784b9f56 100644 --- a/bindings/python/src/pipeline/node/HostNodeBindings.cpp +++ b/bindings/python/src/pipeline/node/HostNodeBindings.cpp @@ -6,7 +6,7 @@ #include "depthai/pipeline/node/host/HostNode.hpp" extern py::handle daiNodeModule; -extern py::object messageQueueException; // Needed to be able to catch in C++ after it's raised on the Python side +extern py::object messageQueueException; // Needed to be able to catch in C++ after it's raised on the Python side using namespace dai; using namespace dai::node; @@ -45,17 +45,17 @@ class PyHostNode : public NodeCRTP { } }; -void bind_hostnode(pybind11::module& m, void* pCallstack){ +void bind_hostnode(pybind11::module& m, void* pCallstack) { // declare upfront - auto threadedHostNode = - py::class_>(daiNodeModule, "ThreadedHostNode", DOC(dai, node, ThreadedHostNode)); + auto threadedHostNode = py::class_>( + daiNodeModule, "ThreadedHostNode", DOC(dai, node, ThreadedHostNode)); auto hostNode = py::class_>(daiNodeModule, "HostNode", DOC(dai, node, HostNode)); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); diff --git a/bindings/python/src/pipeline/node/IMUBindings.cpp b/bindings/python/src/pipeline/node/IMUBindings.cpp index ff1665c4f..c4655bb8c 100644 --- a/bindings/python/src/pipeline/node/IMUBindings.cpp +++ b/bindings/python/src/pipeline/node/IMUBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/IMU.hpp" -void bind_imu(pybind11::module& m, void* pCallstack){ - +void bind_imu(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -20,7 +18,7 @@ void bind_imu(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -30,8 +28,7 @@ void bind_imu(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - imuSensor - .value("ACCELEROMETER_RAW", IMUSensor::ACCELEROMETER_RAW, DOC(dai, IMUSensor, ACCELEROMETER_RAW)) + imuSensor.value("ACCELEROMETER_RAW", IMUSensor::ACCELEROMETER_RAW, DOC(dai, IMUSensor, ACCELEROMETER_RAW)) .value("ACCELEROMETER", IMUSensor::ACCELEROMETER, DOC(dai, IMUSensor, ACCELEROMETER)) .value("LINEAR_ACCELERATION", IMUSensor::LINEAR_ACCELERATION, DOC(dai, IMUSensor, LINEAR_ACCELERATION)) .value("GRAVITY", IMUSensor::GRAVITY, DOC(dai, IMUSensor, GRAVITY)) @@ -45,39 +42,47 @@ void bind_imu(pybind11::module& m, void* pCallstack){ .value("GAME_ROTATION_VECTOR", IMUSensor::GAME_ROTATION_VECTOR, DOC(dai, IMUSensor, GAME_ROTATION_VECTOR)) .value("GEOMAGNETIC_ROTATION_VECTOR", IMUSensor::GEOMAGNETIC_ROTATION_VECTOR, DOC(dai, IMUSensor, GEOMAGNETIC_ROTATION_VECTOR)) .value("ARVR_STABILIZED_ROTATION_VECTOR", IMUSensor::ARVR_STABILIZED_ROTATION_VECTOR, DOC(dai, IMUSensor, ARVR_STABILIZED_ROTATION_VECTOR)) - .value("ARVR_STABILIZED_GAME_ROTATION_VECTOR", IMUSensor::ARVR_STABILIZED_GAME_ROTATION_VECTOR, DOC(dai, IMUSensor, ARVR_STABILIZED_GAME_ROTATION_VECTOR)) + .value( + "ARVR_STABILIZED_GAME_ROTATION_VECTOR", IMUSensor::ARVR_STABILIZED_GAME_ROTATION_VECTOR, DOC(dai, IMUSensor, ARVR_STABILIZED_GAME_ROTATION_VECTOR)) // .value("GYRO_INTEGRATED_ROTATION_VECTOR", IMUSensor::GYRO_INTEGRATED_ROTATION_VECTOR) - ; + ; - imuSensorConfig - .def(py::init<>()) + imuSensorConfig.def(py::init<>()) .def_readwrite("sensitivityEnabled", &IMUSensorConfig::sensitivityEnabled) .def_readwrite("sensitivityRelative", &IMUSensorConfig::sensitivityRelative) .def_readwrite("changeSensitivity", &IMUSensorConfig::changeSensitivity) .def_readwrite("reportRate", &IMUSensorConfig::reportRate) - .def_readwrite("sensorId", &IMUSensorConfig::sensorId) - ; + .def_readwrite("sensorId", &IMUSensorConfig::sensorId); - imuProperties - .def_readwrite("imuSensors", &IMUProperties::imuSensors, DOC(dai, IMUProperties, imuSensors)) + imuProperties.def_readwrite("imuSensors", &IMUProperties::imuSensors, DOC(dai, IMUProperties, imuSensors)) .def_readwrite("batchReportThreshold", &IMUProperties::batchReportThreshold, DOC(dai, IMUProperties, batchReportThreshold)) .def_readwrite("maxBatchReports", &IMUProperties::maxBatchReports, DOC(dai, IMUProperties, maxBatchReports)) - .def_readwrite("enableFirmwareUpdate", &IMUProperties::enableFirmwareUpdate, DOC(dai, IMUProperties, enableFirmwareUpdate)) - ; + .def_readwrite("enableFirmwareUpdate", &IMUProperties::enableFirmwareUpdate, DOC(dai, IMUProperties, enableFirmwareUpdate)); // Node - imu - .def_readonly("out", &IMU::out, DOC(dai, node, IMU, out)) - .def("enableIMUSensor", static_cast(&IMU::enableIMUSensor), py::arg("sensorConfig"), DOC(dai, node, IMU, enableIMUSensor)) - .def("enableIMUSensor", static_cast& imuSensors)>(&IMU::enableIMUSensor), py::arg("sensorConfigs"), DOC(dai, node, IMU, enableIMUSensor, 2)) - .def("enableIMUSensor", static_cast(&IMU::enableIMUSensor), py::arg("sensor"), py::arg("reportRate"), DOC(dai, node, IMU, enableIMUSensor, 3)) - .def("enableIMUSensor", static_cast& sensors, uint32_t reportRate)>(&IMU::enableIMUSensor), py::arg("sensors"), py::arg("reportRate"), DOC(dai, node, IMU, enableIMUSensor, 4)) + imu.def_readonly("out", &IMU::out, DOC(dai, node, IMU, out)) + .def("enableIMUSensor", + static_cast(&IMU::enableIMUSensor), + py::arg("sensorConfig"), + DOC(dai, node, IMU, enableIMUSensor)) + .def("enableIMUSensor", + static_cast& imuSensors)>(&IMU::enableIMUSensor), + py::arg("sensorConfigs"), + DOC(dai, node, IMU, enableIMUSensor, 2)) + .def("enableIMUSensor", + static_cast(&IMU::enableIMUSensor), + py::arg("sensor"), + py::arg("reportRate"), + DOC(dai, node, IMU, enableIMUSensor, 3)) + .def("enableIMUSensor", + static_cast& sensors, uint32_t reportRate)>(&IMU::enableIMUSensor), + py::arg("sensors"), + py::arg("reportRate"), + DOC(dai, node, IMU, enableIMUSensor, 4)) .def("setBatchReportThreshold", &IMU::setBatchReportThreshold, py::arg("batchReportThreshold"), DOC(dai, node, IMU, setBatchReportThreshold)) .def("getBatchReportThreshold", &IMU::getBatchReportThreshold, DOC(dai, node, IMU, getBatchReportThreshold)) .def("setMaxBatchReports", &IMU::setMaxBatchReports, py::arg("maxBatchReports"), DOC(dai, node, IMU, setMaxBatchReports)) .def("getMaxBatchReports", &IMU::getMaxBatchReports, DOC(dai, node, IMU, getMaxBatchReports)) - .def("enableFirmwareUpdate", &IMU::enableFirmwareUpdate, DOC(dai, node, IMU, enableFirmwareUpdate)) - ; + .def("enableFirmwareUpdate", &IMU::enableFirmwareUpdate, DOC(dai, node, IMU, enableFirmwareUpdate)); daiNodeModule.attr("IMU").attr("Properties") = imuProperties; - } diff --git a/bindings/python/src/pipeline/node/ImageAlignBindings.cpp b/bindings/python/src/pipeline/node/ImageAlignBindings.cpp index f0bc41fe0..6dd3100bd 100644 --- a/bindings/python/src/pipeline/node/ImageAlignBindings.cpp +++ b/bindings/python/src/pipeline/node/ImageAlignBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/ImageAlign.hpp" -void bind_imagealign(pybind11::module& m, void* pCallstack){ - +void bind_imagealign(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; using namespace pybind11::literals; @@ -19,7 +17,7 @@ void bind_imagealign(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -29,32 +27,28 @@ void bind_imagealign(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - imageAlignProperties - .def_readwrite("initialConfig", &ImageAlignProperties::initialConfig, DOC(dai, ImageAlignProperties, initialConfig)) + imageAlignProperties.def_readwrite("initialConfig", &ImageAlignProperties::initialConfig, DOC(dai, ImageAlignProperties, initialConfig)) .def_readwrite("numFramesPool", &ImageAlignProperties::numFramesPool, DOC(dai, ImageAlignProperties, numFramesPool)) .def_readwrite("numShaves", &ImageAlignProperties::numShaves, DOC(dai, ImageAlignProperties, numShaves)) .def_readwrite("warpHwIds", &ImageAlignProperties::warpHwIds, DOC(dai, ImageAlignProperties, warpHwIds)) .def_readwrite("alignHeight", &ImageAlignProperties::alignHeight, DOC(dai, ImageAlignProperties, alignHeight)) .def_readwrite("alignWidth", &ImageAlignProperties::alignWidth, DOC(dai, ImageAlignProperties, alignWidth)) .def_readwrite("interpolation", &ImageAlignProperties::interpolation, DOC(dai, ImageAlignProperties, interpolation)) - .def_readwrite("outKeepAspectRatio", &ImageAlignProperties::outKeepAspectRatio, DOC(dai, ImageAlignProperties, outKeepAspectRatio)) - ; + .def_readwrite("outKeepAspectRatio", &ImageAlignProperties::outKeepAspectRatio, DOC(dai, ImageAlignProperties, outKeepAspectRatio)); // Node - imageAlign - .def_readonly("initialConfig", &ImageAlign::initialConfig, DOC(dai, node, ImageAlign, initialConfig), DOC(dai, node, ImageAlign, initialConfig)) + imageAlign.def_readonly("initialConfig", &ImageAlign::initialConfig, DOC(dai, node, ImageAlign, initialConfig), DOC(dai, node, ImageAlign, initialConfig)) .def_readonly("inputConfig", &ImageAlign::inputConfig, DOC(dai, node, ImageAlign, inputConfig), DOC(dai, node, ImageAlign, inputConfig)) .def_readonly("input", &ImageAlign::input, DOC(dai, node, ImageAlign, input), DOC(dai, node, ImageAlign, input)) .def_readonly("inputAlignTo", &ImageAlign::inputAlignTo, DOC(dai, node, ImageAlign, inputAlignTo), DOC(dai, node, ImageAlign, inputAlignTo)) - .def_readonly("passthroughInput", &ImageAlign::passthroughInput, DOC(dai, node, ImageAlign, passthroughInput), DOC(dai, node, ImageAlign, passthroughInput)) + .def_readonly( + "passthroughInput", &ImageAlign::passthroughInput, DOC(dai, node, ImageAlign, passthroughInput), DOC(dai, node, ImageAlign, passthroughInput)) .def_readonly("outputAligned", &ImageAlign::outputAligned, DOC(dai, node, ImageAlign, outputAligned), DOC(dai, node, ImageAlign, outputAligned)) - .def("setOutputSize",&ImageAlign::setOutputSize, py::arg("alignWidth"),py::arg("alignHeight") ,DOC(dai, node, ImageAlign, setOutputSize)) - .def("setOutKeepAspectRatio", &ImageAlign::setOutKeepAspectRatio,py::arg("keep"), DOC(dai, node, ImageAlign, setOutKeepAspectRatio)) - .def("setInterpolation", &ImageAlign::setInterpolation,py::arg("interp"), DOC(dai, node, ImageAlign, setInterpolation)) - .def("setNumShaves", &ImageAlign::setNumShaves, py::arg("numShaves"),DOC(dai, node, ImageAlign, setNumShaves)) - .def("setNumFramesPool", &ImageAlign::setNumFramesPool,py::arg("numFramesPool") , DOC(dai, node, ImageAlign, setNumFramesPool)) - ; + .def("setOutputSize", &ImageAlign::setOutputSize, py::arg("alignWidth"), py::arg("alignHeight"), DOC(dai, node, ImageAlign, setOutputSize)) + .def("setOutKeepAspectRatio", &ImageAlign::setOutKeepAspectRatio, py::arg("keep"), DOC(dai, node, ImageAlign, setOutKeepAspectRatio)) + .def("setInterpolation", &ImageAlign::setInterpolation, py::arg("interp"), DOC(dai, node, ImageAlign, setInterpolation)) + .def("setNumShaves", &ImageAlign::setNumShaves, py::arg("numShaves"), DOC(dai, node, ImageAlign, setNumShaves)) + .def("setNumFramesPool", &ImageAlign::setNumFramesPool, py::arg("numFramesPool"), DOC(dai, node, ImageAlign, setNumFramesPool)); // ALIAS daiNodeModule.attr("ImageAlign").attr("Properties") = imageAlignProperties; - } diff --git a/bindings/python/src/pipeline/node/ImageManipBindings.cpp b/bindings/python/src/pipeline/node/ImageManipBindings.cpp index faa4651ff..07f54f51e 100644 --- a/bindings/python/src/pipeline/node/ImageManipBindings.cpp +++ b/bindings/python/src/pipeline/node/ImageManipBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/ImageManip.hpp" -void bind_imagemanip(pybind11::module& m, void* pCallstack){ - +void bind_imagemanip(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -17,7 +15,7 @@ void bind_imagemanip(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -27,91 +25,103 @@ void bind_imagemanip(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // ImageManip Node - imageManip - .def_readonly("inputConfig", &ImageManip::inputConfig, DOC(dai, node, ImageManip, inputConfig)) + imageManip.def_readonly("inputConfig", &ImageManip::inputConfig, DOC(dai, node, ImageManip, inputConfig)) .def_readonly("inputImage", &ImageManip::inputImage, DOC(dai, node, ImageManip, inputImage)) .def_readonly("out", &ImageManip::out, DOC(dai, node, ImageManip, out)) .def_readonly("initialConfig", &ImageManip::initialConfig, DOC(dai, node, ImageManip, initialConfig)) // setters - .def("setCropRect", [](ImageManip& im, float xmin, float ymin, float xmax, float ymax) { - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "setCropRect() is deprecated, use initialConfig.setCropRect() instead.", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - im.setCropRect(xmin, ymin, xmax, ymax); - HEDLEY_DIAGNOSTIC_POP - }) - .def("setCenterCrop", [](ImageManip& im, float ratio, float whRatio = 1.0f) { - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "setCenterCrop() is deprecated, use initialConfig.setCenterCrop() instead.", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - im.setCenterCrop(ratio, whRatio); - HEDLEY_DIAGNOSTIC_POP - }) - - .def("setResize", [](ImageManip& im, int w, int h) { - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "setResize() is deprecated, use initialConfig.setResize() instead.", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - im.setResize(w, h); - HEDLEY_DIAGNOSTIC_POP - }) - - .def("setResizeThumbnail", [](ImageManip& im, int w, int h, int bgRed = 0, int bgGreen = 0, int bgBlue = 0) { - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "setResizeThumbnail() is deprecated, use initialConfig.setResizeThumbnail() instead.", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - im.setResizeThumbnail(w, h, bgRed, bgGreen, bgBlue); - HEDLEY_DIAGNOSTIC_POP - }) - - .def("setFrameType", [](ImageManip& im, dai::ImgFrame::Type name) { - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "setFrameType() is deprecated, use initialConfig.setFrameType() instead.", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - im.setFrameType(name); - HEDLEY_DIAGNOSTIC_POP - }) - - .def("setHorizontalFlip", [](ImageManip& im, bool flip) { - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "setHorizontalFlip() is deprecated, use initialConfig.setHorizontalFlip() instead.", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - im.setHorizontalFlip(flip); - HEDLEY_DIAGNOSTIC_POP - }) + .def("setCropRect", + [](ImageManip& im, float xmin, float ymin, float xmax, float ymax) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "setCropRect() is deprecated, use initialConfig.setCropRect() instead.", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + im.setCropRect(xmin, ymin, xmax, ymax); + HEDLEY_DIAGNOSTIC_POP + }) + .def("setCenterCrop", + [](ImageManip& im, float ratio, float whRatio = 1.0f) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "setCenterCrop() is deprecated, use initialConfig.setCenterCrop() instead.", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + im.setCenterCrop(ratio, whRatio); + HEDLEY_DIAGNOSTIC_POP + }) + + .def("setResize", + [](ImageManip& im, int w, int h) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "setResize() is deprecated, use initialConfig.setResize() instead.", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + im.setResize(w, h); + HEDLEY_DIAGNOSTIC_POP + }) + + .def("setResizeThumbnail", + [](ImageManip& im, int w, int h, int bgRed = 0, int bgGreen = 0, int bgBlue = 0) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "setResizeThumbnail() is deprecated, use initialConfig.setResizeThumbnail() instead.", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + im.setResizeThumbnail(w, h, bgRed, bgGreen, bgBlue); + HEDLEY_DIAGNOSTIC_POP + }) + + .def("setFrameType", + [](ImageManip& im, dai::ImgFrame::Type name) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "setFrameType() is deprecated, use initialConfig.setFrameType() instead.", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + im.setFrameType(name); + HEDLEY_DIAGNOSTIC_POP + }) + + .def("setHorizontalFlip", + [](ImageManip& im, bool flip) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "setHorizontalFlip() is deprecated, use initialConfig.setHorizontalFlip() instead.", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + im.setHorizontalFlip(flip); + HEDLEY_DIAGNOSTIC_POP + }) .def("setKeepAspectRatio", &ImageManip::setKeepAspectRatio, DOC(dai, node, ImageManip, setKeepAspectRatio)) - .def("setWaitForConfigInput", [](ImageManip& obj, bool wait){ - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - obj.setWaitForConfigInput(wait); - HEDLEY_DIAGNOSTIC_POP - }, py::arg("wait"), DOC(dai, node, ImageManip, setWaitForConfigInput)) - - .def("getWaitForConfigInput", [](ImageManip& obj){ - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - return obj.getWaitForConfigInput(); - HEDLEY_DIAGNOSTIC_POP - }, DOC(dai, node, ImageManip, getWaitForConfigInput)) + .def( + "setWaitForConfigInput", + [](ImageManip& obj, bool wait) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + obj.setWaitForConfigInput(wait); + HEDLEY_DIAGNOSTIC_POP + }, + py::arg("wait"), + DOC(dai, node, ImageManip, setWaitForConfigInput)) + + .def( + "getWaitForConfigInput", + [](ImageManip& obj) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + return obj.getWaitForConfigInput(); + HEDLEY_DIAGNOSTIC_POP + }, + DOC(dai, node, ImageManip, getWaitForConfigInput)) .def("setNumFramesPool", &ImageManip::setNumFramesPool, DOC(dai, node, ImageManip, setNumFramesPool)) .def("setMaxOutputFrameSize", &ImageManip::setMaxOutputFrameSize, DOC(dai, node, ImageManip, setMaxOutputFrameSize)) .def("setWarpMesh", py::overload_cast&, int, int>(&ImageManip::setWarpMesh), DOC(dai, node, ImageManip, setWarpMesh)) - .def("setWarpMesh", py::overload_cast>&, int, int>(&ImageManip::setWarpMesh), DOC(dai, node, ImageManip, setWarpMesh)) - ; - + .def("setWarpMesh", + py::overload_cast>&, int, int>(&ImageManip::setWarpMesh), + DOC(dai, node, ImageManip, setWarpMesh)); } diff --git a/bindings/python/src/pipeline/node/ImageManipV2Bindings.cpp b/bindings/python/src/pipeline/node/ImageManipV2Bindings.cpp index 429008c22..e59825248 100644 --- a/bindings/python/src/pipeline/node/ImageManipV2Bindings.cpp +++ b/bindings/python/src/pipeline/node/ImageManipV2Bindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/ImageManipV2.hpp" -void bind_imagemanipv2(pybind11::module& m, void* pCallstack){ - +void bind_imagemanipv2(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -17,7 +15,7 @@ void bind_imagemanipv2(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -27,14 +25,11 @@ void bind_imagemanipv2(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // ImageManip Node - imageManip - .def_readonly("inputConfig", &ImageManipV2::inputConfig, DOC(dai, node, ImageManipV2, inputConfig)) + imageManip.def_readonly("inputConfig", &ImageManipV2::inputConfig, DOC(dai, node, ImageManipV2, inputConfig)) .def_readonly("inputImage", &ImageManipV2::inputImage, DOC(dai, node, ImageManipV2, inputImage)) .def_readonly("out", &ImageManipV2::out, DOC(dai, node, ImageManipV2, out)) .def_readonly("initialConfig", &ImageManipV2::initialConfig, DOC(dai, node, ImageManipV2, initialConfig)) .def("setRunOnHost", &ImageManipV2::setRunOnHost, DOC(dai, node, ImageManipV2, setRunOnHost)) .def("setNumFramesPool", &ImageManipV2::setNumFramesPool, DOC(dai, node, ImageManipV2, setNumFramesPool)) - .def("setMaxOutputFrameSize", &ImageManipV2::setMaxOutputFrameSize, DOC(dai, node, ImageManipV2, setMaxOutputFrameSize)) - ; - + .def("setMaxOutputFrameSize", &ImageManipV2::setMaxOutputFrameSize, DOC(dai, node, ImageManipV2, setMaxOutputFrameSize)); } diff --git a/bindings/python/src/pipeline/node/MessageDemuxBindings.cpp b/bindings/python/src/pipeline/node/MessageDemuxBindings.cpp index 9accb8962..0efdfc1fa 100644 --- a/bindings/python/src/pipeline/node/MessageDemuxBindings.cpp +++ b/bindings/python/src/pipeline/node/MessageDemuxBindings.cpp @@ -1,42 +1,35 @@ #include "Common.hpp" #include "NodeBindings.hpp" - #include "depthai/pipeline/Node.hpp" #include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/MessageDemux.hpp" #include "depthai/properties/MessageDemuxProperties.hpp" -void bind_messagedemux(pybind11::module &m, void *pCallstack) { - - using namespace dai; - using namespace dai::node; +void bind_messagedemux(pybind11::module& m, void* pCallstack) { + using namespace dai; + using namespace dai::node; - // Node and Properties declare upfront - py::class_ messageDemuxProperties( - m, "MessageDemuxProperties", DOC(dai, MessageDemuxProperties)); - auto messageDemux = ADD_NODE(MessageDemux); + // Node and Properties declare upfront + py::class_ messageDemuxProperties(m, "MessageDemuxProperties", DOC(dai, MessageDemuxProperties)); + auto messageDemux = ADD_NODE(MessageDemux); - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - // 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 - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + // 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 + // Properties - // Node - messageDemux - .def_readonly("outputs", &MessageDemux::outputs, - DOC(dai, node, MessageDemux, outputs)) - .def_readonly("input", &MessageDemux::input, - DOC(dai, node, MessageDemux, input)); - daiNodeModule.attr("MessageDemux").attr("Properties") = - messageDemuxProperties; + // Node + messageDemux.def_readonly("outputs", &MessageDemux::outputs, DOC(dai, node, MessageDemux, outputs)) + .def_readonly("input", &MessageDemux::input, DOC(dai, node, MessageDemux, input)); + daiNodeModule.attr("MessageDemux").attr("Properties") = messageDemuxProperties; } diff --git a/bindings/python/src/pipeline/node/MonoCameraBindings.cpp b/bindings/python/src/pipeline/node/MonoCameraBindings.cpp index 4e6765eb4..c484397f7 100644 --- a/bindings/python/src/pipeline/node/MonoCameraBindings.cpp +++ b/bindings/python/src/pipeline/node/MonoCameraBindings.cpp @@ -1,25 +1,24 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/MonoCamera.hpp" -void bind_monocamera(pybind11::module& m, void* pCallstack){ - +void bind_monocamera(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; // Node and Properties declare upfront py::class_ monoCameraProperties(m, "MonoCameraProperties", DOC(dai, MonoCameraProperties)); - py::enum_ monoCameraPropertiesSensorResolution(monoCameraProperties, "SensorResolution", DOC(dai, MonoCameraProperties, SensorResolution)); + py::enum_ monoCameraPropertiesSensorResolution( + monoCameraProperties, "SensorResolution", DOC(dai, MonoCameraProperties, SensorResolution)); auto monoCamera = ADD_NODE(MonoCamera); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -28,52 +27,48 @@ void bind_monocamera(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// - // Properties - monoCameraPropertiesSensorResolution - .value("THE_720_P", MonoCameraProperties::SensorResolution::THE_720_P) + monoCameraPropertiesSensorResolution.value("THE_720_P", MonoCameraProperties::SensorResolution::THE_720_P) .value("THE_800_P", MonoCameraProperties::SensorResolution::THE_800_P) .value("THE_400_P", MonoCameraProperties::SensorResolution::THE_400_P) .value("THE_480_P", MonoCameraProperties::SensorResolution::THE_480_P) .value("THE_1200_P", MonoCameraProperties::SensorResolution::THE_1200_P) .value("THE_4000X3000", MonoCameraProperties::SensorResolution::THE_4000X3000) - .value("THE_4224X3136", MonoCameraProperties::SensorResolution::THE_4224X3136) - ; + .value("THE_4224X3136", MonoCameraProperties::SensorResolution::THE_4224X3136); - monoCameraProperties - .def_readwrite("initialControl", &MonoCameraProperties::initialControl) + monoCameraProperties.def_readwrite("initialControl", &MonoCameraProperties::initialControl) .def_readwrite("boardSocket", &MonoCameraProperties::boardSocket) .def_readwrite("resolution", &MonoCameraProperties::resolution) .def_readwrite("fps", &MonoCameraProperties::fps) .def_readwrite("isp3aFps", &MonoCameraProperties::isp3aFps) .def_readwrite("numFramesPool", &MonoCameraProperties::numFramesPool) .def_readwrite("numFramesPoolRaw", &MonoCameraProperties::numFramesPoolRaw) - .def_readwrite("eventFilter", &MonoCameraProperties::eventFilter) - ; + .def_readwrite("eventFilter", &MonoCameraProperties::eventFilter); // Node - monoCamera - .def_readonly("inputControl", &MonoCamera::inputControl, DOC(dai, node, MonoCamera, inputControl)) - .def_readonly("out", &MonoCamera::out, DOC(dai, node, MonoCamera, out)) - .def_readonly("raw", &MonoCamera::raw, DOC(dai, node, MonoCamera, raw)) - .def_readonly("frameEvent", &MonoCamera::frameEvent, DOC(dai, node, MonoCamera, frameEvent)) - .def_readonly("initialControl", &MonoCamera::initialControl, DOC(dai, node, MonoCamera, initialControl)) - .def("setCamId", [](MonoCamera& c, int64_t id) { - // Issue an deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "setCamId() is deprecated, use setBoardSocket() instead.", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - c.setCamId(id); - HEDLEY_DIAGNOSTIC_POP - }) - .def("getCamId", [](MonoCamera& c) { - // Issue an deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "getCamId() is deprecated, use getBoardSocket() instead.", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - return c.getCamId(); - HEDLEY_DIAGNOSTIC_POP - }) + monoCamera.def_readonly("inputControl", &MonoCamera::inputControl, DOC(dai, node, MonoCamera, inputControl)) + .def_readonly("out", &MonoCamera::out, DOC(dai, node, MonoCamera, out)) + .def_readonly("raw", &MonoCamera::raw, DOC(dai, node, MonoCamera, raw)) + .def_readonly("frameEvent", &MonoCamera::frameEvent, DOC(dai, node, MonoCamera, frameEvent)) + .def_readonly("initialControl", &MonoCamera::initialControl, DOC(dai, node, MonoCamera, initialControl)) + .def("setCamId", + [](MonoCamera& c, int64_t id) { + // Issue an deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "setCamId() is deprecated, use setBoardSocket() instead.", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + c.setCamId(id); + HEDLEY_DIAGNOSTIC_POP + }) + .def("getCamId", + [](MonoCamera& c) { + // Issue an deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "getCamId() is deprecated, use getBoardSocket() instead.", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + return c.getCamId(); + HEDLEY_DIAGNOSTIC_POP + }) .def("setBoardSocket", &MonoCamera::setBoardSocket, py::arg("boardSocket"), DOC(dai, node, MonoCamera, setBoardSocket)) .def("getBoardSocket", &MonoCamera::getBoardSocket, DOC(dai, node, MonoCamera, getBoardSocket)) .def("setImageOrientation", &MonoCamera::setImageOrientation, py::arg("imageOrientation"), DOC(dai, node, MonoCamera, setImageOrientation)) @@ -82,9 +77,9 @@ void bind_monocamera(pybind11::module& m, void* pCallstack){ .def("getResolution", &MonoCamera::getResolution, DOC(dai, node, MonoCamera, getResolution)) .def("setFrameEventFilter", &MonoCamera::setFrameEventFilter, py::arg("events"), DOC(dai, node, MonoCamera, setFrameEventFilter)) .def("getFrameEventFilter", &MonoCamera::getFrameEventFilter, DOC(dai, node, MonoCamera, getFrameEventFilter)) - .def("setFps", &MonoCamera::setFps, py::arg("fps"), DOC(dai, node, MonoCamera, setFps)) + .def("setFps", &MonoCamera::setFps, py::arg("fps"), DOC(dai, node, MonoCamera, setFps)) .def("setIsp3aFps", &MonoCamera::setIsp3aFps, DOC(dai, node, MonoCamera, setIsp3aFps)) - .def("getFps", &MonoCamera::getFps, DOC(dai, node, MonoCamera, getFps)) + .def("getFps", &MonoCamera::getFps, DOC(dai, node, MonoCamera, getFps)) .def("getResolutionSize", &MonoCamera::getResolutionSize, DOC(dai, node, MonoCamera, getResolutionSize)) .def("getResolutionWidth", &MonoCamera::getResolutionWidth, DOC(dai, node, MonoCamera, getResolutionWidth)) .def("getResolutionHeight", &MonoCamera::getResolutionHeight, DOC(dai, node, MonoCamera, getResolutionHeight)) @@ -95,9 +90,7 @@ void bind_monocamera(pybind11::module& m, void* pCallstack){ .def("setCamera", &MonoCamera::setCamera, py::arg("name"), DOC(dai, node, MonoCamera, setCamera)) .def("getCamera", &MonoCamera::getCamera, DOC(dai, node, MonoCamera, getCamera)) - .def("setRawOutputPacked", &MonoCamera::setRawOutputPacked, py::arg("packed"), DOC(dai, node, MonoCamera, setRawOutputPacked)) - ; + .def("setRawOutputPacked", &MonoCamera::setRawOutputPacked, py::arg("packed"), DOC(dai, node, MonoCamera, setRawOutputPacked)); // ALIAS daiNodeModule.attr("MonoCamera").attr("Properties") = monoCameraProperties; - } diff --git a/bindings/python/src/pipeline/node/NeuralNetworkBindings.cpp b/bindings/python/src/pipeline/node/NeuralNetworkBindings.cpp index 844624a7e..9ed171f37 100644 --- a/bindings/python/src/pipeline/node/NeuralNetworkBindings.cpp +++ b/bindings/python/src/pipeline/node/NeuralNetworkBindings.cpp @@ -1,25 +1,23 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/NeuralNetwork.hpp" - -void bind_neuralnetwork(pybind11::module& m, void* pCallstack){ - +void bind_neuralnetwork(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; // Node and Properties declare upfront - py::class_> neuralNetworkProperties(m, "NeuralNetworkProperties", DOC(dai, NeuralNetworkProperties)); + py::class_> neuralNetworkProperties( + m, "NeuralNetworkProperties", DOC(dai, NeuralNetworkProperties)); auto neuralNetwork = ADD_NODE(NeuralNetwork); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -29,13 +27,11 @@ void bind_neuralnetwork(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - neuralNetworkProperties - .def_readwrite("blobSize", &NeuralNetworkProperties::blobSize) + neuralNetworkProperties.def_readwrite("blobSize", &NeuralNetworkProperties::blobSize) .def_readwrite("blobUri", &NeuralNetworkProperties::blobUri) .def_readwrite("numFrames", &NeuralNetworkProperties::numFrames) .def_readwrite("numThreads", &NeuralNetworkProperties::numThreads) - .def_readwrite("numNCEPerThread", &NeuralNetworkProperties::numNCEPerThread) - ; + .def_readwrite("numNCEPerThread", &NeuralNetworkProperties::numNCEPerThread); // Node neuralNetwork.def_readonly("input", &NeuralNetwork::input, DOC(dai, node, NeuralNetwork, input)) @@ -49,21 +45,49 @@ void bind_neuralnetwork(pybind11::module& m, void* pCallstack){ py::arg("numNCEPerThread"), DOC(dai, node, NeuralNetwork, setNumNCEPerInferenceThread)) .def("getNumInferenceThreads", &NeuralNetwork::getNumInferenceThreads, DOC(dai, node, NeuralNetwork, getNumInferenceThreads)) - .def("setNNArchive", py::overload_cast(&NeuralNetwork::setNNArchive), py::arg("nnArchive"), DOC(dai, node, NeuralNetwork, setNNArchive)) - .def("setNNArchive", py::overload_cast(&NeuralNetwork::setNNArchive), py::arg("nnArchive"), py::arg("numShaves"), DOC(dai, node, NeuralNetwork, setNNArchive, 2)) - .def("setFromModelZoo", py::overload_cast(&NeuralNetwork::setFromModelZoo), py::arg("description"), py::arg("useCached"), DOC(dai, node, NeuralNetwork, setFromModelZoo)) - .def("build", py::overload_cast(&NeuralNetwork::build), py::arg("input"), py::arg("nnArchive"), DOC(dai, node, NeuralNetwork, build)) - .def("build", py::overload_cast&, dai::NNModelDescription, float>(&NeuralNetwork::build), py::arg("input"), py::arg("modelDesc"), py::arg("fps")=30.0f, DOC(dai, node, NeuralNetwork, build,2)) - .def("build", py::overload_cast&, dai::NNArchive, float>(&NeuralNetwork::build), py::arg("input"), py::arg("nnArchive"), py::arg("fps")=30.0f, DOC(dai, node, NeuralNetwork, build, 3)) - .def("build", [](NeuralNetwork& self, const std::shared_ptr& input, const std::string& model, float fps) { - return self.build(input, NNModelDescription{model}, fps); - }, py::arg("input"), py::arg("model"), py::arg("fps")=30.0f, DOC(dai, node, NeuralNetwork, build)) + .def("setNNArchive", + py::overload_cast(&NeuralNetwork::setNNArchive), + py::arg("nnArchive"), + DOC(dai, node, NeuralNetwork, setNNArchive)) + .def("setNNArchive", + py::overload_cast(&NeuralNetwork::setNNArchive), + py::arg("nnArchive"), + py::arg("numShaves"), + DOC(dai, node, NeuralNetwork, setNNArchive, 2)) + .def("setFromModelZoo", + py::overload_cast(&NeuralNetwork::setFromModelZoo), + py::arg("description"), + py::arg("useCached"), + DOC(dai, node, NeuralNetwork, setFromModelZoo)) + .def("build", + py::overload_cast(&NeuralNetwork::build), + py::arg("input"), + py::arg("nnArchive"), + DOC(dai, node, NeuralNetwork, build)) + .def("build", + py::overload_cast&, dai::NNModelDescription, float>(&NeuralNetwork::build), + py::arg("input"), + py::arg("modelDesc"), + py::arg("fps") = 30.0f, + DOC(dai, node, NeuralNetwork, build, 2)) + .def("build", + py::overload_cast&, dai::NNArchive, float>(&NeuralNetwork::build), + py::arg("input"), + py::arg("nnArchive"), + py::arg("fps") = 30.0f, + DOC(dai, node, NeuralNetwork, build, 3)) + .def( + "build", + [](NeuralNetwork& self, const std::shared_ptr& input, const std::string& model, float fps) { + return self.build(input, NNModelDescription{model}, fps); + }, + py::arg("input"), + py::arg("model"), + py::arg("fps") = 30.0f, + DOC(dai, node, NeuralNetwork, build)) .def("setBlob", py::overload_cast(&NeuralNetwork::setBlob), py::arg("blob"), DOC(dai, node, NeuralNetwork, setBlob)) .def("setBlob", py::overload_cast(&NeuralNetwork::setBlob), py::arg("path"), DOC(dai, node, NeuralNetwork, setBlob, 2)) - .def("setModelPath", - &NeuralNetwork::setModelPath, - py::arg("modelPath"), - DOC(dai, node, NeuralNetwork, setModelPath)) + .def("setModelPath", &NeuralNetwork::setModelPath, py::arg("modelPath"), DOC(dai, node, NeuralNetwork, setModelPath)) .def("setNumShavesPerInferenceThread", &NeuralNetwork::setNumShavesPerInferenceThread, py::arg("numShavesPerInferenceThread"), @@ -77,5 +101,4 @@ void bind_neuralnetwork(pybind11::module& m, void* pCallstack){ ; // Properties alias daiNodeModule.attr("NeuralNetwork").attr("Properties") = neuralNetworkProperties; - } diff --git a/bindings/python/src/pipeline/node/NodeBindings.cpp b/bindings/python/src/pipeline/node/NodeBindings.cpp index 0e6cca987..f9816bf0b 100644 --- a/bindings/python/src/pipeline/node/NodeBindings.cpp +++ b/bindings/python/src/pipeline/node/NodeBindings.cpp @@ -315,14 +315,18 @@ void NodeBindings::bind(pybind11::module& m, void* pCallstack) { DOC(dai, Node, Input, getParent)) .def("getPossibleDatatypes", &Node::Input::getPossibleDatatypes, DOC(dai, Node, Input, getPossibleDatatypes)) .def("setPossibleDatatypes", &Node::Input::setPossibleDatatypes, py::arg("types"), DOC(dai, Node, Input, setPossibleDatatypes)) - .def("setPossibleDatatypes", [](Node::Input& input, const std::vector>& types) { - std::vector converted; - converted.reserve(types.size()); - for(const auto& t : types) { - converted.emplace_back(std::get<0>(t), std::get<1>(t)); - } - input.setPossibleDatatypes(converted); - }, py::arg("types"), DOC(dai, Node, Input, setPossibleDatatypes)) + .def( + "setPossibleDatatypes", + [](Node::Input& input, const std::vector>& types) { + std::vector converted; + converted.reserve(types.size()); + for(const auto& t : types) { + converted.emplace_back(std::get<0>(t), std::get<1>(t)); + } + input.setPossibleDatatypes(converted); + }, + py::arg("types"), + DOC(dai, Node, Input, setPossibleDatatypes)) .def("setWaitForMessage", &Node::Input::setWaitForMessage, py::arg("waitForMessage"), DOC(dai, Node, Input, setWaitForMessage)) .def("getWaitForMessage", &Node::Input::getWaitForMessage, DOC(dai, Node, Input, getWaitForMessage)) .def("setReusePreviousMessage", &Node::Input::setReusePreviousMessage, py::arg("reusePreviousMessage"), DOC(dai, Node, Input, setReusePreviousMessage)) @@ -347,14 +351,18 @@ void NodeBindings::bind(pybind11::module& m, void* pCallstack) { py::keep_alive<1, 0>()) .def("getPossibleDatatypes", &Node::Output::getPossibleDatatypes, DOC(dai, Node, Output, getPossibleDatatypes)) .def("setPossibleDatatypes", &Node::Output::setPossibleDatatypes, py::arg("types"), DOC(dai, Node, Output, setPossibleDatatypes)) - .def("setPossibleDatatypes", [](Node::Output& output, const std::vector>& types) { - std::vector converted; - converted.reserve(types.size()); - for(const auto& t : types) { - converted.emplace_back(std::get<0>(t), std::get<1>(t)); - } - output.setPossibleDatatypes(converted); - }, py::arg("types"), DOC(dai, Node, Output, setPossibleDatatypes)) + .def( + "setPossibleDatatypes", + [](Node::Output& output, const std::vector>& types) { + std::vector converted; + converted.reserve(types.size()); + for(const auto& t : types) { + converted.emplace_back(std::get<0>(t), std::get<1>(t)); + } + output.setPossibleDatatypes(converted); + }, + py::arg("types"), + DOC(dai, Node, Output, setPossibleDatatypes)) .def("getParent", static_cast(&Node::Output::getParent), py::return_value_policy::reference_internal, @@ -422,7 +430,6 @@ void NodeBindings::bind(pybind11::module& m, void* pCallstack) { py::return_value_policy::reference_internal, DOC(dai, Node, getAssetManager)); - // TODO(themarpe) - refactor, threaded node could be separate from Node pyThreadedNode.def("trace", [](dai::ThreadedNode& node, const std::string& msg) { node.logger->trace(msg); }) .def("debug", [](dai::ThreadedNode& node, const std::string& msg) { node.logger->debug(msg); }) diff --git a/bindings/python/src/pipeline/node/NodeBindings.hpp b/bindings/python/src/pipeline/node/NodeBindings.hpp index f9ceeb793..3747283dc 100644 --- a/bindings/python/src/pipeline/node/NodeBindings.hpp +++ b/bindings/python/src/pipeline/node/NodeBindings.hpp @@ -10,7 +10,6 @@ #include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/ThreadedHostNode.hpp" - dai::Pipeline* getImplicitPipeline(); void setImplicitPipeline(dai::Pipeline* pipeline); void delImplicitPipeline(); @@ -18,6 +17,7 @@ void delImplicitPipeline(); struct NodeBindings { static void addToCallstack(std::deque& callstack); static std::vector(dai::Pipeline&, py::object class_)>>> getNodeCreateMap(); - private: + + private: static void bind(pybind11::module& m, void* pCallstack); }; diff --git a/bindings/python/src/pipeline/node/ObjectTrackerBindings.cpp b/bindings/python/src/pipeline/node/ObjectTrackerBindings.cpp index b2b2b76a3..d4c1a231a 100644 --- a/bindings/python/src/pipeline/node/ObjectTrackerBindings.cpp +++ b/bindings/python/src/pipeline/node/ObjectTrackerBindings.cpp @@ -1,26 +1,25 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/ObjectTracker.hpp" -void bind_objecttracker(pybind11::module& m, void* pCallstack){ - +void bind_objecttracker(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; // Node and Properties declare upfront py::enum_ trackerType(m, "TrackerType"); py::enum_ trackerIdAssignmentPolicy(m, "TrackerIdAssignmentPolicy"); - py::class_> objectTrackerProperties(m, "ObjectTrackerProperties", DOC(dai, ObjectTrackerProperties)); + py::class_> objectTrackerProperties( + m, "ObjectTrackerProperties", DOC(dai, ObjectTrackerProperties)); auto objectTracker = ADD_NODE(ObjectTracker); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -30,29 +29,22 @@ void bind_objecttracker(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - trackerType - .value("SHORT_TERM_KCF", TrackerType::SHORT_TERM_KCF, DOC(dai, TrackerType, SHORT_TERM_KCF)) + trackerType.value("SHORT_TERM_KCF", TrackerType::SHORT_TERM_KCF, DOC(dai, TrackerType, SHORT_TERM_KCF)) .value("SHORT_TERM_IMAGELESS", TrackerType::SHORT_TERM_IMAGELESS, DOC(dai, TrackerType, SHORT_TERM_IMAGELESS)) .value("ZERO_TERM_IMAGELESS", TrackerType::ZERO_TERM_IMAGELESS, DOC(dai, TrackerType, ZERO_TERM_IMAGELESS)) - .value("ZERO_TERM_COLOR_HISTOGRAM", TrackerType::ZERO_TERM_COLOR_HISTOGRAM, DOC(dai, TrackerType, ZERO_TERM_COLOR_HISTOGRAM)) - ; + .value("ZERO_TERM_COLOR_HISTOGRAM", TrackerType::ZERO_TERM_COLOR_HISTOGRAM, DOC(dai, TrackerType, ZERO_TERM_COLOR_HISTOGRAM)); - trackerIdAssignmentPolicy - .value("UNIQUE_ID", TrackerIdAssignmentPolicy::UNIQUE_ID) - .value("SMALLEST_ID", TrackerIdAssignmentPolicy::SMALLEST_ID) - ; + trackerIdAssignmentPolicy.value("UNIQUE_ID", TrackerIdAssignmentPolicy::UNIQUE_ID).value("SMALLEST_ID", TrackerIdAssignmentPolicy::SMALLEST_ID); - objectTrackerProperties - .def_readwrite("trackerThreshold", &ObjectTrackerProperties::trackerThreshold, DOC(dai, ObjectTrackerProperties, trackerThreshold)) + objectTrackerProperties.def_readwrite("trackerThreshold", &ObjectTrackerProperties::trackerThreshold, DOC(dai, ObjectTrackerProperties, trackerThreshold)) .def_readwrite("maxObjectsToTrack", &ObjectTrackerProperties::maxObjectsToTrack, DOC(dai, ObjectTrackerProperties, maxObjectsToTrack)) .def_readwrite("detectionLabelsToTrack", &ObjectTrackerProperties::detectionLabelsToTrack, DOC(dai, ObjectTrackerProperties, detectionLabelsToTrack)) .def_readwrite("trackerType", &ObjectTrackerProperties::trackerType, DOC(dai, ObjectTrackerProperties, trackerType)) - .def_readwrite("trackerIdAssignmentPolicy", &ObjectTrackerProperties::trackerIdAssignmentPolicy, DOC(dai, ObjectTrackerProperties, trackerIdAssignmentPolicy)) - ; + .def_readwrite( + "trackerIdAssignmentPolicy", &ObjectTrackerProperties::trackerIdAssignmentPolicy, DOC(dai, ObjectTrackerProperties, trackerIdAssignmentPolicy)); // Node - objectTracker - .def_readonly("inputTrackerFrame", &ObjectTracker::inputTrackerFrame, DOC(dai, node, ObjectTracker, inputTrackerFrame)) + objectTracker.def_readonly("inputTrackerFrame", &ObjectTracker::inputTrackerFrame, DOC(dai, node, ObjectTracker, inputTrackerFrame)) .def_readonly("inputDetectionFrame", &ObjectTracker::inputDetectionFrame, DOC(dai, node, ObjectTracker, inputDetectionFrame)) .def_readonly("inputDetections", &ObjectTracker::inputDetections, DOC(dai, node, ObjectTracker, inputDetections)) .def_readonly("out", &ObjectTracker::out, DOC(dai, node, ObjectTracker, out)) @@ -62,11 +54,13 @@ void bind_objecttracker(pybind11::module& m, void* pCallstack){ .def("setTrackerThreshold", &ObjectTracker::setTrackerThreshold, py::arg("threshold"), DOC(dai, node, ObjectTracker, setTrackerThreshold)) .def("setMaxObjectsToTrack", &ObjectTracker::setMaxObjectsToTrack, py::arg("maxObjectsToTrack"), DOC(dai, node, ObjectTracker, setMaxObjectsToTrack)) - .def("setDetectionLabelsToTrack", &ObjectTracker::setDetectionLabelsToTrack, py::arg("labels"), DOC(dai, node, ObjectTracker, setDetectionLabelsToTrack)) + .def( + "setDetectionLabelsToTrack", &ObjectTracker::setDetectionLabelsToTrack, py::arg("labels"), DOC(dai, node, ObjectTracker, setDetectionLabelsToTrack)) .def("setTrackerType", &ObjectTracker::setTrackerType, py::arg("type"), DOC(dai, node, ObjectTracker, setTrackerType)) - .def("setTrackerIdAssignmentPolicy", &ObjectTracker::setTrackerIdAssignmentPolicy, py::arg("type"), DOC(dai, node, ObjectTracker, setTrackerIdAssignmentPolicy)) - .def("setTrackingPerClass", &ObjectTracker::setTrackingPerClass, py::arg("trackingPerClass"), DOC(dai, node, ObjectTracker, setTrackingPerClass)) - ; + .def("setTrackerIdAssignmentPolicy", + &ObjectTracker::setTrackerIdAssignmentPolicy, + py::arg("type"), + DOC(dai, node, ObjectTracker, setTrackerIdAssignmentPolicy)) + .def("setTrackingPerClass", &ObjectTracker::setTrackingPerClass, py::arg("trackingPerClass"), DOC(dai, node, ObjectTracker, setTrackingPerClass)); daiNodeModule.attr("ObjectTracker").attr("Properties") = objectTrackerProperties; - } diff --git a/bindings/python/src/pipeline/node/PointCloudBindings.cpp b/bindings/python/src/pipeline/node/PointCloudBindings.cpp index 63ad94393..9fd1c2efc 100644 --- a/bindings/python/src/pipeline/node/PointCloudBindings.cpp +++ b/bindings/python/src/pipeline/node/PointCloudBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/PointCloud.hpp" -void bind_pointcloud(pybind11::module& m, void* pCallstack){ - +void bind_pointcloud(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -18,7 +16,7 @@ void bind_pointcloud(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -28,21 +26,18 @@ void bind_pointcloud(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - properties - .def_readwrite("initialConfig", &PointCloudProperties::initialConfig, DOC(dai, PointCloudProperties, initialConfig)) - .def_readwrite("numFramesPool", &PointCloudProperties::numFramesPool, DOC(dai, PointCloudProperties, numFramesPool)) - ; + properties.def_readwrite("initialConfig", &PointCloudProperties::initialConfig, DOC(dai, PointCloudProperties, initialConfig)) + .def_readwrite("numFramesPool", &PointCloudProperties::numFramesPool, DOC(dai, PointCloudProperties, numFramesPool)); // Node - node - .def_readonly("inputConfig", &PointCloud::inputConfig, DOC(dai, node, PointCloud, inputConfig), DOC(dai, node, PointCloud, inputConfig)) + node.def_readonly("inputConfig", &PointCloud::inputConfig, DOC(dai, node, PointCloud, inputConfig), DOC(dai, node, PointCloud, inputConfig)) .def_readonly("inputDepth", &PointCloud::inputDepth, DOC(dai, node, PointCloud, inputDepth), DOC(dai, node, PointCloud, inputDepth)) - .def_readonly("outputPointCloud", &PointCloud::outputPointCloud, DOC(dai, node, PointCloud, outputPointCloud), DOC(dai, node, PointCloud, outputPointCloud)) - .def_readonly("passthroughDepth", &PointCloud::passthroughDepth, DOC(dai, node, PointCloud, passthroughDepth), DOC(dai, node, PointCloud, passthroughDepth)) + .def_readonly( + "outputPointCloud", &PointCloud::outputPointCloud, DOC(dai, node, PointCloud, outputPointCloud), DOC(dai, node, PointCloud, outputPointCloud)) + .def_readonly( + "passthroughDepth", &PointCloud::passthroughDepth, DOC(dai, node, PointCloud, passthroughDepth), DOC(dai, node, PointCloud, passthroughDepth)) .def_readonly("initialConfig", &PointCloud::initialConfig, DOC(dai, node, PointCloud, initialConfig), DOC(dai, node, PointCloud, initialConfig)) - .def("setNumFramesPool", &PointCloud::setNumFramesPool, DOC(dai, node, PointCloud, setNumFramesPool)) - ; + .def("setNumFramesPool", &PointCloud::setNumFramesPool, DOC(dai, node, PointCloud, setNumFramesPool)); // ALIAS daiNodeModule.attr("PointCloud").attr("Properties") = properties; - } diff --git a/bindings/python/src/pipeline/node/RTABMapSLAMBindings.cpp b/bindings/python/src/pipeline/node/RTABMapSLAMBindings.cpp index 2df6bb59b..332a7d806 100644 --- a/bindings/python/src/pipeline/node/RTABMapSLAMBindings.cpp +++ b/bindings/python/src/pipeline/node/RTABMapSLAMBindings.cpp @@ -1,13 +1,13 @@ +#include + #include "Common.hpp" #include "NodeBindings.hpp" #include "depthai/pipeline/ThreadedHostNode.hpp" #include "depthai/rtabmap/RTABMapSLAM.hpp" -#include - extern py::handle daiNodeModule; -void bind_rtabmapslamnode(pybind11::module& m, void* pCallstack){ +void bind_rtabmapslamnode(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -18,7 +18,7 @@ void bind_rtabmapslamnode(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -29,8 +29,10 @@ void bind_rtabmapslamnode(pybind11::module& m, void* pCallstack){ // RTABMapSLAM Node rtabmapSLAMNode - .def_property_readonly("rect", [](RTABMapSLAM& node){ return &node.rect; }, py::return_value_policy::reference_internal) - .def_property_readonly("depth", [](RTABMapSLAM& node){ return &node.depth; }, py::return_value_policy::reference_internal) + .def_property_readonly( + "rect", [](RTABMapSLAM& node) { return &node.rect; }, py::return_value_policy::reference_internal) + .def_property_readonly( + "depth", [](RTABMapSLAM& node) { return &node.depth; }, py::return_value_policy::reference_internal) .def_readonly("features", &RTABMapSLAM::features, DOC(dai, node, RTABMapSLAM, features)) .def_readonly("odom", &RTABMapSLAM::odom, DOC(dai, node, RTABMapSLAM, odom)) .def_readonly("transform", &RTABMapSLAM::transform, DOC(dai, node, RTABMapSLAM, transform)) @@ -47,7 +49,8 @@ void bind_rtabmapslamnode(pybind11::module& m, void* pCallstack){ .def("setLoadDatabaseOnStart", &RTABMapSLAM::setLoadDatabaseOnStart, py::arg("load"), DOC(dai, node, RTABMapSLAM, setLoadDatabaseOnStart)) .def("setSaveDatabaseOnClose", &RTABMapSLAM::setSaveDatabaseOnClose, py::arg("save"), DOC(dai, node, RTABMapSLAM, setSaveDatabaseOnClose)) .def("saveDatabase", &RTABMapSLAM::saveDatabase, DOC(dai, node, RTABMapSLAM, saveDatabase)) - .def("setSaveDatabasePeriodically", &RTABMapSLAM::setSaveDatabasePeriodically, py::arg("save"), DOC(dai, node, RTABMapSLAM, setSaveDatabasePeriodically)) + .def( + "setSaveDatabasePeriodically", &RTABMapSLAM::setSaveDatabasePeriodically, py::arg("save"), DOC(dai, node, RTABMapSLAM, setSaveDatabasePeriodically)) .def("setSaveDatabasePeriod", &RTABMapSLAM::setSaveDatabasePeriod, py::arg("period"), DOC(dai, node, RTABMapSLAM, setSaveDatabasePeriod)) .def("setPublishObstacleCloud", &RTABMapSLAM::setPublishObstacleCloud, py::arg("publish"), DOC(dai, node, RTABMapSLAM, setPublishObstacleCloud)) .def("setPublishGroundCloud", &RTABMapSLAM::setPublishGroundCloud, py::arg("publish"), DOC(dai, node, RTABMapSLAM, setPublishGroundCloud)) diff --git a/bindings/python/src/pipeline/node/RTABMapVIOBindings.cpp b/bindings/python/src/pipeline/node/RTABMapVIOBindings.cpp index a7d05b55b..e458ce811 100644 --- a/bindings/python/src/pipeline/node/RTABMapVIOBindings.cpp +++ b/bindings/python/src/pipeline/node/RTABMapVIOBindings.cpp @@ -1,13 +1,13 @@ +#include + #include "Common.hpp" #include "NodeBindings.hpp" #include "depthai/pipeline/ThreadedHostNode.hpp" #include "depthai/rtabmap/RTABMapVIO.hpp" -#include - extern py::handle daiNodeModule; -void bind_rtabmapvionode(pybind11::module& m, void* pCallstack){ +void bind_rtabmapvionode(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -18,7 +18,7 @@ void bind_rtabmapvionode(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -29,8 +29,10 @@ void bind_rtabmapvionode(pybind11::module& m, void* pCallstack){ // RTABMapVIO Node rtabmapVIONode - .def_property_readonly("rect", [](RTABMapVIO& node){ return &node.rect; }, py::return_value_policy::reference_internal) - .def_property_readonly("depth", [](RTABMapVIO& node){ return &node.depth; }, py::return_value_policy::reference_internal) + .def_property_readonly( + "rect", [](RTABMapVIO& node) { return &node.rect; }, py::return_value_policy::reference_internal) + .def_property_readonly( + "depth", [](RTABMapVIO& node) { return &node.depth; }, py::return_value_policy::reference_internal) .def_readonly("imu", &RTABMapVIO::imu, DOC(dai, node, RTABMapVIO, imu)) .def_readonly("features", &RTABMapVIO::features, DOC(dai, node, RTABMapVIO, features)) .def_readonly("transform", &RTABMapVIO::transform, DOC(dai, node, RTABMapVIO, transform)) diff --git a/bindings/python/src/pipeline/node/RecordBindings.cpp b/bindings/python/src/pipeline/node/RecordBindings.cpp index 39299f38c..02f98e1e3 100644 --- a/bindings/python/src/pipeline/node/RecordBindings.cpp +++ b/bindings/python/src/pipeline/node/RecordBindings.cpp @@ -3,7 +3,7 @@ #include "Common.hpp" #include "depthai/pipeline/node/host/Record.hpp" -void bind_record(pybind11::module& m, void* pCallstack){ +void bind_record(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace node; @@ -14,7 +14,7 @@ void bind_record(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -33,8 +33,10 @@ void bind_record(pybind11::module& m, void* pCallstack){ recordMessage.def_readonly("input", &RecordMetadataOnly::input, DOC(dai, node, RecordMetadataOnly, input)) .def("setRecordFile", &RecordMetadataOnly::setRecordFile, py::arg("recordFile"), DOC(dai, node, RecordMetadataOnly, setRecordFile)) - .def("setCompressionLevel", &RecordMetadataOnly::setCompressionLevel, py::arg("compressionLevel"), DOC(dai, node, RecordMetadataOnly, setCompressionLevel)) + .def("setCompressionLevel", + &RecordMetadataOnly::setCompressionLevel, + py::arg("compressionLevel"), + DOC(dai, node, RecordMetadataOnly, setCompressionLevel)) .def("getRecordFile", &RecordMetadataOnly::getRecordFile, DOC(dai, node, RecordMetadataOnly, getRecordFile)) .def("getCompressionLevel", &RecordMetadataOnly::getCompressionLevel, DOC(dai, node, RecordMetadataOnly, getCompressionLevel)); - } diff --git a/bindings/python/src/pipeline/node/ReplayBindings.cpp b/bindings/python/src/pipeline/node/ReplayBindings.cpp index 23e14e1ac..6fc139617 100644 --- a/bindings/python/src/pipeline/node/ReplayBindings.cpp +++ b/bindings/python/src/pipeline/node/ReplayBindings.cpp @@ -3,7 +3,7 @@ #include "Common.hpp" #include "depthai/pipeline/node/host/Replay.hpp" -void bind_replay(pybind11::module& m, void* pCallstack){ +void bind_replay(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace node; @@ -14,7 +14,7 @@ void bind_replay(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); diff --git a/bindings/python/src/pipeline/node/SPIInBindings.cpp b/bindings/python/src/pipeline/node/SPIInBindings.cpp index 04f4147bf..9b4504db2 100644 --- a/bindings/python/src/pipeline/node/SPIInBindings.cpp +++ b/bindings/python/src/pipeline/node/SPIInBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/SPIIn.hpp" -void bind_spiin(pybind11::module& m, void* pCallstack){ - +void bind_spiin(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -19,7 +17,7 @@ void bind_spiin(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -29,16 +27,13 @@ void bind_spiin(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - spiInProperties - .def_readwrite("streamName", &SPIInProperties::streamName) + spiInProperties.def_readwrite("streamName", &SPIInProperties::streamName) .def_readwrite("busId", &SPIInProperties::busId) .def_readwrite("maxDataSize", &SPIInProperties::maxDataSize) - .def_readwrite("numFrames", &SPIInProperties::numFrames) - ; + .def_readwrite("numFrames", &SPIInProperties::numFrames); // Node - spiIn - .def_readonly("out", &SPIIn::out, DOC(dai, node, SPIIn, out)) + spiIn.def_readonly("out", &SPIIn::out, DOC(dai, node, SPIIn, out)) .def("setStreamName", &SPIIn::setStreamName, py::arg("name"), DOC(dai, node, SPIIn, setStreamName)) .def("setBusId", &SPIIn::setBusId, py::arg("id"), DOC(dai, node, SPIIn, setBusId)) .def("setMaxDataSize", &SPIIn::setMaxDataSize, py::arg("maxDataSize"), DOC(dai, node, SPIIn, setMaxDataSize)) @@ -46,11 +41,7 @@ void bind_spiin(pybind11::module& m, void* pCallstack){ .def("getStreamName", &SPIIn::getStreamName, DOC(dai, node, SPIIn, getStreamName)) .def("getBusId", &SPIIn::getBusId, DOC(dai, node, SPIIn, getBusId)) .def("getMaxDataSize", &SPIIn::getMaxDataSize, DOC(dai, node, SPIIn, getMaxDataSize)) - .def("getNumFrames", &SPIIn::getNumFrames, DOC(dai, node, SPIIn, getNumFrames)) - ; + .def("getNumFrames", &SPIIn::getNumFrames, DOC(dai, node, SPIIn, getNumFrames)); // ALIAS daiNodeModule.attr("SPIIn").attr("Properties") = spiInProperties; - - - } diff --git a/bindings/python/src/pipeline/node/SPIOutBindings.cpp b/bindings/python/src/pipeline/node/SPIOutBindings.cpp index 2148e00be..57b04837b 100644 --- a/bindings/python/src/pipeline/node/SPIOutBindings.cpp +++ b/bindings/python/src/pipeline/node/SPIOutBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/SPIOut.hpp" -void bind_spiout(pybind11::module& m, void* pCallstack){ - +void bind_spiout(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -14,12 +12,11 @@ void bind_spiout(pybind11::module& m, void* pCallstack){ py::class_ spiOutProperties(m, "SPIOutProperties", DOC(dai, SPIOutProperties)); auto spiOut = ADD_NODE(SPIOut); - /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -29,19 +26,12 @@ void bind_spiout(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - spiOutProperties - .def_readwrite("streamName", &SPIOutProperties::streamName) - .def_readwrite("busId", &SPIOutProperties::busId) - ; + spiOutProperties.def_readwrite("streamName", &SPIOutProperties::streamName).def_readwrite("busId", &SPIOutProperties::busId); // Node - spiOut - .def_readonly("input", &SPIOut::input, DOC(dai, node, SPIOut, input)) + spiOut.def_readonly("input", &SPIOut::input, DOC(dai, node, SPIOut, input)) .def("setStreamName", &SPIOut::setStreamName, py::arg("name"), DOC(dai, node, SPIOut, setStreamName)) - .def("setBusId", &SPIOut::setBusId, py::arg("id"), DOC(dai, node, SPIOut, setBusId)) - ; + .def("setBusId", &SPIOut::setBusId, py::arg("id"), DOC(dai, node, SPIOut, setBusId)); // ALIAS daiNodeModule.attr("SPIOut").attr("Properties") = spiOutProperties; - - } diff --git a/bindings/python/src/pipeline/node/ScriptBindings.cpp b/bindings/python/src/pipeline/node/ScriptBindings.cpp index 7ba029143..9757db9df 100644 --- a/bindings/python/src/pipeline/node/ScriptBindings.cpp +++ b/bindings/python/src/pipeline/node/ScriptBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/Script.hpp" -void bind_script(pybind11::module& m, void* pCallstack){ - +void bind_script(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -18,7 +16,7 @@ void bind_script(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -28,15 +26,12 @@ void bind_script(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - scriptProperties - .def_readwrite("scriptUri", &ScriptProperties::scriptUri, DOC(dai, ScriptProperties, scriptUri)) + scriptProperties.def_readwrite("scriptUri", &ScriptProperties::scriptUri, DOC(dai, ScriptProperties, scriptUri)) .def_readwrite("scriptName", &ScriptProperties::scriptName, DOC(dai, ScriptProperties, scriptName)) - .def_readwrite("processor", &ScriptProperties::processor, DOC(dai, ScriptProperties, processor)) - ; + .def_readwrite("processor", &ScriptProperties::processor, DOC(dai, ScriptProperties, processor)); // Node - script - .def_readonly("inputs", &Script::inputs) + script.def_readonly("inputs", &Script::inputs) .def_readonly("outputs", &Script::outputs) #ifdef DEPTHAI_SCRIPT_NODE_ADD_IO .def_property_readonly( @@ -58,13 +53,19 @@ void bind_script(pybind11::module& m, void* pCallstack){ py::return_value_policy::reference_internal) #endif .def("setScriptPath", &Script::setScriptPath, DOC(dai, node, Script, setScriptPath)) - .def("setScript", py::overload_cast(&Script::setScript), py::arg("script"), py::arg("name") = "", DOC(dai, node, Script, setScript)) - .def("setScript", py::overload_cast&, const std::string&>(&Script::setScript), py::arg("data"), py::arg("name") = "", DOC(dai, node, Script, setScript, 2)) + .def("setScript", + py::overload_cast(&Script::setScript), + py::arg("script"), + py::arg("name") = "", + DOC(dai, node, Script, setScript)) + .def("setScript", + py::overload_cast&, const std::string&>(&Script::setScript), + py::arg("data"), + py::arg("name") = "", + DOC(dai, node, Script, setScript, 2)) .def("setScriptPath", &Script::setScriptPath, py::arg("path"), py::arg("name") = "", DOC(dai, node, Script, setScriptPath)) .def("getScriptName", &Script::getScriptName, DOC(dai, node, Script, getScriptName)) .def("setProcessor", &Script::setProcessor, DOC(dai, node, Script, setProcessor)) - .def("getProcessor", &Script::getProcessor, DOC(dai, node, Script, getProcessor)) - ; + .def("getProcessor", &Script::getProcessor, DOC(dai, node, Script, getProcessor)); daiNodeModule.attr("Script").attr("Properties") = scriptProperties; - } diff --git a/bindings/python/src/pipeline/node/SpatialDetectionNetworkBindings.cpp b/bindings/python/src/pipeline/node/SpatialDetectionNetworkBindings.cpp index a0c03a69e..6142b65fe 100644 --- a/bindings/python/src/pipeline/node/SpatialDetectionNetworkBindings.cpp +++ b/bindings/python/src/pipeline/node/SpatialDetectionNetworkBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/SpatialDetectionNetwork.hpp" -void bind_spatialdetectionnetwork(pybind11::module& m, void* pCallstack){ - +void bind_spatialdetectionnetwork(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -21,7 +19,7 @@ void bind_spatialdetectionnetwork(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -31,20 +29,36 @@ void bind_spatialdetectionnetwork(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - spatialDetectionNetworkProperties - .def_readwrite("detectedBBScaleFactor", &SpatialDetectionNetworkProperties::detectedBBScaleFactor) - .def_readwrite("depthThresholds", &SpatialDetectionNetworkProperties::depthThresholds) - ; - + spatialDetectionNetworkProperties.def_readwrite("detectedBBScaleFactor", &SpatialDetectionNetworkProperties::detectedBBScaleFactor) + .def_readwrite("depthThresholds", &SpatialDetectionNetworkProperties::depthThresholds); // Node spatialDetectionNetwork // Copied from NN node - .def("build", py::overload_cast&, const std::shared_ptr&, NNModelDescription, float>(&SpatialDetectionNetwork::build), py::arg("input"), py::arg("stereo"), py::arg("model"), py::arg("fps") = 30.0f, DOC(dai, node, SpatialDetectionNetwork, build)) - .def("build", ([](SpatialDetectionNetwork& self, const std::shared_ptr& input, const std::shared_ptr& stereo, std::string model, float fps) { - return self.build(input, stereo, NNModelDescription{model}, fps); - }), py::arg("input"), py::arg("stereo"), py::arg("model"), py::arg("fps") = 30.0f, DOC(dai, node, SpatialDetectionNetwork, build, 2)) - .def("build", py::overload_cast&, const std::shared_ptr&, NNArchive, float>(&SpatialDetectionNetwork::build), py::arg("input"), py::arg("stereo"), py::arg("nnArchive"), py::arg("fps") = 30.0f, DOC(dai, node, SpatialDetectionNetwork, build, 2)) + .def("build", + py::overload_cast&, const std::shared_ptr&, NNModelDescription, float>(&SpatialDetectionNetwork::build), + py::arg("input"), + py::arg("stereo"), + py::arg("model"), + py::arg("fps") = 30.0f, + DOC(dai, node, SpatialDetectionNetwork, build)) + .def( + "build", + ([](SpatialDetectionNetwork& self, const std::shared_ptr& input, const std::shared_ptr& stereo, std::string model, float fps) { + return self.build(input, stereo, NNModelDescription{model}, fps); + }), + py::arg("input"), + py::arg("stereo"), + py::arg("model"), + py::arg("fps") = 30.0f, + DOC(dai, node, SpatialDetectionNetwork, build, 2)) + .def("build", + py::overload_cast&, const std::shared_ptr&, NNArchive, float>(&SpatialDetectionNetwork::build), + py::arg("input"), + py::arg("stereo"), + py::arg("nnArchive"), + py::arg("fps") = 30.0f, + DOC(dai, node, SpatialDetectionNetwork, build, 2)) .def("setBlobPath", &SpatialDetectionNetwork::setBlobPath, py::arg("path"), DOC(dai, node, SpatialDetectionNetwork, setBlobPath)) .def("setNumPoolFrames", &SpatialDetectionNetwork::setNumPoolFrames, py::arg("numFrames"), DOC(dai, node, SpatialDetectionNetwork, setNumPoolFrames)) .def("setNumInferenceThreads", @@ -56,9 +70,20 @@ void bind_spatialdetectionnetwork(pybind11::module& m, void* pCallstack){ py::arg("numNCEPerThread"), DOC(dai, node, SpatialDetectionNetwork, setNumNCEPerInferenceThread)) .def("getNumInferenceThreads", &SpatialDetectionNetwork::getNumInferenceThreads, DOC(dai, node, SpatialDetectionNetwork, getNumInferenceThreads)) - .def("setNNArchive", py::overload_cast(&SpatialDetectionNetwork::setNNArchive), py::arg("archive"), DOC(dai, node, SpatialDetectionNetwork, setNNArchive)) - .def("setNNArchive", py::overload_cast(&SpatialDetectionNetwork::setNNArchive), py::arg("archive"), py::arg("numShaves"), DOC(dai, node, SpatialDetectionNetwork, setNNArchive)) - .def("setFromModelZoo", py::overload_cast(&SpatialDetectionNetwork::setFromModelZoo), py::arg("description"), py::arg("useCached"), DOC(dai, node, SpatialDetectionNetwork, setFromModelZoo)) + .def("setNNArchive", + py::overload_cast(&SpatialDetectionNetwork::setNNArchive), + py::arg("archive"), + DOC(dai, node, SpatialDetectionNetwork, setNNArchive)) + .def("setNNArchive", + py::overload_cast(&SpatialDetectionNetwork::setNNArchive), + py::arg("archive"), + py::arg("numShaves"), + DOC(dai, node, SpatialDetectionNetwork, setNNArchive)) + .def("setFromModelZoo", + py::overload_cast(&SpatialDetectionNetwork::setFromModelZoo), + py::arg("description"), + py::arg("useCached"), + DOC(dai, node, SpatialDetectionNetwork, setFromModelZoo)) .def("setBlob", py::overload_cast(&SpatialDetectionNetwork::setBlob), py::arg("blob"), @@ -67,10 +92,7 @@ void bind_spatialdetectionnetwork(pybind11::module& m, void* pCallstack){ py::overload_cast(&SpatialDetectionNetwork::setBlob), py::arg("path"), DOC(dai, node, SpatialDetectionNetwork, setBlob, 2)) - .def("setModelPath", - &SpatialDetectionNetwork::setModelPath, - py::arg("modelPath"), - DOC(dai, node, SpatialDetectionNetwork, setModelPath)) + .def("setModelPath", &SpatialDetectionNetwork::setModelPath, py::arg("modelPath"), DOC(dai, node, SpatialDetectionNetwork, setModelPath)) .def("setNumShavesPerInferenceThread", &SpatialDetectionNetwork::setNumShavesPerInferenceThread, py::arg("numShavesPerInferenceThread"), @@ -139,7 +161,8 @@ void bind_spatialdetectionnetwork(pybind11::module& m, void* pCallstack){ // // MobileNetSpatialDetectionNetwork // YoloSpatialDetectionNetwork - yoloSpatialDetectionNetwork.def("setNumClasses", &YoloSpatialDetectionNetwork::setNumClasses, py::arg("numClasses"), DOC(dai, node, YoloSpatialDetectionNetwork, setNumClasses)) + yoloSpatialDetectionNetwork + .def("setNumClasses", &YoloSpatialDetectionNetwork::setNumClasses, py::arg("numClasses"), DOC(dai, node, YoloSpatialDetectionNetwork, setNumClasses)) .def("setCoordinateSize", &YoloSpatialDetectionNetwork::setCoordinateSize, py::arg("coordinates"), diff --git a/bindings/python/src/pipeline/node/SpatialLocationCalculatorBindings.cpp b/bindings/python/src/pipeline/node/SpatialLocationCalculatorBindings.cpp index 241d7d731..9bdd41481 100644 --- a/bindings/python/src/pipeline/node/SpatialLocationCalculatorBindings.cpp +++ b/bindings/python/src/pipeline/node/SpatialLocationCalculatorBindings.cpp @@ -1,25 +1,23 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/SpatialLocationCalculator.hpp" -void bind_spatiallocationcalculator(pybind11::module& m, void* pCallstack){ - +void bind_spatiallocationcalculator(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; // Node and Properties declare upfront - py::class_ spatialLocationCalculatorProperties(m, "SpatialLocationCalculatorProperties", DOC(dai, SpatialLocationCalculatorProperties)); + py::class_ spatialLocationCalculatorProperties( + m, "SpatialLocationCalculatorProperties", DOC(dai, SpatialLocationCalculatorProperties)); auto spatialLocationCalculator = ADD_NODE(SpatialLocationCalculator); - /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -29,38 +27,41 @@ void bind_spatiallocationcalculator(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - spatialLocationCalculatorProperties - .def_readwrite("roiConfig", &SpatialLocationCalculatorProperties::roiConfig) - ; + spatialLocationCalculatorProperties.def_readwrite("roiConfig", &SpatialLocationCalculatorProperties::roiConfig); // Node - spatialLocationCalculator - .def_readonly("inputConfig", &SpatialLocationCalculator::inputConfig, DOC(dai, node, SpatialLocationCalculator, inputConfig)) + spatialLocationCalculator.def_readonly("inputConfig", &SpatialLocationCalculator::inputConfig, DOC(dai, node, SpatialLocationCalculator, inputConfig)) .def_readonly("inputDepth", &SpatialLocationCalculator::inputDepth, DOC(dai, node, SpatialLocationCalculator, inputDepth)) .def_readonly("out", &SpatialLocationCalculator::out, DOC(dai, node, SpatialLocationCalculator, out)) .def_readonly("passthroughDepth", &SpatialLocationCalculator::passthroughDepth, DOC(dai, node, SpatialLocationCalculator, passthroughDepth)) .def_readonly("initialConfig", &SpatialLocationCalculator::initialConfig, DOC(dai, node, SpatialLocationCalculator, initialConfig)) - .def("setWaitForConfigInput", [](SpatialLocationCalculator& obj, bool wait){ - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - obj.setWaitForConfigInput(wait); - HEDLEY_DIAGNOSTIC_POP - }, py::arg("wait"), DOC(dai, node, SpatialLocationCalculator, setWaitForConfigInput)) + .def( + "setWaitForConfigInput", + [](SpatialLocationCalculator& obj, bool wait) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + obj.setWaitForConfigInput(wait); + HEDLEY_DIAGNOSTIC_POP + }, + py::arg("wait"), + DOC(dai, node, SpatialLocationCalculator, setWaitForConfigInput)) - .def("getWaitForConfigInput", [](SpatialLocationCalculator& obj){ - // Issue a deprecation warning - PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - return obj.getWaitForConfigInput(); - HEDLEY_DIAGNOSTIC_POP - }, DOC(dai, node, SpatialLocationCalculator, getWaitForConfigInput)) + .def( + "getWaitForConfigInput", + [](SpatialLocationCalculator& obj) { + // Issue a deprecation warning + PyErr_WarnEx(PyExc_DeprecationWarning, "Use 'inputConfig.setWaitForMessage()' instead", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + return obj.getWaitForConfigInput(); + HEDLEY_DIAGNOSTIC_POP + }, + DOC(dai, node, SpatialLocationCalculator, getWaitForConfigInput)) ; // ALIAS daiNodeModule.attr("SpatialLocationCalculator").attr("Properties") = spatialLocationCalculatorProperties; - } diff --git a/bindings/python/src/pipeline/node/StereoDepthBindings.cpp b/bindings/python/src/pipeline/node/StereoDepthBindings.cpp index 7f6a05e1b..f60b0f60d 100644 --- a/bindings/python/src/pipeline/node/StereoDepthBindings.cpp +++ b/bindings/python/src/pipeline/node/StereoDepthBindings.cpp @@ -1,26 +1,25 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/StereoDepth.hpp" -void bind_stereodepth(pybind11::module& m, void* pCallstack){ - +void bind_stereodepth(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; // Node and Properties declare upfront auto stereoDepth = ADD_NODE(StereoDepth); py::class_ stereoDepthProperties(m, "StereoDepthProperties", DOC(dai, StereoDepthProperties)); - py::class_ rectificationMesh(stereoDepthProperties, "RectificationMesh", DOC(dai, StereoDepthProperties, RectificationMesh)); + py::class_ rectificationMesh( + stereoDepthProperties, "RectificationMesh", DOC(dai, StereoDepthProperties, RectificationMesh)); py::enum_ stereoDepthPresetMode(stereoDepth, "PresetMode", DOC(dai, node, StereoDepth, PresetMode)); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -32,14 +31,13 @@ void bind_stereodepth(pybind11::module& m, void* pCallstack){ // Properties rectificationMesh .def_readwrite("meshLeftUri", &StereoDepthProperties::RectificationMesh::meshLeftUri, DOC(dai, StereoDepthProperties, RectificationMesh, meshLeftUri)) - .def_readwrite("meshRightUri", &StereoDepthProperties::RectificationMesh::meshRightUri, DOC(dai, StereoDepthProperties, RectificationMesh, meshRightUri)) + .def_readwrite( + "meshRightUri", &StereoDepthProperties::RectificationMesh::meshRightUri, DOC(dai, StereoDepthProperties, RectificationMesh, meshRightUri)) .def_readwrite("meshSize", &StereoDepthProperties::RectificationMesh::meshSize, DOC(dai, StereoDepthProperties, RectificationMesh, meshSize)) .def_readwrite("stepWidth", &StereoDepthProperties::RectificationMesh::stepWidth, DOC(dai, StereoDepthProperties, RectificationMesh, stepWidth)) - .def_readwrite("stepHeight", &StereoDepthProperties::RectificationMesh::stepHeight, DOC(dai, StereoDepthProperties, RectificationMesh, stepHeight)) - ; + .def_readwrite("stepHeight", &StereoDepthProperties::RectificationMesh::stepHeight, DOC(dai, StereoDepthProperties, RectificationMesh, stepHeight)); - stereoDepthProperties - .def_readwrite("initialConfig", &StereoDepthProperties::initialConfig, DOC(dai, StereoDepthProperties, initialConfig)) + stereoDepthProperties.def_readwrite("initialConfig", &StereoDepthProperties::initialConfig, DOC(dai, StereoDepthProperties, initialConfig)) .def_readwrite("depthAlignCamera", &StereoDepthProperties::depthAlignCamera, DOC(dai, StereoDepthProperties, depthAlignCamera)) .def_readwrite("enableRectification", &StereoDepthProperties::enableRectification, DOC(dai, StereoDepthProperties, enableRectification)) .def_readwrite("rectifyEdgeFillColor", &StereoDepthProperties::rectifyEdgeFillColor, DOC(dai, StereoDepthProperties, rectifyEdgeFillColor)) @@ -49,19 +47,30 @@ void bind_stereodepth(pybind11::module& m, void* pCallstack){ .def_readwrite("outHeight", &StereoDepthProperties::outHeight, DOC(dai, StereoDepthProperties, outHeight)) .def_readwrite("outKeepAspectRatio", &StereoDepthProperties::outKeepAspectRatio, DOC(dai, StereoDepthProperties, outKeepAspectRatio)) .def_readwrite("mesh", &StereoDepthProperties::mesh, DOC(dai, StereoDepthProperties, mesh)) - .def_readwrite("enableRuntimeStereoModeSwitch", &StereoDepthProperties::enableRuntimeStereoModeSwitch, DOC(dai, StereoDepthProperties, enableRuntimeStereoModeSwitch)) + .def_readwrite("enableRuntimeStereoModeSwitch", + &StereoDepthProperties::enableRuntimeStereoModeSwitch, + DOC(dai, StereoDepthProperties, enableRuntimeStereoModeSwitch)) .def_readwrite("numFramesPool", &StereoDepthProperties::numFramesPool, DOC(dai, StereoDepthProperties, numFramesPool)) .def_readwrite("numPostProcessingShaves", &StereoDepthProperties::numPostProcessingShaves, DOC(dai, StereoDepthProperties, numPostProcessingShaves)) - .def_readwrite("numPostProcessingMemorySlices", &StereoDepthProperties::numPostProcessingMemorySlices, DOC(dai, StereoDepthProperties, numPostProcessingMemorySlices)) - .def_readwrite("focalLengthFromCalibration", &StereoDepthProperties::focalLengthFromCalibration, DOC(dai, StereoDepthProperties, focalLengthFromCalibration)) - .def_readwrite("useHomographyRectification", &StereoDepthProperties::useHomographyRectification, DOC(dai, StereoDepthProperties, useHomographyRectification)) + .def_readwrite("numPostProcessingMemorySlices", + &StereoDepthProperties::numPostProcessingMemorySlices, + DOC(dai, StereoDepthProperties, numPostProcessingMemorySlices)) + .def_readwrite( + "focalLengthFromCalibration", &StereoDepthProperties::focalLengthFromCalibration, DOC(dai, StereoDepthProperties, focalLengthFromCalibration)) + .def_readwrite( + "useHomographyRectification", &StereoDepthProperties::useHomographyRectification, DOC(dai, StereoDepthProperties, useHomographyRectification)) .def_readwrite("baseline", &StereoDepthProperties::baseline, DOC(dai, StereoDepthProperties, baseline)) .def_readwrite("focalLength", &StereoDepthProperties::focalLength, DOC(dai, StereoDepthProperties, focalLength)) - .def_readwrite("disparityToDepthUseSpecTranslation", &StereoDepthProperties::disparityToDepthUseSpecTranslation, DOC(dai, StereoDepthProperties, disparityToDepthUseSpecTranslation)) - .def_readwrite("rectificationUseSpecTranslation", &StereoDepthProperties::rectificationUseSpecTranslation, DOC(dai, StereoDepthProperties, rectificationUseSpecTranslation)) - .def_readwrite("depthAlignmentUseSpecTranslation", &StereoDepthProperties::depthAlignmentUseSpecTranslation, DOC(dai, StereoDepthProperties, depthAlignmentUseSpecTranslation)) - .def_readwrite("alphaScaling", &StereoDepthProperties::alphaScaling, DOC(dai, StereoDepthProperties, alphaScaling)) - ; + .def_readwrite("disparityToDepthUseSpecTranslation", + &StereoDepthProperties::disparityToDepthUseSpecTranslation, + DOC(dai, StereoDepthProperties, disparityToDepthUseSpecTranslation)) + .def_readwrite("rectificationUseSpecTranslation", + &StereoDepthProperties::rectificationUseSpecTranslation, + DOC(dai, StereoDepthProperties, rectificationUseSpecTranslation)) + .def_readwrite("depthAlignmentUseSpecTranslation", + &StereoDepthProperties::depthAlignmentUseSpecTranslation, + DOC(dai, StereoDepthProperties, depthAlignmentUseSpecTranslation)) + .def_readwrite("alphaScaling", &StereoDepthProperties::alphaScaling, DOC(dai, StereoDepthProperties, alphaScaling)); stereoDepthPresetMode .value("HIGH_ACCURACY", StereoDepth::PresetMode::HIGH_ACCURACY, "**Deprecated:** Will be removed in future releases and replaced with DEFAULT") @@ -73,37 +82,39 @@ void bind_stereodepth(pybind11::module& m, void* pCallstack){ .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_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; - }) + .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 stereoDepth .def(py::init([](Node::Output& left, Node::Output& right, StereoDepth::PresetMode presetMode) { - auto self = getImplicitPipeline()->create(); - self->build(left, right, presetMode); - return self; - }), + auto self = getImplicitPipeline()->create(); + self->build(left, right, presetMode); + return self; + }), py::arg("left"), py::arg("right"), - py::arg("presetMode") = StereoDepth::PresetMode::HIGH_DENSITY - ) + py::arg("presetMode") = StereoDepth::PresetMode::HIGH_DENSITY) .def(py::init([](bool autoCreateCameras, StereoDepth::PresetMode presetMode) { - auto self = getImplicitPipeline()->create(); - self->build(autoCreateCameras, presetMode); - return self; - }), + auto self = getImplicitPipeline()->create(); + self->build(autoCreateCameras, presetMode); + return self; + }), py::arg("autoCreateCameras"), - py::arg("presetMode") = StereoDepth::PresetMode::HIGH_DENSITY - ) + py::arg("presetMode") = StereoDepth::PresetMode::HIGH_DENSITY) .def("build", static_cast (StereoDepth::*)(Node::Output&, Node::Output&, StereoDepth::PresetMode)>(&StereoDepth::build), py::arg("left"), @@ -277,7 +288,4 @@ void bind_stereodepth(pybind11::module& m, void* pCallstack){ .def("setAlphaScaling", &StereoDepth::setAlphaScaling, DOC(dai, node, StereoDepth, setAlphaScaling)); // ALIAS daiNodeModule.attr("StereoDepth").attr("Properties") = stereoDepthProperties; - - - } diff --git a/bindings/python/src/pipeline/node/SyncBindings.cpp b/bindings/python/src/pipeline/node/SyncBindings.cpp index 7443d556d..e7c20601e 100644 --- a/bindings/python/src/pipeline/node/SyncBindings.cpp +++ b/bindings/python/src/pipeline/node/SyncBindings.cpp @@ -1,13 +1,11 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/properties/SyncProperties.hpp" -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/Sync.hpp" +#include "depthai/properties/SyncProperties.hpp" -void bind_sync(pybind11::module& m, void* pCallstack){ - +void bind_sync(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -19,7 +17,7 @@ void bind_sync(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -29,10 +27,7 @@ void bind_sync(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - syncProperties - .def_readwrite("syncThresholdNs", &SyncProperties::syncThresholdNs) - .def_readwrite("syncAttempts", &SyncProperties::syncAttempts) - ; + syncProperties.def_readwrite("syncThresholdNs", &SyncProperties::syncThresholdNs).def_readwrite("syncAttempts", &SyncProperties::syncAttempts); // Node sync.def_readonly("out", &Sync::out, DOC(dai, node, Sync, out)) @@ -42,8 +37,6 @@ void bind_sync(pybind11::module& m, void* pCallstack){ .def("getSyncThreshold", &Sync::getSyncThreshold, DOC(dai, node, Sync, getSyncThreshold)) .def("getSyncAttempts", &Sync::getSyncAttempts, DOC(dai, node, Sync, getSyncAttempts)) .def("setRunOnHost", &Sync::setRunOnHost, py::arg("runOnHost"), DOC(dai, node, Sync, setRunOnHost)) - .def("runOnHost", &Sync::runOnHost, DOC(dai, node, Sync, runOnHost)) - ; + .def("runOnHost", &Sync::runOnHost, DOC(dai, node, Sync, runOnHost)); daiNodeModule.attr("Sync").attr("Properties") = syncProperties; - } diff --git a/bindings/python/src/pipeline/node/SystemLoggerBindings.cpp b/bindings/python/src/pipeline/node/SystemLoggerBindings.cpp index 55ad38b44..f6d128ee2 100644 --- a/bindings/python/src/pipeline/node/SystemLoggerBindings.cpp +++ b/bindings/python/src/pipeline/node/SystemLoggerBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/SystemLogger.hpp" -void bind_systemlogger(pybind11::module& m, void* pCallstack){ - +void bind_systemlogger(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -14,12 +12,11 @@ void bind_systemlogger(pybind11::module& m, void* pCallstack){ py::class_ systemLoggerProperties(m, "SystemLoggerProperties", DOC(dai, SystemLoggerProperties)); auto systemLogger = ADD_NODE(SystemLogger); - /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -29,16 +26,10 @@ void bind_systemlogger(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - systemLoggerProperties - .def_readwrite("rateHz", &SystemLoggerProperties::rateHz) - ; + systemLoggerProperties.def_readwrite("rateHz", &SystemLoggerProperties::rateHz); // Node - systemLogger - .def_readonly("out", &SystemLogger::out, DOC(dai, node, SystemLogger, out)) + systemLogger.def_readonly("out", &SystemLogger::out, DOC(dai, node, SystemLogger, out)) .def("setRate", &SystemLogger::setRate, py::arg("hz"), DOC(dai, node, SystemLogger, setRate)) - .def("getRate", &SystemLogger::getRate, DOC(dai, node, SystemLogger, getRate)) - ; - - + .def("getRate", &SystemLogger::getRate, DOC(dai, node, SystemLogger, getRate)); } diff --git a/bindings/python/src/pipeline/node/ThermalBindings.cpp b/bindings/python/src/pipeline/node/ThermalBindings.cpp index bedee43cc..e2b9d7c32 100644 --- a/bindings/python/src/pipeline/node/ThermalBindings.cpp +++ b/bindings/python/src/pipeline/node/ThermalBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/Thermal.hpp" -void bind_thermal(pybind11::module& m, void* pCallstack){ - +void bind_thermal(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; using namespace pybind11::literals; @@ -19,7 +17,7 @@ void bind_thermal(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -29,24 +27,19 @@ void bind_thermal(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - ThermalProperties - .def_readwrite("initialConfig", &ThermalProperties::initialConfig, DOC(dai, ThermalProperties, initialConfig)) + ThermalProperties.def_readwrite("initialConfig", &ThermalProperties::initialConfig, DOC(dai, ThermalProperties, initialConfig)) .def_readwrite("numFramesPool", &ThermalProperties::numFramesPool, DOC(dai, ThermalProperties, numFramesPool)) .def_readwrite("boardSocket", &ThermalProperties::boardSocket, DOC(dai, ThermalProperties, boardSocket)) - .def_readwrite("fps", &ThermalProperties::fps, DOC(dai, ThermalProperties, fps)) - ; + .def_readwrite("fps", &ThermalProperties::fps, DOC(dai, ThermalProperties, fps)); // Node - thermal - .def_readonly("initialConfig", &Thermal::initialConfig, DOC(dai, node, Thermal, initialConfig), DOC(dai, node, Thermal, initialConfig)) + thermal.def_readonly("initialConfig", &Thermal::initialConfig, DOC(dai, node, Thermal, initialConfig), DOC(dai, node, Thermal, initialConfig)) .def_readonly("inputConfig", &Thermal::inputConfig, DOC(dai, node, Thermal, inputConfig), DOC(dai, node, Thermal, inputConfig)) .def_readonly("temperature", &Thermal::temperature, DOC(dai, node, Thermal, temperature), DOC(dai, node, Thermal, temperature)) .def_readonly("color", &Thermal::color, DOC(dai, node, Thermal, color), DOC(dai, node, Thermal, color)) .def("build", &Thermal::build, "boardSocket"_a = CameraBoardSocket::AUTO, "fps"_a = float(25), DOC(dai, node, Thermal, build)) - .def("getBoardSocket", &Thermal::getBoardSocket, DOC(dai, node, Thermal, getBoardSocket)) - ; + .def("getBoardSocket", &Thermal::getBoardSocket, DOC(dai, node, Thermal, getBoardSocket)); // ALIAS daiNodeModule.attr("Thermal").attr("Properties") = ThermalProperties; - } diff --git a/bindings/python/src/pipeline/node/ToFBindings.cpp b/bindings/python/src/pipeline/node/ToFBindings.cpp index c30be7aeb..12599e677 100644 --- a/bindings/python/src/pipeline/node/ToFBindings.cpp +++ b/bindings/python/src/pipeline/node/ToFBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/ToF.hpp" -void bind_tof(pybind11::module& m, void* pCallstack){ - +void bind_tof(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; using namespace pybind11::literals; @@ -19,7 +17,7 @@ void bind_tof(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -29,16 +27,13 @@ void bind_tof(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - tofProperties - .def_readwrite("initialConfig", &ToFProperties::initialConfig, DOC(dai, ToFProperties, initialConfig)) + tofProperties.def_readwrite("initialConfig", &ToFProperties::initialConfig, DOC(dai, ToFProperties, initialConfig)) .def_readwrite("numFramesPool", &ToFProperties::numFramesPool, DOC(dai, ToFProperties, numFramesPool)) .def_readwrite("numShaves", &ToFProperties::numShaves, DOC(dai, ToFProperties, numShaves)) - .def_readwrite("warpHwIds", &ToFProperties::warpHwIds, DOC(dai, ToFProperties, warpHwIds)) - ; + .def_readwrite("warpHwIds", &ToFProperties::warpHwIds, DOC(dai, ToFProperties, warpHwIds)); // Node - tof - .def_readonly("inputConfig", &ToF::inputConfig, DOC(dai, node, ToF, inputConfig), DOC(dai, node, ToF, inputConfig)) + tof.def_readonly("inputConfig", &ToF::inputConfig, DOC(dai, node, ToF, inputConfig), DOC(dai, node, ToF, inputConfig)) .def_readonly("depth", &ToF::depth, DOC(dai, node, ToF, depth), DOC(dai, node, ToF, depth)) .def_readonly("amplitude", &ToF::amplitude, DOC(dai, node, ToF, amplitude), DOC(dai, node, ToF, amplitude)) .def_readonly("intensity", &ToF::intensity, DOC(dai, node, ToF, intensity), DOC(dai, node, ToF, intensity)) @@ -49,8 +44,7 @@ void bind_tof(pybind11::module& m, void* pCallstack){ .def("getBoardSocket", &ToF::getBoardSocket, DOC(dai, node, ToF, getBoardSocket)) // .def("setNumShaves", &ToF::setNumShaves, DOC(dai, node, ToF, setNumShaves)) // .def("setNumFramesPool", &ToF::setNumFramesPool, DOC(dai, node, ToF, setNumFramesPool)) - ; + ; // ALIAS daiNodeModule.attr("ToF").attr("Properties") = tofProperties; - } diff --git a/bindings/python/src/pipeline/node/UVCBindings.cpp b/bindings/python/src/pipeline/node/UVCBindings.cpp index 81f180658..89e5bb037 100644 --- a/bindings/python/src/pipeline/node/UVCBindings.cpp +++ b/bindings/python/src/pipeline/node/UVCBindings.cpp @@ -1,13 +1,11 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/UVC.hpp" -void bind_uvc(pybind11::module& m, void* pCallstack){ - +void bind_uvc(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -19,7 +17,7 @@ void bind_uvc(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -29,22 +27,16 @@ void bind_uvc(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - uvcProperties - .def_readwrite("gpioInit", &UVCProperties::gpioInit) + uvcProperties.def_readwrite("gpioInit", &UVCProperties::gpioInit) .def_readwrite("gpioStreamOn", &UVCProperties::gpioStreamOn) - .def_readwrite("gpioStreamOff", &UVCProperties::gpioStreamOff) - ; + .def_readwrite("gpioStreamOff", &UVCProperties::gpioStreamOff); // UVC node - uvc - .def_readonly("input", &UVC::input, DOC(dai, node, UVC, input)) + uvc.def_readonly("input", &UVC::input, DOC(dai, node, UVC, input)) .def("setGpiosOnInit", &UVC::setGpiosOnInit, py::arg("list"), DOC(dai, node, UVC, setGpiosOnInit)) .def("setGpiosOnStreamOn", &UVC::setGpiosOnStreamOn, py::arg("list"), DOC(dai, node, UVC, setGpiosOnStreamOn)) - .def("setGpiosOnStreamOff", &UVC::setGpiosOnStreamOff, py::arg("list"), DOC(dai, node, UVC, setGpiosOnStreamOff)) - ; + .def("setGpiosOnStreamOff", &UVC::setGpiosOnStreamOff, py::arg("list"), DOC(dai, node, UVC, setGpiosOnStreamOff)); // ALIAS daiNodeModule.attr("UVC").attr("Properties") = uvcProperties; - } - diff --git a/bindings/python/src/pipeline/node/VideoEncoderBindings.cpp b/bindings/python/src/pipeline/node/VideoEncoderBindings.cpp index 28f6dce4b..8f5016c5a 100644 --- a/bindings/python/src/pipeline/node/VideoEncoderBindings.cpp +++ b/bindings/python/src/pipeline/node/VideoEncoderBindings.cpp @@ -1,26 +1,25 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/VideoEncoder.hpp" -void bind_videoencoder(pybind11::module& m, void* pCallstack){ - +void bind_videoencoder(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; // Node and Properties declare upfront py::class_ videoEncoderProperties(m, "VideoEncoderProperties", DOC(dai, VideoEncoderProperties)); py::enum_ videoEncoderPropertiesProfile(videoEncoderProperties, "Profile", DOC(dai, VideoEncoderProperties, Profile)); - py::enum_ videoEncoderPropertiesProfileRateControlMode(videoEncoderProperties, "RateControlMode", DOC(dai, VideoEncoderProperties, RateControlMode)); + py::enum_ videoEncoderPropertiesProfileRateControlMode( + videoEncoderProperties, "RateControlMode", DOC(dai, VideoEncoderProperties, RateControlMode)); auto videoEncoder = ADD_NODE(VideoEncoder); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -30,21 +29,16 @@ void bind_videoencoder(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - videoEncoderPropertiesProfile - .value("H264_BASELINE", VideoEncoderProperties::Profile::H264_BASELINE) + videoEncoderPropertiesProfile.value("H264_BASELINE", VideoEncoderProperties::Profile::H264_BASELINE) .value("H264_HIGH", VideoEncoderProperties::Profile::H264_HIGH) .value("H264_MAIN", VideoEncoderProperties::Profile::H264_MAIN) .value("H265_MAIN", VideoEncoderProperties::Profile::H265_MAIN) - .value("MJPEG", VideoEncoderProperties::Profile::MJPEG) - ; + .value("MJPEG", VideoEncoderProperties::Profile::MJPEG); - videoEncoderPropertiesProfileRateControlMode - .value("CBR", VideoEncoderProperties::RateControlMode::CBR) - .value("VBR", VideoEncoderProperties::RateControlMode::VBR) - ; + videoEncoderPropertiesProfileRateControlMode.value("CBR", VideoEncoderProperties::RateControlMode::CBR) + .value("VBR", VideoEncoderProperties::RateControlMode::VBR); - videoEncoderProperties - .def_readwrite("bitrate", &VideoEncoderProperties::bitrate) + videoEncoderProperties.def_readwrite("bitrate", &VideoEncoderProperties::bitrate) .def_readwrite("keyframeFrequency", &VideoEncoderProperties::keyframeFrequency) .def_readwrite("maxBitrate", &VideoEncoderProperties::maxBitrate) .def_readwrite("numBFrames", &VideoEncoderProperties::numBFrames) @@ -52,92 +46,97 @@ void bind_videoencoder(pybind11::module& m, void* pCallstack){ .def_readwrite("profile", &VideoEncoderProperties::profile) .def_readwrite("quality", &VideoEncoderProperties::quality) .def_readwrite("rateCtrlMode", &VideoEncoderProperties::rateCtrlMode) - .def_readwrite("outputFrameSize", &VideoEncoderProperties::outputFrameSize) - ; + .def_readwrite("outputFrameSize", &VideoEncoderProperties::outputFrameSize); // Node videoEncoder -#define VIDEO_ENCODER_BUILD_ARGS \ - Node::Output& input -#define VIDEO_ENCODER_BUILD_PYARGS \ - py::arg("input") -#define VIDEO_ENCODER_ARGS \ - float bitrate, \ - float frameRate, \ - VideoEncoderProperties::Profile profile, \ - int keyframeFrequency, \ - bool lossless, \ - int quality -#define VIDEO_ENCODER_PYARGS \ - py::arg("bitrate") = VideoEncoderProperties().bitrate, \ - py::arg("frameRate") = VideoEncoderProperties().frameRate, \ - py::arg("profile") = VideoEncoderProperties().profile, \ - py::arg("keyframeFrequency") = VideoEncoderProperties().keyframeFrequency, \ - py::arg("lossless") = VideoEncoderProperties().lossless, \ - py::arg("quality") = VideoEncoderProperties().quality - // TODO (Zimamazim) Automatically fetch default arguments to avoid duplicity -#define VIDEO_ENCODER_CODE(OP) \ - self OP setBitrate(bitrate);\ - self OP setFrameRate(frameRate); \ - self OP setProfile(profile); \ - self OP setKeyframeFrequency(keyframeFrequency); \ - self OP setLossless(lossless); \ - self OP setQuality(quality); - .def("build", [](VideoEncoder &self, - VIDEO_ENCODER_BUILD_ARGS, - VIDEO_ENCODER_ARGS) { +#define VIDEO_ENCODER_BUILD_ARGS Node::Output& input +#define VIDEO_ENCODER_BUILD_PYARGS py::arg("input") +#define VIDEO_ENCODER_ARGS float bitrate, float frameRate, VideoEncoderProperties::Profile profile, int keyframeFrequency, bool lossless, int quality +#define VIDEO_ENCODER_PYARGS \ + py::arg("bitrate") = VideoEncoderProperties().bitrate, py::arg("frameRate") = VideoEncoderProperties().frameRate, \ + py::arg("profile") = VideoEncoderProperties().profile, py::arg("keyframeFrequency") = VideoEncoderProperties().keyframeFrequency, \ + py::arg("lossless") = VideoEncoderProperties().lossless, py::arg("quality") = VideoEncoderProperties().quality + // TODO (Zimamazim) Automatically fetch default arguments to avoid duplicity +#define VIDEO_ENCODER_CODE(OP) \ + self OP setBitrate(bitrate); \ + self OP setFrameRate(frameRate); \ + self OP setProfile(profile); \ + self OP setKeyframeFrequency(keyframeFrequency); \ + self OP setLossless(lossless); \ + self OP setQuality(quality); + .def( + "build", + [](VideoEncoder& self, VIDEO_ENCODER_BUILD_ARGS, VIDEO_ENCODER_ARGS) { self.build(input); VIDEO_ENCODER_CODE(.) return std::static_pointer_cast(self.shared_from_this()); }, VIDEO_ENCODER_BUILD_PYARGS, - VIDEO_ENCODER_PYARGS - ) - .def(py::init([](VIDEO_ENCODER_BUILD_ARGS, VIDEO_ENCODER_ARGS){ - auto self = getImplicitPipeline()->create(); - self->build(input); - VIDEO_ENCODER_CODE(->) - return self; - }), - VIDEO_ENCODER_BUILD_PYARGS, - VIDEO_ENCODER_PYARGS - ) + VIDEO_ENCODER_PYARGS) + .def(py::init([](VIDEO_ENCODER_BUILD_ARGS, VIDEO_ENCODER_ARGS) { + auto self = getImplicitPipeline()->create(); + self->build(input); + VIDEO_ENCODER_CODE(->) + return self; + }), + VIDEO_ENCODER_BUILD_PYARGS, + VIDEO_ENCODER_PYARGS) .def_readonly("input", &VideoEncoder::input, DOC(dai, node, VideoEncoder, input), DOC(dai, node, VideoEncoder, input)) .def_readonly("bitstream", &VideoEncoder::bitstream, DOC(dai, node, VideoEncoder, bitstream), DOC(dai, node, VideoEncoder, bitstream)) .def_readonly("out", &VideoEncoder::out, DOC(dai, node, VideoEncoder, out), DOC(dai, node, VideoEncoder, out)) - .def("setDefaultProfilePreset", static_cast(&VideoEncoder::setDefaultProfilePreset), py::arg("fps"), py::arg("profile"), DOC(dai, node, VideoEncoder, setDefaultProfilePreset)) - .def("setDefaultProfilePreset", [](VideoEncoder& v, int width, int height, float fps, VideoEncoderProperties::Profile profile){ - PyErr_WarnEx(PyExc_DeprecationWarning, "Input width/height no longer needed, automatically determined from first frame", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - v.setDefaultProfilePreset(width, height, fps, profile); - HEDLEY_DIAGNOSTIC_POP - }, DOC(dai, node, VideoEncoder, setDefaultProfilePreset, 2)) - .def("setDefaultProfilePreset", [](VideoEncoder& v, std::tuple size, float fps, VideoEncoderProperties::Profile profile){ - PyErr_WarnEx(PyExc_DeprecationWarning, "Input size no longer needed, automatically determined from first frame", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - v.setDefaultProfilePreset(size, fps, profile); - HEDLEY_DIAGNOSTIC_POP - }, DOC(dai, node, VideoEncoder, setDefaultProfilePreset, 3)) + .def("setDefaultProfilePreset", + static_cast(&VideoEncoder::setDefaultProfilePreset), + py::arg("fps"), + py::arg("profile"), + DOC(dai, node, VideoEncoder, setDefaultProfilePreset)) + .def( + "setDefaultProfilePreset", + [](VideoEncoder& v, int width, int height, float fps, VideoEncoderProperties::Profile profile) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Input width/height no longer needed, automatically determined from first frame", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + v.setDefaultProfilePreset(width, height, fps, profile); + HEDLEY_DIAGNOSTIC_POP + }, + DOC(dai, node, VideoEncoder, setDefaultProfilePreset, 2)) + .def( + "setDefaultProfilePreset", + [](VideoEncoder& v, std::tuple size, float fps, VideoEncoderProperties::Profile profile) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Input size no longer needed, automatically determined from first frame", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + v.setDefaultProfilePreset(size, fps, profile); + HEDLEY_DIAGNOSTIC_POP + }, + DOC(dai, node, VideoEncoder, setDefaultProfilePreset, 3)) .def("setNumFramesPool", &VideoEncoder::setNumFramesPool, py::arg("frames"), DOC(dai, node, VideoEncoder, setNumFramesPool)) .def("getNumFramesPool", &VideoEncoder::getNumFramesPool, DOC(dai, node, VideoEncoder, getNumFramesPool)) .def("setRateControlMode", &VideoEncoder::setRateControlMode, py::arg("mode"), DOC(dai, node, VideoEncoder, setRateControlMode)) - .def("setProfile", static_cast(&VideoEncoder::setProfile), py::arg("profile"), DOC(dai, node, VideoEncoder, setProfile)) - .def("setProfile", [](VideoEncoder& v, std::tuple size, VideoEncoderProperties::Profile profile){ - PyErr_WarnEx(PyExc_DeprecationWarning, "Input width/height no longer needed, automatically determined from first frame", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - v.setProfile(size, profile); - HEDLEY_DIAGNOSTIC_POP - }, DOC(dai, node, VideoEncoder, setProfile, 2)) - .def("setProfile", [](VideoEncoder& v, int width, int height, VideoEncoderProperties::Profile profile){ - PyErr_WarnEx(PyExc_DeprecationWarning, "Input width/height no longer needed, automatically determined from first frame", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - v.setProfile(width, height, profile); - HEDLEY_DIAGNOSTIC_POP - }, DOC(dai, node, VideoEncoder, setProfile, 3)) + .def("setProfile", + static_cast(&VideoEncoder::setProfile), + py::arg("profile"), + DOC(dai, node, VideoEncoder, setProfile)) + .def( + "setProfile", + [](VideoEncoder& v, std::tuple size, VideoEncoderProperties::Profile profile) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Input width/height no longer needed, automatically determined from first frame", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + v.setProfile(size, profile); + HEDLEY_DIAGNOSTIC_POP + }, + DOC(dai, node, VideoEncoder, setProfile, 2)) + .def( + "setProfile", + [](VideoEncoder& v, int width, int height, VideoEncoderProperties::Profile profile) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Input width/height no longer needed, automatically determined from first frame", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + v.setProfile(width, height, profile); + HEDLEY_DIAGNOSTIC_POP + }, + DOC(dai, node, VideoEncoder, setProfile, 3)) .def("setBitrate", &VideoEncoder::setBitrate, py::arg("bitrate"), DOC(dai, node, VideoEncoder, setBitrate)) .def("setBitrateKbps", &VideoEncoder::setBitrateKbps, py::arg("bitrateKbps"), DOC(dai, node, VideoEncoder, setBitrateKbps)) .def("setKeyframeFrequency", &VideoEncoder::setKeyframeFrequency, py::arg("freq"), DOC(dai, node, VideoEncoder, setKeyframeFrequency)) @@ -155,32 +154,39 @@ void bind_videoencoder(pybind11::module& m, void* pCallstack){ //.def("getMaxBitrate", &VideoEncoder::getMaxBitrate) .def("getNumBFrames", &VideoEncoder::getNumBFrames, DOC(dai, node, VideoEncoder, getNumBFrames)) .def("getQuality", &VideoEncoder::getQuality, DOC(dai, node, VideoEncoder, getQuality)) - .def("getWidth", [](VideoEncoder& v){ - PyErr_WarnEx(PyExc_DeprecationWarning, "Input size no longer available, it's determined when first frame arrives", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - return v.getWidth(); - HEDLEY_DIAGNOSTIC_POP - }, DOC(dai, node, VideoEncoder, getWidth)) - .def("getHeight", [](VideoEncoder& v){ - PyErr_WarnEx(PyExc_DeprecationWarning, "Input size no longer available, it's determined when first frame arrives", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - return v.getHeight(); - HEDLEY_DIAGNOSTIC_POP - }, DOC(dai, node, VideoEncoder, getHeight)) - .def("getSize", [](VideoEncoder& v){ - PyErr_WarnEx(PyExc_DeprecationWarning, "Input size no longer available, it's determined when first frame arrives", 1); - HEDLEY_DIAGNOSTIC_PUSH - HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED - return v.getSize(); - HEDLEY_DIAGNOSTIC_POP - }, DOC(dai, node, VideoEncoder, getSize)) + .def( + "getWidth", + [](VideoEncoder& v) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Input size no longer available, it's determined when first frame arrives", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + return v.getWidth(); + HEDLEY_DIAGNOSTIC_POP + }, + DOC(dai, node, VideoEncoder, getWidth)) + .def( + "getHeight", + [](VideoEncoder& v) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Input size no longer available, it's determined when first frame arrives", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + return v.getHeight(); + HEDLEY_DIAGNOSTIC_POP + }, + DOC(dai, node, VideoEncoder, getHeight)) + .def( + "getSize", + [](VideoEncoder& v) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Input size no longer available, it's determined when first frame arrives", 1); + HEDLEY_DIAGNOSTIC_PUSH + HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + return v.getSize(); + HEDLEY_DIAGNOSTIC_POP + }, + DOC(dai, node, VideoEncoder, getSize)) .def("getFrameRate", &VideoEncoder::getFrameRate, DOC(dai, node, VideoEncoder, getFrameRate)) .def("getLossless", &VideoEncoder::getLossless, DOC(dai, node, VideoEncoder, getLossless)) - .def("getMaxOutputFrameSize", &VideoEncoder::getMaxOutputFrameSize, DOC(dai, node, VideoEncoder, getMaxOutputFrameSize)) - ; + .def("getMaxOutputFrameSize", &VideoEncoder::getMaxOutputFrameSize, DOC(dai, node, VideoEncoder, getMaxOutputFrameSize)); // ALIAS daiNodeModule.attr("VideoEncoder").attr("Properties") = videoEncoderProperties; - } diff --git a/bindings/python/src/pipeline/node/WarpBindings.cpp b/bindings/python/src/pipeline/node/WarpBindings.cpp index 4e090834e..7a7287e9d 100644 --- a/bindings/python/src/pipeline/node/WarpBindings.cpp +++ b/bindings/python/src/pipeline/node/WarpBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/Warp.hpp" -void bind_warp(pybind11::module& m, void* pCallstack){ - +void bind_warp(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -18,7 +16,7 @@ void bind_warp(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -37,8 +35,8 @@ void bind_warp(pybind11::module& m, void* pCallstack){ // .def_readonly("initialConfig", &Warp::initialConfig, DOC(dai, node, Warp, initialConfig)) // setters - .def("setOutputSize", py::overload_cast(&Warp::setOutputSize), DOC(dai, node, Warp, setOutputSize)) - .def("setOutputSize", py::overload_cast>(&Warp::setOutputSize), DOC(dai, node, Warp, setOutputSize, 2)) + .def("setOutputSize", py::overload_cast(&Warp::setOutputSize), DOC(dai, node, Warp, setOutputSize)) + .def("setOutputSize", py::overload_cast>(&Warp::setOutputSize), DOC(dai, node, Warp, setOutputSize, 2)) // .def("setOutputWidth", &Warp::setOutputWidth, DOC(dai, node, Warp, setOutputWidth)) // .def("setOutputHeight", &Warp::setOutputHeight, DOC(dai, node, Warp, setOutputHeight)) @@ -46,14 +44,12 @@ void bind_warp(pybind11::module& m, void* pCallstack){ .def("setMaxOutputFrameSize", &Warp::setMaxOutputFrameSize, DOC(dai, node, Warp, setMaxOutputFrameSize)) .def("setWarpMesh", py::overload_cast&, int, int>(&Warp::setWarpMesh), DOC(dai, node, Warp, setWarpMesh)) - .def("setWarpMesh", py::overload_cast>&, int, int>(&Warp::setWarpMesh), DOC(dai, node, Warp, setWarpMesh)) + .def("setWarpMesh", py::overload_cast>&, int, int>(&Warp::setWarpMesh), DOC(dai, node, Warp, setWarpMesh)) .def("setHwIds", &Warp::setHwIds, DOC(dai, node, Warp, setHwIds)) .def("getHwIds", &Warp::getHwIds, DOC(dai, node, Warp, getHwIds)) .def("setInterpolation", &Warp::setInterpolation, DOC(dai, node, Warp, setInterpolation)) - .def("getInterpolation", &Warp::getInterpolation, DOC(dai, node, Warp, getInterpolation)) - ; + .def("getInterpolation", &Warp::getInterpolation, DOC(dai, node, Warp, getInterpolation)); daiNodeModule.attr("Warp").attr("Properties") = warpProperties; - } diff --git a/bindings/python/src/pipeline/node/XLinkInBindings.cpp b/bindings/python/src/pipeline/node/XLinkInBindings.cpp index 58e30c632..9c7593c17 100644 --- a/bindings/python/src/pipeline/node/XLinkInBindings.cpp +++ b/bindings/python/src/pipeline/node/XLinkInBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/XLinkIn.hpp" -void bind_xlinkin(pybind11::module& m, void* pCallstack){ - +void bind_xlinkin(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -18,7 +16,7 @@ void bind_xlinkin(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -28,22 +26,17 @@ void bind_xlinkin(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - xlinkInProperties - .def_readwrite("streamName", &XLinkInProperties::streamName) + xlinkInProperties.def_readwrite("streamName", &XLinkInProperties::streamName) .def_readwrite("maxDataSize", &XLinkInProperties::maxDataSize) - .def_readwrite("numFrames", &XLinkInProperties::numFrames) - ; + .def_readwrite("numFrames", &XLinkInProperties::numFrames); // Node - xlinkIn - .def_readonly("out", &XLinkIn::out, DOC(dai, node, XLinkIn, out)) + xlinkIn.def_readonly("out", &XLinkIn::out, DOC(dai, node, XLinkIn, out)) .def("setStreamName", &XLinkIn::setStreamName, py::arg("streamName"), DOC(dai, node, XLinkIn, setStreamName)) .def("setMaxDataSize", &XLinkIn::setMaxDataSize, py::arg("maxDataSize"), DOC(dai, node, XLinkIn, setMaxDataSize)) - .def("setNumFrames", &XLinkIn::setNumFrames, py::arg("numFrames"), DOC(dai, node, XLinkIn, setNumFrames)) + .def("setNumFrames", &XLinkIn::setNumFrames, py::arg("numFrames"), DOC(dai, node, XLinkIn, setNumFrames)) .def("getStreamName", &XLinkIn::getStreamName, DOC(dai, node, XLinkIn, getStreamName)) .def("getMaxDataSize", &XLinkIn::getMaxDataSize, DOC(dai, node, XLinkIn, getMaxDataSize)) - .def("getNumFrames", &XLinkIn::getNumFrames, DOC(dai, node, XLinkIn, getNumFrames)) - ; + .def("getNumFrames", &XLinkIn::getNumFrames, DOC(dai, node, XLinkIn, getNumFrames)); daiNodeModule.attr("XLinkIn").attr("Properties") = xlinkInProperties; - } diff --git a/bindings/python/src/pipeline/node/XLinkOutBindings.cpp b/bindings/python/src/pipeline/node/XLinkOutBindings.cpp index d8a176904..c5727022d 100644 --- a/bindings/python/src/pipeline/node/XLinkOutBindings.cpp +++ b/bindings/python/src/pipeline/node/XLinkOutBindings.cpp @@ -1,12 +1,10 @@ -#include "NodeBindings.hpp" #include "Common.hpp" - -#include "depthai/pipeline/Pipeline.hpp" +#include "NodeBindings.hpp" #include "depthai/pipeline/Node.hpp" +#include "depthai/pipeline/Pipeline.hpp" #include "depthai/pipeline/node/XLinkOut.hpp" -void bind_xlinkout(pybind11::module& m, void* pCallstack){ - +void bind_xlinkout(pybind11::module& m, void* pCallstack) { using namespace dai; using namespace dai::node; @@ -18,7 +16,7 @@ void bind_xlinkout(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Call the rest of the type defines, then perform the actual bindings - Callstack* callstack = (Callstack*) pCallstack; + Callstack* callstack = (Callstack*)pCallstack; auto cb = callstack->top(); callstack->pop(); cb(m, pCallstack); @@ -28,22 +26,17 @@ void bind_xlinkout(pybind11::module& m, void* pCallstack){ /////////////////////////////////////////////////////////////////////// // Properties - xlinkOutProperties - .def_readwrite("maxFpsLimit", &XLinkOutProperties::maxFpsLimit) + xlinkOutProperties.def_readwrite("maxFpsLimit", &XLinkOutProperties::maxFpsLimit) .def_readwrite("streamName", &XLinkOutProperties::streamName) - .def_readwrite("metadataOnly", &XLinkOutProperties::metadataOnly) - ; + .def_readwrite("metadataOnly", &XLinkOutProperties::metadataOnly); // Node - xlinkOut - .def_readonly("input", &XLinkOut::input, DOC(dai, node, XLinkOut, input)) + xlinkOut.def_readonly("input", &XLinkOut::input, DOC(dai, node, XLinkOut, input)) .def("setStreamName", &XLinkOut::setStreamName, py::arg("streamName"), DOC(dai, node, XLinkOut, setStreamName)) .def("setFpsLimit", &XLinkOut::setFpsLimit, py::arg("fpsLimit"), DOC(dai, node, XLinkOut, setFpsLimit)) .def("getStreamName", &XLinkOut::getStreamName, DOC(dai, node, XLinkOut, getStreamName)) .def("getFpsLimit", &XLinkOut::getFpsLimit, DOC(dai, node, XLinkOut, getFpsLimit)) .def("setMetadataOnly", &XLinkOut::setMetadataOnly, DOC(dai, node, XLinkOut, setMetadataOnly)) - .def("getMetadataOnly", &XLinkOut::getMetadataOnly, DOC(dai, node, XLinkOut, getMetadataOnly)) - ; + .def("getMetadataOnly", &XLinkOut::getMetadataOnly, DOC(dai, node, XLinkOut, getMetadataOnly)); daiNodeModule.attr("XLinkOut").attr("Properties") = xlinkOutProperties; - } diff --git a/bindings/python/src/py_bindings.cpp b/bindings/python/src/py_bindings.cpp index c987679b0..332248cb6 100644 --- a/bindings/python/src/py_bindings.cpp +++ b/bindings/python/src/py_bindings.cpp @@ -14,36 +14,36 @@ #include "depthai/build/version.hpp" // project -#include "depthai/depthai.hpp" -#include "common/ModelTypeBindings.hpp" -#include "pipeline/AssetManagerBindings.hpp" -#include "pipeline/PipelineBindings.hpp" -#include "pipeline/CommonBindings.hpp" -#include "pipeline/node/NodeBindings.hpp" -#include "XLinkBindings.hpp" -#include "DeviceBindings.hpp" #include "CalibrationHandlerBindings.hpp" -#include "DeviceBootloaderBindings.hpp" #include "DatatypeBindings.hpp" +#include "DeviceBindings.hpp" +#include "DeviceBootloaderBindings.hpp" #include "MessageQueueBindings.hpp" -#include "openvino/OpenVINOBindings.hpp" -#include "nn_archive/NNArchiveBindings.hpp" -#include "log/LogBindings.hpp" #include "VersionBindings.hpp" +#include "XLinkBindings.hpp" #include "capabilities/CapabilityBindings.hpp" #include "capabilities/CapabilityRangeBindings.hpp" #include "capabilities/ImgFrameCapabilityBindings.hpp" +#include "common/ModelTypeBindings.hpp" +#include "depthai/depthai.hpp" +#include "log/LogBindings.hpp" #include "modelzoo/NNModelDescriptionBindings.hpp" #include "modelzoo/ZooBindings.hpp" -#include "utility/EventsManagerBindings.hpp" +#include "nn_archive/NNArchiveBindings.hpp" +#include "openvino/OpenVINOBindings.hpp" +#include "pipeline/AssetManagerBindings.hpp" +#include "pipeline/CommonBindings.hpp" +#include "pipeline/PipelineBindings.hpp" +#include "pipeline/node/NodeBindings.hpp" #include "remote_connection/RemoteConnectionBindings.hpp" +#include "utility/EventsManagerBindings.hpp" #ifdef DEPTHAI_HAVE_OPENCV_SUPPORT #include #endif #ifdef DEPTHAI_PYTHON_EMBEDDED_MODULE -#include -extern "C" void depthai_bindings_init() {} // to force inclusion + #include +extern "C" void depthai_bindings_init() {} // to force inclusion #endif // Specify module @@ -90,7 +90,7 @@ PYBIND11_MODULE(depthai, m) callstack.push_front(&EventsManagerBindings::bind); callstack.push_front(&RemoteConnectionBindings::bind); // end of the callstack - callstack.push_front([](py::module &, void *) {}); + callstack.push_front([](py::module&, void*) {}); Callstack callstackAdapter(callstack); @@ -102,18 +102,18 @@ PYBIND11_MODULE(depthai, m) constexpr static const char* signalHandlerKey = "DEPTHAI_INSTALL_SIGNAL_HANDLER"; try { auto sysModule = py::module_::import("sys"); - if(py::hasattr(sysModule, signalHandlerKey)){ + if(py::hasattr(sysModule, signalHandlerKey)) { installSignalHandler = installSignalHandler && sysModule.attr(signalHandlerKey).cast(); } - } catch (...) { + } catch(...) { // ignore } try { auto builtinsModule = py::module_::import("builtins"); - if(py::hasattr(builtinsModule, signalHandlerKey)){ + if(py::hasattr(builtinsModule, signalHandlerKey)) { installSignalHandler = installSignalHandler && builtinsModule.attr(signalHandlerKey).cast(); } - } catch (...){ + } catch(...) { // ignore } @@ -122,18 +122,18 @@ PYBIND11_MODULE(depthai, m) constexpr static const char* javavmEnvKey = "DEPTHAI_LIBUSB_ANDROID_JAVAVM"; try { auto sysModule = py::module_::import("sys"); - if(py::hasattr(sysModule, javavmEnvKey)){ + if(py::hasattr(sysModule, javavmEnvKey)) { javavmEnvStr = sysModule.attr(javavmEnvKey).cast(); } - } catch (...) { + } catch(...) { // ignore } try { auto builtinsModule = py::module_::import("builtins"); - if(py::hasattr(builtinsModule, javavmEnvKey)){ + if(py::hasattr(builtinsModule, javavmEnvKey)) { javavmEnvStr = builtinsModule.attr(javavmEnvKey).cast(); } - } catch (...){ + } catch(...) { // ignore } // JNIEnv handling @@ -148,9 +148,11 @@ PYBIND11_MODULE(depthai, m) // Call dai::initialize on 'import depthai' to initialize asap with additional information to print try { - dai::initialize(std::string("Python bindings - version: ") + DEPTHAI_PYTHON_VERSION + " from " + DEPTHAI_PYTHON_COMMIT_DATETIME + " build: " + DEPTHAI_PYTHON_BUILD_DATETIME, installSignalHandler, javavm); - } catch (const std::exception&) { + dai::initialize(std::string("Python bindings - version: ") + DEPTHAI_PYTHON_VERSION + " from " + DEPTHAI_PYTHON_COMMIT_DATETIME + + " build: " + DEPTHAI_PYTHON_BUILD_DATETIME, + installSignalHandler, + javavm); + } catch(const std::exception&) { // ignore, will be initialized later on if possible } - } diff --git a/bindings/python/src/pybind11_common.hpp b/bindings/python/src/pybind11_common.hpp index f235650e4..4876e3758 100644 --- a/bindings/python/src/pybind11_common.hpp +++ b/bindings/python/src/pybind11_common.hpp @@ -6,67 +6,68 @@ #endif #endif -#include -#include #include #include #include -#include +#include +#include + #include -#include #include +#include +#include #include // Include docstring file #include "docstring.hpp" -namespace pybind11 { namespace detail { - template <> struct type_caster { - public: +namespace pybind11 { +namespace detail { +template <> +struct type_caster { + public: + // This macro establishes the name 'dai::Path' in + // function signatures and declares a local variable + // 'value' of type dai::Path + PYBIND11_TYPE_CASTER(dai::Path, _("Path")); - // This macro establishes the name 'dai::Path' in - // function signatures and declares a local variable - // 'value' of type dai::Path - PYBIND11_TYPE_CASTER(dai::Path, _("Path")); - - // Conversion part 1 (Python->C++): convert a PyObject into a dai::Path - // instance or return false upon failure. The second argument - // indicates whether implicit conversions should be applied. - bool load(handle src, bool) { + // Conversion part 1 (Python->C++): convert a PyObject into a dai::Path + // instance or return false upon failure. The second argument + // indicates whether implicit conversions should be applied. + bool load(handle src, bool) { + try { + // Make sure only strings and paths are cast to dai::Path + // Instead of anything that can be represented as string + bool isPath = false; try { - // Make sure only strings and paths are cast to dai::Path - // Instead of anything that can be represented as string - bool isPath = false; - try{ - isPath = isinstance(src, module::import("pathlib").attr("PurePath")); - } catch (const std::exception&) { - //ignore - } - if(!isinstance(src) && !isPath) { - return false; - } - str pystr = static_cast(src); - value = dai::Path(static_cast(pystr)); - return true; - } catch (...) { + isPath = isinstance(src, module::import("pathlib").attr("PurePath")); + } catch(const std::exception&) { + // ignore + } + if(!isinstance(src) && !isPath) { return false; } + str pystr = static_cast(src); + value = dai::Path(static_cast(pystr)); + return true; + } catch(...) { + return false; } + } - // Conversion part 2 (C++ -> Python): convert an dai::Path instance into - // a Python (string) object. The second and third arguments are used to - // indicate the return value policy and parent object (for - // ``return_value_policy::reference_internal``) and are generally - // ignored by implicit casters. - static handle cast(dai::Path src, return_value_policy /* policy */, handle /* parent */) { - return str{src.u8string()}; - } - }; -}} // namespace pybind11::detail - + // Conversion part 2 (C++ -> Python): convert an dai::Path instance into + // a Python (string) object. The second and third arguments are used to + // indicate the return value policy and parent object (for + // ``return_value_policy::reference_internal``) and are generally + // ignored by implicit casters. + static handle cast(dai::Path src, return_value_policy /* policy */, handle /* parent */) { + return str{src.u8string()}; + } +}; +} // namespace detail +} // namespace pybind11 namespace py = pybind11; -using StackFunction = void (*)(pybind11::module &m, void *pCallstack); +using StackFunction = void (*)(pybind11::module& m, void* pCallstack); using Callstack = std::stack; - diff --git a/bindings/python/src/remote_connection/RemoteConnectionBindings.cpp b/bindings/python/src/remote_connection/RemoteConnectionBindings.cpp index a624a64e5..2124a42a5 100644 --- a/bindings/python/src/remote_connection/RemoteConnectionBindings.cpp +++ b/bindings/python/src/remote_connection/RemoteConnectionBindings.cpp @@ -5,8 +5,8 @@ #include #include -#include "depthai/remote_connection/RemoteConnection.hpp" #include "depthai/pipeline/InputQueue.hpp" +#include "depthai/remote_connection/RemoteConnection.hpp" void RemoteConnectionBindings::bind(pybind11::module& m, void* pCallstack) { using namespace dai; @@ -47,19 +47,19 @@ void RemoteConnectionBindings::bind(pybind11::module& m, void* pCallstack) { DOC(dai, RemoteConnection, addTopic)) .def("registerPipeline", &RemoteConnection::registerPipeline, py::arg("pipeline"), DOC(dai, RemoteConnection, registerPipeline)) .def("registerService", &RemoteConnection::registerService, py::arg("serviceName"), py::arg("callback"), DOC(dai, RemoteConnection, registerService)) - .def("waitKey", - &RemoteConnection::waitKey, - py::arg("delay"), - py::call_guard(), - DOC(dai, RemoteConnection, waitKey)); + .def("waitKey", &RemoteConnection::waitKey, py::arg("delay"), py::call_guard(), DOC(dai, RemoteConnection, waitKey)); #else - // Define a placeholder class for RemoteConnection + // Define a placeholder class for RemoteConnection struct RemoteConnectionPlaceholder { RemoteConnectionPlaceholder(const std::string& /*address*/, uint16_t /*port*/, bool /*serveFrontend*/, uint16_t /*httpPort*/) { throw std::runtime_error("Remote connection is not enabled in this build."); } }; - py::class_(m, "RemoteConnection") - .def(py::init(), py::arg("address") = "", py::arg("port") = 0, py::arg("serveFrontend") = true, py::arg("httpPort") = 0); + py::class_(m, "RemoteConnection") + .def(py::init(), + py::arg("address") = "", + py::arg("port") = 0, + py::arg("serveFrontend") = true, + py::arg("httpPort") = 0); #endif } \ No newline at end of file diff --git a/bindings/python/src/utility/EventsManagerBindings.cpp b/bindings/python/src/utility/EventsManagerBindings.cpp index 2fc4e6a05..19e3dfc20 100644 --- a/bindings/python/src/utility/EventsManagerBindings.cpp +++ b/bindings/python/src/utility/EventsManagerBindings.cpp @@ -2,7 +2,7 @@ // depthai #ifdef DEPTHAI_ENABLE_EVENTS_MANAGER -#include "depthai/utility/EventsManager.hpp" + #include "depthai/utility/EventsManager.hpp" #endif void EventsManagerBindings::bind(pybind11::module& m, void* pCallstack) { @@ -19,7 +19,7 @@ void EventsManagerBindings::bind(pybind11::module& m, void* pCallstack) { /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// - #ifdef DEPTHAI_ENABLE_EVENTS_MANAGER +#ifdef DEPTHAI_ENABLE_EVENTS_MANAGER using namespace dai::utility; py::class_>(m, "EventData") .def(py::init(), py::arg("data"), py::arg("fileName"), py::arg("mimeType")) @@ -70,5 +70,5 @@ void EventsManagerBindings::bind(pybind11::module& m, void* pCallstack) { py::arg("extraData") = std::unordered_map(), py::arg("deviceSerialNo") = "", DOC(dai, utility, EventsManager, sendSnap)); - #endif +#endif } diff --git a/bindings/python/src/utility/SpanBindings.hpp b/bindings/python/src/utility/SpanBindings.hpp index 859f1df31..5fa043990 100644 --- a/bindings/python/src/utility/SpanBindings.hpp +++ b/bindings/python/src/utility/SpanBindings.hpp @@ -10,161 +10,151 @@ namespace detail { template struct span_name_maker { - template - static constexpr auto make(const T &t) { - return concat(t, span_name_maker::make(t)); - } + template + static constexpr auto make(const T& t) { + return concat(t, span_name_maker::make(t)); + } }; template <> struct span_name_maker<1> { - template - static constexpr auto make(const T &t) { - return t; - } + template + static constexpr auto make(const T& t) { + return t; + } }; // span with fixed size converts to a tuple -template struct type_caster> { - using span_type = typename dai::span; - using value_conv = make_caster; - using value_type = typename std::remove_cv::type; - - value_type backing_array[Extent] = {}; - - PYBIND11_TYPE_CASTER(span_type, _("Tuple[") + span_name_maker::make(value_conv::name) + _("]")); - - type_caster() : value(backing_array) {} - - bool load(handle src, bool convert) { - if (!isinstance(src) || isinstance(src)) - return false; - auto s = reinterpret_borrow(src); - if (s.size() != Extent) - return false; - size_t i = 0; - for (auto it : s) { - value_conv conv; - if (!conv.load(it, convert)) - return false; - backing_array[i] = cast_op(std::move(conv)); - i++; +template +struct type_caster> { + using span_type = typename dai::span; + using value_conv = make_caster; + using value_type = typename std::remove_cv::type; + + value_type backing_array[Extent] = {}; + + PYBIND11_TYPE_CASTER(span_type, _("Tuple[") + span_name_maker::make(value_conv::name) + _("]")); + + type_caster() : value(backing_array) {} + + bool load(handle src, bool convert) { + if(!isinstance(src) || isinstance(src)) return false; + auto s = reinterpret_borrow(src); + if(s.size() != Extent) return false; + size_t i = 0; + for(auto it : s) { + value_conv conv; + if(!conv.load(it, convert)) return false; + backing_array[i] = cast_op(std::move(conv)); + i++; + } + return true; } - return true; - } - -public: - template - static handle cast(T &&src, return_value_policy policy, handle parent) { - if (!std::is_lvalue_reference::value) - policy = return_value_policy_override::policy(policy); - tuple l(Extent); - size_t index = 0; - for (auto &&value : src) { - auto value_ = reinterpret_steal( - value_conv::cast(forward_like(value), policy, parent)); - if (!value_) - return handle(); - PyTuple_SET_ITEM(l.ptr(), (ssize_t)index++, - value_.release().ptr()); // steals a reference + + public: + template + static handle cast(T&& src, return_value_policy policy, handle parent) { + if(!std::is_lvalue_reference::value) policy = return_value_policy_override::policy(policy); + tuple l(Extent); + size_t index = 0; + for(auto&& value : src) { + auto value_ = reinterpret_steal(value_conv::cast(forward_like(value), policy, parent)); + if(!value_) return handle(); + PyTuple_SET_ITEM(l.ptr(), (ssize_t)index++, + value_.release().ptr()); // steals a reference + } + return l.release(); } - return l.release(); - } }; - // span with dynamic extent -template struct type_caster> { - using span_type = typename dai::span; - using value_conv = make_caster; - using value_type = typename std::remove_cv::type; - PYBIND11_TYPE_CASTER(span_type, _("List[") + value_conv::name + _("]")); - - std::vector vec; - bool load(handle src, bool convert) { - if (!isinstance(src) || isinstance(src)) - return false; - auto s = reinterpret_borrow(src); - vec.reserve(s.size()); - for (auto it : s) { - value_conv conv; - if (!conv.load(it, convert)) - return false; - vec.push_back(cast_op(std::move(conv))); +template +struct type_caster> { + using span_type = typename dai::span; + using value_conv = make_caster; + using value_type = typename std::remove_cv::type; + PYBIND11_TYPE_CASTER(span_type, _("List[") + value_conv::name + _("]")); + + std::vector vec; + bool load(handle src, bool convert) { + if(!isinstance(src) || isinstance(src)) return false; + auto s = reinterpret_borrow(src); + vec.reserve(s.size()); + for(auto it : s) { + value_conv conv; + if(!conv.load(it, convert)) return false; + vec.push_back(cast_op(std::move(conv))); + } + value = span_type(vec.data(), vec.size()); + return true; } - value = span_type(vec.data(), vec.size()); - return true; - } - -public: - template - static handle cast(T &&src, return_value_policy policy, handle parent) { - if (!std::is_lvalue_reference::value) - policy = return_value_policy_override::policy(policy); - list l(src.size()); - size_t index = 0; - for (auto &&value : src) { - auto value_ = reinterpret_steal( - value_conv::cast(forward_like(value), policy, parent)); - if (!value_) - return handle(); - PyList_SET_ITEM(l.ptr(), (ssize_t)index++, - value_.release().ptr()); // steals a reference + + public: + template + static handle cast(T&& src, return_value_policy policy, handle parent) { + if(!std::is_lvalue_reference::value) policy = return_value_policy_override::policy(policy); + list l(src.size()); + size_t index = 0; + for(auto&& value : src) { + auto value_ = reinterpret_steal(value_conv::cast(forward_like(value), policy, parent)); + if(!value_) return handle(); + PyList_SET_ITEM(l.ptr(), (ssize_t)index++, + value_.release().ptr()); // steals a reference + } + return l.release(); } - return l.release(); - } }; // span specialization: accepts any readonly buffers -template <> struct type_caster> { - using span_type = typename dai::span; - PYBIND11_TYPE_CASTER(span_type, _("buffer")); - - bool load(handle src, bool convert) { - if (!isinstance(src)) - return false; - auto buf = reinterpret_borrow(src); - auto req = buf.request(); - if (req.ndim != 1) { - return false; +template <> +struct type_caster> { + using span_type = typename dai::span; + PYBIND11_TYPE_CASTER(span_type, _("buffer")); + + bool load(handle src, bool convert) { + if(!isinstance(src)) return false; + auto buf = reinterpret_borrow(src); + auto req = buf.request(); + if(req.ndim != 1) { + return false; + } + + value = span_type((const uint8_t*)req.ptr, req.size * req.itemsize); + return true; } - value = span_type((const uint8_t*)req.ptr, req.size*req.itemsize); - return true; - } - -public: - template - static handle cast(T &&src, return_value_policy policy, handle parent) { - return bytes((char*)src.data(), src.size()).release(); - } + public: + template + static handle cast(T&& src, return_value_policy policy, handle parent) { + return bytes((char*)src.data(), src.size()).release(); + } }; // span specialization: writeable buffer -template <> struct type_caster> { - using span_type = typename dai::span; - PYBIND11_TYPE_CASTER(dai::span, _("buffer")); - - bool load(handle src, bool convert) { - if (!isinstance(src)) - return false; - auto buf = reinterpret_borrow(src); - auto req = buf.request(true); // buffer must be writeable - if (req.ndim != 1) { - return false; +template <> +struct type_caster> { + using span_type = typename dai::span; + PYBIND11_TYPE_CASTER(dai::span, _("buffer")); + + bool load(handle src, bool convert) { + if(!isinstance(src)) return false; + auto buf = reinterpret_borrow(src); + auto req = buf.request(true); // buffer must be writeable + if(req.ndim != 1) { + return false; + } + + value = dai::span((uint8_t*)req.ptr, req.size * req.itemsize); + return true; } - value = dai::span((uint8_t*)req.ptr, req.size*req.itemsize); - return true; - } - -public: - template - static handle cast(T &&src, return_value_policy policy, handle parent) { - // TODO: should this be a memoryview instead? - return bytes((char*)src.data(), src.size()).release(); - } + public: + template + static handle cast(T&& src, return_value_policy policy, handle parent) { + // TODO: should this be a memoryview instead? + return bytes((char*)src.data(), src.size()).release(); + } }; -} // namespace detail -} // namespace pybind11 \ No newline at end of file +} // namespace detail +} // namespace pybind11 \ No newline at end of file diff --git a/src/device/DeviceLogger.hpp b/src/device/DeviceLogger.hpp index a7da18666..92f684327 100644 --- a/src/device/DeviceLogger.hpp +++ b/src/device/DeviceLogger.hpp @@ -7,21 +7,35 @@ namespace dai { class DeviceLogger : public spdlog::logger { using spdlog::logger::logger; -public: - void logMessage(const LogMessage& msg){ + public: + void logMessage(const LogMessage& msg) { // Convert LogMessage to spdlog::details::log_msg spdlog::details::log_msg log; // First get spdlogLevel spdlog::level::level_enum spdlogLevel = spdlog::level::warn; - switch (msg.level) { - case dai::LogLevel::TRACE: spdlogLevel = spdlog::level::trace; break; - case dai::LogLevel::DEBUG: spdlogLevel = spdlog::level::debug; break; - case dai::LogLevel::INFO: spdlogLevel = spdlog::level::info; break; - case dai::LogLevel::WARN: spdlogLevel = spdlog::level::warn; break; - case dai::LogLevel::ERR: spdlogLevel = spdlog::level::err; break; - case dai::LogLevel::CRITICAL: spdlogLevel = spdlog::level::critical; break; - case dai::LogLevel::OFF: spdlogLevel = spdlog::level::off; break; + switch(msg.level) { + case dai::LogLevel::TRACE: + spdlogLevel = spdlog::level::trace; + break; + case dai::LogLevel::DEBUG: + spdlogLevel = spdlog::level::debug; + break; + case dai::LogLevel::INFO: + spdlogLevel = spdlog::level::info; + break; + case dai::LogLevel::WARN: + spdlogLevel = spdlog::level::warn; + break; + case dai::LogLevel::ERR: + spdlogLevel = spdlog::level::err; + break; + case dai::LogLevel::CRITICAL: + spdlogLevel = spdlog::level::critical; + break; + case dai::LogLevel::OFF: + spdlogLevel = spdlog::level::off; + break; } // level log.level = spdlogLevel; @@ -29,17 +43,17 @@ class DeviceLogger : public spdlog::logger { // mimics regular "log" method bool logEnabled = should_log(log.level); bool tracebackEnabled = tracer_.enabled(); - if (!logEnabled && !tracebackEnabled) { + if(!logEnabled && !tracebackEnabled) { return; } - // Continue with other fields // logger name log.logger_name = msg.nodeIdName; // time - log.time = std::chrono::time_point(std::chrono::duration_cast(std::chrono::seconds(msg.time.sec) + std::chrono::nanoseconds(msg.time.nsec))); + log.time = std::chrono::time_point( + std::chrono::duration_cast(std::chrono::seconds(msg.time.sec) + std::chrono::nanoseconds(msg.time.nsec))); // color log.color_range_start = msg.colorRangeStart; @@ -50,9 +64,7 @@ class DeviceLogger : public spdlog::logger { // Call the internal log_it_ method log_it_(log, logEnabled, tracebackEnabled); - } - }; -} // namespace dai +} // namespace dai diff --git a/src/nn_archive/v1/Generators.hpp b/src/nn_archive/v1/Generators.hpp index 0a6f3a076..2fd2e7631 100644 --- a/src/nn_archive/v1/Generators.hpp +++ b/src/nn_archive/v1/Generators.hpp @@ -8,256 +8,313 @@ #pragma once -#include #include -#include "helper.hpp" +#include #include "depthai/nn_archive/v1/Config.hpp" -#include "depthai/nn_archive/v1/Model.hpp" -#include "depthai/nn_archive/v1/Output.hpp" -#include "depthai/nn_archive/v1/MetadataClass.hpp" -#include "depthai/nn_archive/v1/Input.hpp" -#include "depthai/nn_archive/v1/PreprocessingBlock.hpp" -#include "depthai/nn_archive/v1/InputType.hpp" #include "depthai/nn_archive/v1/DataType.hpp" #include "depthai/nn_archive/v1/Head.hpp" +#include "depthai/nn_archive/v1/Input.hpp" +#include "depthai/nn_archive/v1/InputType.hpp" #include "depthai/nn_archive/v1/Metadata.hpp" +#include "depthai/nn_archive/v1/MetadataClass.hpp" +#include "depthai/nn_archive/v1/Model.hpp" +#include "depthai/nn_archive/v1/Output.hpp" +#include "depthai/nn_archive/v1/PreprocessingBlock.hpp" +#include "helper.hpp" namespace dai { namespace nn_archive { namespace v1 { - void from_json(const json & j, Metadata & x); - void to_json(json & j, const Metadata & x); - - void from_json(const json & j, Head & x); - void to_json(json & j, const Head & x); - - void from_json(const json & j, PreprocessingBlock & x); - void to_json(json & j, const PreprocessingBlock & x); - - void from_json(const json & j, Input & x); - void to_json(json & j, const Input & x); - - void from_json(const json & j, MetadataClass & x); - void to_json(json & j, const MetadataClass & x); - - void from_json(const json & j, Output & x); - void to_json(json & j, const Output & x); - - void from_json(const json & j, Model & x); - void to_json(json & j, const Model & x); - - void from_json(const json & j, Config & x); - void to_json(json & j, const Config & x); - - void from_json(const json & j, DataType & x); - void to_json(json & j, const DataType & x); - - void from_json(const json & j, InputType & x); - void to_json(json & j, const InputType & x); - - inline void from_json(const json & j, Metadata& x) { - x.anchors = get_stack_optional>>>(j, "anchors"); - x.classes = get_stack_optional>(j, "classes"); - x.confThreshold = get_stack_optional(j, "conf_threshold"); - x.iouThreshold = get_stack_optional(j, "iou_threshold"); - x.maxDet = get_stack_optional(j, "max_det"); - x.nClasses = get_stack_optional(j, "n_classes"); - x.postprocessorPath = get_stack_optional(j, "postprocessor_path"); - x.isSoftmax = get_stack_optional(j, "is_softmax"); - x.boxesOutputs = get_stack_optional(j, "boxes_outputs"); - x.scoresOutputs = get_stack_optional(j, "scores_outputs"); - x.anglesOutputs = get_stack_optional>(j, "angles_outputs"); - x.keypointsOutputs = get_stack_optional>(j, "keypoints_outputs"); - x.maskOutputs = get_stack_optional>(j, "mask_outputs"); - x.nKeypoints = get_stack_optional(j, "n_keypoints"); - x.nPrototypes = get_stack_optional(j, "n_prototypes"); - x.protosOutputs = get_stack_optional(j, "protos_outputs"); - x.subtype = get_stack_optional(j, "subtype"); - x.yoloOutputs = get_stack_optional>(j, "yolo_outputs"); - x.extraParams = j; - } +void from_json(const json& j, Metadata& x); +void to_json(json& j, const Metadata& x); + +void from_json(const json& j, Head& x); +void to_json(json& j, const Head& x); + +void from_json(const json& j, PreprocessingBlock& x); +void to_json(json& j, const PreprocessingBlock& x); + +void from_json(const json& j, Input& x); +void to_json(json& j, const Input& x); + +void from_json(const json& j, MetadataClass& x); +void to_json(json& j, const MetadataClass& x); + +void from_json(const json& j, Output& x); +void to_json(json& j, const Output& x); + +void from_json(const json& j, Model& x); +void to_json(json& j, const Model& x); + +void from_json(const json& j, Config& x); +void to_json(json& j, const Config& x); + +void from_json(const json& j, DataType& x); +void to_json(json& j, const DataType& x); + +void from_json(const json& j, InputType& x); +void to_json(json& j, const InputType& x); + +inline void from_json(const json& j, Metadata& x) { + x.anchors = get_stack_optional>>>(j, "anchors"); + x.classes = get_stack_optional>(j, "classes"); + x.confThreshold = get_stack_optional(j, "conf_threshold"); + x.iouThreshold = get_stack_optional(j, "iou_threshold"); + x.maxDet = get_stack_optional(j, "max_det"); + x.nClasses = get_stack_optional(j, "n_classes"); + x.postprocessorPath = get_stack_optional(j, "postprocessor_path"); + x.isSoftmax = get_stack_optional(j, "is_softmax"); + x.boxesOutputs = get_stack_optional(j, "boxes_outputs"); + x.scoresOutputs = get_stack_optional(j, "scores_outputs"); + x.anglesOutputs = get_stack_optional>(j, "angles_outputs"); + x.keypointsOutputs = get_stack_optional>(j, "keypoints_outputs"); + x.maskOutputs = get_stack_optional>(j, "mask_outputs"); + x.nKeypoints = get_stack_optional(j, "n_keypoints"); + x.nPrototypes = get_stack_optional(j, "n_prototypes"); + x.protosOutputs = get_stack_optional(j, "protos_outputs"); + x.subtype = get_stack_optional(j, "subtype"); + x.yoloOutputs = get_stack_optional>(j, "yolo_outputs"); + x.extraParams = j; +} - inline void to_json(json & j, const Metadata & x) { - j = json::object(); - j["anchors"] = x.anchors; - j["classes"] = x.classes; - j["conf_threshold"] = x.confThreshold; - j["iou_threshold"] = x.iouThreshold; - j["max_det"] = x.maxDet; - j["n_classes"] = x.nClasses; - j["postprocessor_path"] = x.postprocessorPath; - j["is_softmax"] = x.isSoftmax; - j["boxes_outputs"] = x.boxesOutputs; - j["scores_outputs"] = x.scoresOutputs; - j["angles_outputs"] = x.anglesOutputs; - j["keypoints_outputs"] = x.keypointsOutputs; - j["mask_outputs"] = x.maskOutputs; - j["n_keypoints"] = x.nKeypoints; - j["n_prototypes"] = x.nPrototypes; - j["protos_outputs"] = x.protosOutputs; - j["subtype"] = x.subtype; - j["yolo_outputs"] = x.yoloOutputs; - } +inline void to_json(json& j, const Metadata& x) { + j = json::object(); + j["anchors"] = x.anchors; + j["classes"] = x.classes; + j["conf_threshold"] = x.confThreshold; + j["iou_threshold"] = x.iouThreshold; + j["max_det"] = x.maxDet; + j["n_classes"] = x.nClasses; + j["postprocessor_path"] = x.postprocessorPath; + j["is_softmax"] = x.isSoftmax; + j["boxes_outputs"] = x.boxesOutputs; + j["scores_outputs"] = x.scoresOutputs; + j["angles_outputs"] = x.anglesOutputs; + j["keypoints_outputs"] = x.keypointsOutputs; + j["mask_outputs"] = x.maskOutputs; + j["n_keypoints"] = x.nKeypoints; + j["n_prototypes"] = x.nPrototypes; + j["protos_outputs"] = x.protosOutputs; + j["subtype"] = x.subtype; + j["yolo_outputs"] = x.yoloOutputs; +} - inline void from_json(const json & j, Head& x) { - x.metadata = j.at("metadata").get(); - x.name = get_stack_optional(j, "name"); - x.outputs = get_stack_optional>(j, "outputs"); - x.parser = j.at("parser").get(); - } +inline void from_json(const json& j, Head& x) { + x.metadata = j.at("metadata").get(); + x.name = get_stack_optional(j, "name"); + x.outputs = get_stack_optional>(j, "outputs"); + x.parser = j.at("parser").get(); +} - inline void to_json(json & j, const Head & x) { - j = json::object(); - j["metadata"] = x.metadata; - j["name"] = x.name; - j["outputs"] = x.outputs; - j["parser"] = x.parser; - } +inline void to_json(json& j, const Head& x) { + j = json::object(); + j["metadata"] = x.metadata; + j["name"] = x.name; + j["outputs"] = x.outputs; + j["parser"] = x.parser; +} - inline void from_json(const json & j, PreprocessingBlock& x) { - x.daiType = get_stack_optional(j, "dai_type"); - x.interleavedToPlanar = get_stack_optional(j, "interleaved_to_planar"); - x.mean = get_stack_optional>(j, "mean"); - x.reverseChannels = get_stack_optional(j, "reverse_channels"); - x.scale = get_stack_optional>(j, "scale"); - } +inline void from_json(const json& j, PreprocessingBlock& x) { + x.daiType = get_stack_optional(j, "dai_type"); + x.interleavedToPlanar = get_stack_optional(j, "interleaved_to_planar"); + x.mean = get_stack_optional>(j, "mean"); + x.reverseChannels = get_stack_optional(j, "reverse_channels"); + x.scale = get_stack_optional>(j, "scale"); +} - inline void to_json(json & j, const PreprocessingBlock & x) { - j = json::object(); - j["dai_type"] = x.daiType; - j["interleaved_to_planar"] = x.interleavedToPlanar; - j["mean"] = x.mean; - j["reverse_channels"] = x.reverseChannels; - j["scale"] = x.scale; - } +inline void to_json(json& j, const PreprocessingBlock& x) { + j = json::object(); + j["dai_type"] = x.daiType; + j["interleaved_to_planar"] = x.interleavedToPlanar; + j["mean"] = x.mean; + j["reverse_channels"] = x.reverseChannels; + j["scale"] = x.scale; +} - inline void from_json(const json & j, Input& x) { - x.dtype = j.at("dtype").get(); - x.inputType = j.at("input_type").get(); - x.layout = get_stack_optional(j, "layout"); - x.name = j.at("name").get(); - x.preprocessing = j.at("preprocessing").get(); - x.shape = j.at("shape").get>(); - } +inline void from_json(const json& j, Input& x) { + x.dtype = j.at("dtype").get(); + x.inputType = j.at("input_type").get(); + x.layout = get_stack_optional(j, "layout"); + x.name = j.at("name").get(); + x.preprocessing = j.at("preprocessing").get(); + x.shape = j.at("shape").get>(); +} - inline void to_json(json & j, const Input & x) { - j = json::object(); - j["dtype"] = x.dtype; - j["input_type"] = x.inputType; - j["layout"] = x.layout; - j["name"] = x.name; - j["preprocessing"] = x.preprocessing; - j["shape"] = x.shape; - } +inline void to_json(json& j, const Input& x) { + j = json::object(); + j["dtype"] = x.dtype; + j["input_type"] = x.inputType; + j["layout"] = x.layout; + j["name"] = x.name; + j["preprocessing"] = x.preprocessing; + j["shape"] = x.shape; +} - inline void from_json(const json & j, MetadataClass& x) { - x.name = j.at("name").get(); - x.path = j.at("path").get(); - x.precision = get_stack_optional(j, "precision"); - } +inline void from_json(const json& j, MetadataClass& x) { + x.name = j.at("name").get(); + x.path = j.at("path").get(); + x.precision = get_stack_optional(j, "precision"); +} - inline void to_json(json & j, const MetadataClass & x) { - j = json::object(); - j["name"] = x.name; - j["path"] = x.path; - j["precision"] = x.precision; - } +inline void to_json(json& j, const MetadataClass& x) { + j = json::object(); + j["name"] = x.name; + j["path"] = x.path; + j["precision"] = x.precision; +} - inline void from_json(const json & j, Output& x) { - x.dtype = j.at("dtype").get(); - x.layout = get_stack_optional(j, "layout"); - x.name = j.at("name").get(); - x.shape = get_stack_optional>(j, "shape"); - } +inline void from_json(const json& j, Output& x) { + x.dtype = j.at("dtype").get(); + x.layout = get_stack_optional(j, "layout"); + x.name = j.at("name").get(); + x.shape = get_stack_optional>(j, "shape"); +} - inline void to_json(json & j, const Output & x) { - j = json::object(); - j["dtype"] = x.dtype; - j["layout"] = x.layout; - j["name"] = x.name; - j["shape"] = x.shape; - } +inline void to_json(json& j, const Output& x) { + j = json::object(); + j["dtype"] = x.dtype; + j["layout"] = x.layout; + j["name"] = x.name; + j["shape"] = x.shape; +} - inline void from_json(const json & j, Model& x) { - x.heads = get_stack_optional>(j, "heads"); - x.inputs = j.at("inputs").get>(); - x.metadata = j.at("metadata").get(); - x.outputs = j.at("outputs").get>(); - } +inline void from_json(const json& j, Model& x) { + x.heads = get_stack_optional>(j, "heads"); + x.inputs = j.at("inputs").get>(); + x.metadata = j.at("metadata").get(); + x.outputs = j.at("outputs").get>(); +} - inline void to_json(json & j, const Model & x) { - j = json::object(); - j["heads"] = x.heads; - j["inputs"] = x.inputs; - j["metadata"] = x.metadata; - j["outputs"] = x.outputs; - } +inline void to_json(json& j, const Model& x) { + j = json::object(); + j["heads"] = x.heads; + j["inputs"] = x.inputs; + j["metadata"] = x.metadata; + j["outputs"] = x.outputs; +} - inline void from_json(const json & j, Config& x) { - x.configVersion = get_stack_optional(j, "config_version"); - x.model = j.at("model").get(); - } +inline void from_json(const json& j, Config& x) { + x.configVersion = get_stack_optional(j, "config_version"); + x.model = j.at("model").get(); +} - inline void to_json(json & j, const Config & x) { - j = json::object(); - j["config_version"] = x.configVersion; - j["model"] = x.model; - } +inline void to_json(json& j, const Config& x) { + j = json::object(); + j["config_version"] = x.configVersion; + j["model"] = x.model; +} - inline void from_json(const json & j, DataType & x) { - if (j == "boolean") x = DataType::BOOLEAN; - else if (j == "float16") x = DataType::FLOAT16; - else if (j == "float32") x = DataType::FLOAT32; - else if (j == "float64") x = DataType::FLOAT64; - else if (j == "int16") x = DataType::INT16; - else if (j == "int32") x = DataType::INT32; - else if (j == "int4") x = DataType::INT4; - else if (j == "int64") x = DataType::INT64; - else if (j == "int8") x = DataType::INT8; - else if (j == "string") x = DataType::STRING; - else if (j == "uint16") x = DataType::UINT16; - else if (j == "uint32") x = DataType::UINT32; - else if (j == "uint4") x = DataType::UINT4; - else if (j == "uint64") x = DataType::UINT64; - else if (j == "uint8") x = DataType::UINT8; - else { throw std::runtime_error("Input JSON does not conform to schema!"); } +inline void from_json(const json& j, DataType& x) { + if(j == "boolean") + x = DataType::BOOLEAN; + else if(j == "float16") + x = DataType::FLOAT16; + else if(j == "float32") + x = DataType::FLOAT32; + else if(j == "float64") + x = DataType::FLOAT64; + else if(j == "int16") + x = DataType::INT16; + else if(j == "int32") + x = DataType::INT32; + else if(j == "int4") + x = DataType::INT4; + else if(j == "int64") + x = DataType::INT64; + else if(j == "int8") + x = DataType::INT8; + else if(j == "string") + x = DataType::STRING; + else if(j == "uint16") + x = DataType::UINT16; + else if(j == "uint32") + x = DataType::UINT32; + else if(j == "uint4") + x = DataType::UINT4; + else if(j == "uint64") + x = DataType::UINT64; + else if(j == "uint8") + x = DataType::UINT8; + else { + throw std::runtime_error("Input JSON does not conform to schema!"); } +} - inline void to_json(json & j, const DataType & x) { - switch (x) { - case DataType::BOOLEAN: j = "boolean"; break; - case DataType::FLOAT16: j = "float16"; break; - case DataType::FLOAT32: j = "float32"; break; - case DataType::FLOAT64: j = "float64"; break; - case DataType::INT16: j = "int16"; break; - case DataType::INT32: j = "int32"; break; - case DataType::INT4: j = "int4"; break; - case DataType::INT64: j = "int64"; break; - case DataType::INT8: j = "int8"; break; - case DataType::STRING: j = "string"; break; - case DataType::UINT16: j = "uint16"; break; - case DataType::UINT32: j = "uint32"; break; - case DataType::UINT4: j = "uint4"; break; - case DataType::UINT64: j = "uint64"; break; - case DataType::UINT8: j = "uint8"; break; - default: throw std::runtime_error("Unexpected value in enumeration \"[object Object]\": " + std::to_string(static_cast(x))); - } +inline void to_json(json& j, const DataType& x) { + switch(x) { + case DataType::BOOLEAN: + j = "boolean"; + break; + case DataType::FLOAT16: + j = "float16"; + break; + case DataType::FLOAT32: + j = "float32"; + break; + case DataType::FLOAT64: + j = "float64"; + break; + case DataType::INT16: + j = "int16"; + break; + case DataType::INT32: + j = "int32"; + break; + case DataType::INT4: + j = "int4"; + break; + case DataType::INT64: + j = "int64"; + break; + case DataType::INT8: + j = "int8"; + break; + case DataType::STRING: + j = "string"; + break; + case DataType::UINT16: + j = "uint16"; + break; + case DataType::UINT32: + j = "uint32"; + break; + case DataType::UINT4: + j = "uint4"; + break; + case DataType::UINT64: + j = "uint64"; + break; + case DataType::UINT8: + j = "uint8"; + break; + default: + throw std::runtime_error("Unexpected value in enumeration \"[object Object]\": " + std::to_string(static_cast(x))); } +} - inline void from_json(const json & j, InputType & x) { - if (j == "image") x = InputType::IMAGE; - else if (j == "raw") x = InputType::RAW; - else { throw std::runtime_error("Input JSON does not conform to schema!"); } +inline void from_json(const json& j, InputType& x) { + if(j == "image") + x = InputType::IMAGE; + else if(j == "raw") + x = InputType::RAW; + else { + throw std::runtime_error("Input JSON does not conform to schema!"); } +} - inline void to_json(json & j, const InputType & x) { - switch (x) { - case InputType::IMAGE: j = "image"; break; - case InputType::RAW: j = "raw"; break; - default: throw std::runtime_error("Unexpected value in enumeration \"[object Object]\": " + std::to_string(static_cast(x))); - } +inline void to_json(json& j, const InputType& x) { + switch(x) { + case InputType::IMAGE: + j = "image"; + break; + case InputType::RAW: + j = "raw"; + break; + default: + throw std::runtime_error("Unexpected value in enumeration \"[object Object]\": " + std::to_string(static_cast(x))); } } -} -} +} // namespace v1 +} // namespace nn_archive +} // namespace dai diff --git a/src/nn_archive/v1/helper.hpp b/src/nn_archive/v1/helper.hpp index bde1f9f50..59e50747a 100644 --- a/src/nn_archive/v1/helper.hpp +++ b/src/nn_archive/v1/helper.hpp @@ -8,78 +8,83 @@ #pragma once -#include "depthai/common/optional.hpp" - -#include #include - +#include #include +#include "depthai/common/optional.hpp" + namespace dai { namespace nn_archive { namespace v1 { - using nlohmann::json; +using nlohmann::json; - #ifndef NLOHMANN_UNTYPED_dai_nn_archive_v1_HELPER +#ifndef NLOHMANN_UNTYPED_dai_nn_archive_v1_HELPER #define NLOHMANN_UNTYPED_dai_nn_archive_v1_HELPER - inline json get_untyped(const json & j, const char * property) { - if (j.find(property) != j.end()) { - return j.at(property).get(); - } - return json(); +inline json get_untyped(const json& j, const char* property) { + if(j.find(property) != j.end()) { + return j.at(property).get(); } + return json(); +} - inline json get_untyped(const json & j, std::string property) { - return get_untyped(j, property.data()); - } - #endif +inline json get_untyped(const json& j, std::string property) { + return get_untyped(j, property.data()); +} +#endif - #ifndef NLOHMANN_OPTIONAL_dai_nn_archive_v1_HELPER +#ifndef NLOHMANN_OPTIONAL_dai_nn_archive_v1_HELPER #define NLOHMANN_OPTIONAL_dai_nn_archive_v1_HELPER - template - inline std::shared_ptr get_heap_optional(const json & j, const char * property) { - auto it = j.find(property); - if (it != j.end() && !it->is_null()) { - return j.at(property).get>(); - } - return std::shared_ptr(); - } - - template - inline std::shared_ptr get_heap_optional(const json & j, std::string property) { - return get_heap_optional(j, property.data()); - } - template - inline std::optional get_stack_optional(const json & j, const char * property) { - auto it = j.find(property); - if (it != j.end() && !it->is_null()) { - return j.at(property).get>(); - } - return std::optional(); +template +inline std::shared_ptr get_heap_optional(const json& j, const char* property) { + auto it = j.find(property); + if(it != j.end() && !it->is_null()) { + return j.at(property).get>(); } + return std::shared_ptr(); +} - template - inline std::optional get_stack_optional(const json & j, std::string property) { - return get_stack_optional(j, property.data()); - } - #endif +template +inline std::shared_ptr get_heap_optional(const json& j, std::string property) { + return get_heap_optional(j, property.data()); } +template +inline std::optional get_stack_optional(const json& j, const char* property) { + auto it = j.find(property); + if(it != j.end() && !it->is_null()) { + return j.at(property).get>(); + } + return std::optional(); } + +template +inline std::optional get_stack_optional(const json& j, std::string property) { + return get_stack_optional(j, property.data()); } +#endif +} // namespace v1 +} // namespace nn_archive +} // namespace dai #ifndef NLOHMANN_OPT_HELPER -#define NLOHMANN_OPT_HELPER + #define NLOHMANN_OPT_HELPER namespace nlohmann { - template - struct adl_serializer> { - static void to_json(json & j, const std::shared_ptr & opt) { - if (!opt) j = nullptr; else j = *opt; - } +template +struct adl_serializer> { + static void to_json(json& j, const std::shared_ptr& opt) { + if(!opt) + j = nullptr; + else + j = *opt; + } - static std::shared_ptr from_json(const json & j) { - if (j.is_null()) return std::make_shared(); else return std::make_shared(j.get()); - } - }; + static std::shared_ptr from_json(const json& j) { + if(j.is_null()) + return std::make_shared(); + else + return std::make_shared(j.get()); + } +}; -} +} // namespace nlohmann #endif diff --git a/src/openvino/BlobFormat.hpp b/src/openvino/BlobFormat.hpp index b7df25fa5..6f82ab442 100644 --- a/src/openvino/BlobFormat.hpp +++ b/src/openvino/BlobFormat.hpp @@ -7,16 +7,15 @@ #pragma once -#include #include +#include #ifdef _MSC_VER -# define VPU_PACKED(body) __pragma(pack(push, 1)) struct body __pragma(pack(pop)) + #define VPU_PACKED(body) __pragma(pack(push, 1)) struct body __pragma(pack(pop)) #elif defined(__GNUC__) -# define VPU_PACKED(body) struct __attribute__((packed)) body + #define VPU_PACKED(body) struct __attribute__((packed)) body #endif - namespace dai { // It is one of float NaN and prime number @@ -25,7 +24,7 @@ const uint32_t STAGE_BORDER_SYMBOL = 0x7f83ff19; const uint32_t EI_NIDENT = 16; VPU_PACKED(ElfN_Ehdr { - uint8_t e_ident[EI_NIDENT]; + uint8_t e_ident[EI_NIDENT]; uint16_t e_type; uint16_t e_machine; uint32_t e_version; @@ -70,4 +69,4 @@ VPU_PACKED(mv_stage_header { uint32_t numShaves; };) -} // namespace vpu +} // namespace dai diff --git a/src/openvino/BlobReader.hpp b/src/openvino/BlobReader.hpp index 18effa48a..1cf35b0b3 100644 --- a/src/openvino/BlobReader.hpp +++ b/src/openvino/BlobReader.hpp @@ -7,8 +7,8 @@ #pragma once -#include #include +#include #include "BlobFormat.hpp" #include "depthai/common/TensorInfo.hpp" @@ -16,27 +16,45 @@ namespace dai { class BlobReader { -public: + public: BlobReader() = default; void parse(const std::vector& blob); - const std::unordered_map& getNetworkInputs() const { return networkInputs; } - const std::unordered_map& getNetworkOutputs() const { return networkOutputs; } - - uint32_t getStageCount() const { return blobHeader.stages_count; } - - uint32_t getMagicNumber() const { return blobHeader.magic_number; } - - uint32_t getVersionMajor() const { return blobHeader.blob_ver_major; } - uint32_t getVersionMinor() const { return blobHeader.blob_ver_minor; } - - uint32_t getNumberOfShaves() const { return blobHeader.number_of_shaves; } - uint32_t getNumberOfSlices() const { return blobHeader.number_of_cmx_slices; } - - std::pair getHeader() const { return {pBlob, sizeof(ElfN_Ehdr) + sizeof(mv_blob_header)};} - -private: + const std::unordered_map& getNetworkInputs() const { + return networkInputs; + } + const std::unordered_map& getNetworkOutputs() const { + return networkOutputs; + } + + uint32_t getStageCount() const { + return blobHeader.stages_count; + } + + uint32_t getMagicNumber() const { + return blobHeader.magic_number; + } + + uint32_t getVersionMajor() const { + return blobHeader.blob_ver_major; + } + uint32_t getVersionMinor() const { + return blobHeader.blob_ver_minor; + } + + uint32_t getNumberOfShaves() const { + return blobHeader.number_of_shaves; + } + uint32_t getNumberOfSlices() const { + return blobHeader.number_of_cmx_slices; + } + + std::pair getHeader() const { + return {pBlob, sizeof(ElfN_Ehdr) + sizeof(mv_blob_header)}; + } + + private: const std::uint8_t* pBlob = nullptr; mv_blob_header blobHeader = {}; @@ -45,7 +63,6 @@ class BlobReader { std::unordered_map networkInputs; std::unordered_map networkOutputs; - }; } // namespace dai diff --git a/src/remote_connection/RemoteConnectionImpl.hpp b/src/remote_connection/RemoteConnectionImpl.hpp index dc8842acb..625e4a2a3 100644 --- a/src/remote_connection/RemoteConnectionImpl.hpp +++ b/src/remote_connection/RemoteConnectionImpl.hpp @@ -25,18 +25,19 @@ class RemoteConnectionImpl { ~RemoteConnectionImpl(); void addTopic(const std::string& topicName, Node::Output& output, const std::string& group, bool useVisualizationIfAvailable); - std::shared_ptr addTopic(const std::string& topicName, const std::string& group, unsigned int maxSize, bool blocking, bool useVisualizationIfAvailable); + std::shared_ptr addTopic( + const std::string& topicName, const std::string& group, unsigned int maxSize, bool blocking, bool useVisualizationIfAvailable); void registerPipeline(const Pipeline& pipeline); void registerService(const std::string& serviceName, std::function callback); int waitKey(int delayMs); private: - /** - * @brief Initialize websocket server - * @param address Address to bind to - * @param port Port to bind to - * @return True if successful, false otherwise - * + /** + * @brief Initialize websocket server + * @param address Address to bind to + * @param port Port to bind to + * @return True if successful, false otherwise + * */ bool initWebsocketServer(const std::string& address, uint16_t port); @@ -48,7 +49,10 @@ class RemoteConnectionImpl { */ bool initHttpServer(const std::string& address, uint16_t port); - void addPublishThread(const std::string& topicName, const std::shared_ptr& outputQueue, const std::string& group, bool useVisualizationIfAvailable); + void addPublishThread(const std::string& topicName, + const std::shared_ptr& outputQueue, + const std::string& group, + bool useVisualizationIfAvailable); void exposeTopicGroupsService(); void exposeKeyPressedService(); void exposePipelineService(const Pipeline& pipeline); diff --git a/src/utility/EepromDataParser.hpp b/src/utility/EepromDataParser.hpp index 95971d394..ab4000697 100644 --- a/src/utility/EepromDataParser.hpp +++ b/src/utility/EepromDataParser.hpp @@ -2,10 +2,8 @@ #include "depthai/common/EepromData.hpp" -namespace dai -{ -namespace utility -{ +namespace dai { +namespace utility { /// @brief Splits given string by delimiter /// @param s string to split @@ -25,5 +23,5 @@ std::string parseProductName(EepromData eeprom, EepromData eepromFactory = {}); /// @return string contaning device name or empty std::string parseDeviceName(EepromData eeprom, EepromData eepromFactory = {}); -} // namespace utility -} // namespace dai +} // namespace utility +} // namespace dai diff --git a/src/utility/Environment.hpp b/src/utility/Environment.hpp index 1ab7ce8e0..9868a6ff2 100644 --- a/src/utility/Environment.hpp +++ b/src/utility/Environment.hpp @@ -1,17 +1,15 @@ #pragma once -#include #include -namespace dai -{ -namespace utility -{ +#include + +namespace dai { +namespace utility { std::string getEnv(const std::string& var); std::string getEnv(const std::string& var, spdlog::logger& logger); std::vector splitList(const std::string& list, const std::string& delimiter); - -} // namespace utility -} // namespace dai +} // namespace utility +} // namespace dai diff --git a/src/utility/HolisticRecordReplay.hpp b/src/utility/HolisticRecordReplay.hpp index 12571606d..81fac9a64 100644 --- a/src/utility/HolisticRecordReplay.hpp +++ b/src/utility/HolisticRecordReplay.hpp @@ -11,7 +11,10 @@ namespace dai { namespace utility { #ifdef DEPTHAI_HAVE_OPENCV_SUPPORT -bool setupHolisticRecord(Pipeline& pipeline, const std::string& deviceId, RecordConfig& recordConfig, std::unordered_map& outFilenames); +bool setupHolisticRecord(Pipeline& pipeline, + const std::string& deviceId, + RecordConfig& recordConfig, + std::unordered_map& outFilenames); bool setupHolisticReplay(Pipeline& pipeline, std::string replayPath, const std::string& deviceId, diff --git a/src/utility/Logging.hpp b/src/utility/Logging.hpp index 29d50c3f9..cc0140855 100644 --- a/src/utility/Logging.hpp +++ b/src/utility/Logging.hpp @@ -1,15 +1,15 @@ #pragma once +#include #include -#include -#include #include -#include #include +#include +#include // libraries -#include #include +#include // shared #include @@ -19,6 +19,7 @@ #include #include #include + #include "Environment.hpp" namespace dai { @@ -28,7 +29,7 @@ class Logging { Logging(); ~Logging() {} -public: + public: static Logging& getInstance() { static Logging logging; return logging; @@ -41,112 +42,92 @@ class Logging { static spdlog::level::level_enum parseLevel(std::string lvl); }; +namespace logger { -namespace logger -{ - -inline spdlog::level::level_enum get_level() -{ +inline spdlog::level::level_enum get_level() { return Logging::getInstance().logger.level(); } -template -inline void log(spdlog::source_loc source, spdlog::level::level_enum lvl, const FormatString &fmt, Args&&...args) -{ +template +inline void log(spdlog::source_loc source, spdlog::level::level_enum lvl, const FormatString& fmt, Args&&... args) { Logging::getInstance().logger.log(source, lvl, fmt, std::forward(args)...); } -template -inline void log(spdlog::level::level_enum lvl, const FormatString &fmt, Args&&...args) -{ +template +inline void log(spdlog::level::level_enum lvl, const FormatString& fmt, Args&&... args) { Logging::getInstance().logger.log(spdlog::source_loc{}, lvl, fmt, std::forward(args)...); } -template -inline void trace(const FormatString &fmt, Args&&...args) -{ +template +inline void trace(const FormatString& fmt, Args&&... args) { Logging::getInstance().logger.trace(fmt, std::forward(args)...); } -template -inline void debug(const FormatString &fmt, Args&&...args) -{ +template +inline void debug(const FormatString& fmt, Args&&... args) { Logging::getInstance().logger.debug(fmt, std::forward(args)...); } -template -inline void info(const FormatString &fmt, Args&&...args) -{ +template +inline void info(const FormatString& fmt, Args&&... args) { Logging::getInstance().logger.info(fmt, std::forward(args)...); } -template -inline void warn(const FormatString &fmt, Args&&...args) -{ +template +inline void warn(const FormatString& fmt, Args&&... args) { Logging::getInstance().logger.warn(fmt, std::forward(args)...); } -template -inline void error(const FormatString &fmt, Args&&...args) -{ +template +inline void error(const FormatString& fmt, Args&&... args) { Logging::getInstance().logger.error(fmt, std::forward(args)...); } -template -inline void critical(const FormatString &fmt, Args&&...args) -{ +template +inline void critical(const FormatString& fmt, Args&&... args) { Logging::getInstance().logger.critical(fmt, std::forward(args)...); } -template -inline void log(spdlog::source_loc source, spdlog::level::level_enum lvl, const T &msg) -{ +template +inline void log(spdlog::source_loc source, spdlog::level::level_enum lvl, const T& msg) { Logging::getInstance().logger.log(source, lvl, msg); } -template -inline void log(spdlog::level::level_enum lvl, const T &msg) -{ +template +inline void log(spdlog::level::level_enum lvl, const T& msg) { Logging::getInstance().logger.log(lvl, msg); } -template -inline void trace(const T &msg) -{ +template +inline void trace(const T& msg) { Logging::getInstance().logger.trace(msg); } -template -inline void debug(const T &msg) -{ +template +inline void debug(const T& msg) { Logging::getInstance().logger.debug(msg); } -template -inline void info(const T &msg) -{ +template +inline void info(const T& msg) { Logging::getInstance().logger.info(msg); } -template -inline void warn(const T &msg) -{ +template +inline void warn(const T& msg) { Logging::getInstance().logger.warn(msg); } -template -inline void error(const T &msg) -{ +template +inline void error(const T& msg) { Logging::getInstance().logger.error(msg); } -template -inline void critical(const T &msg) -{ +template +inline void critical(const T& msg) { Logging::getInstance().logger.critical(msg); } -} // namespace logger - +} // namespace logger -} // namespace dai +} // namespace dai diff --git a/src/utility/PimplImpl.hpp b/src/utility/PimplImpl.hpp index 9b2204585..d6a46bf00 100644 --- a/src/utility/PimplImpl.hpp +++ b/src/utility/PimplImpl.hpp @@ -5,21 +5,24 @@ namespace dai { -template -Pimpl::Pimpl() : m{ new T{} } { } +template +Pimpl::Pimpl() : m{new T{}} {} -template -template -Pimpl::Pimpl( Args&& ...args ) - : m{ new T{ std::forward(args)... } } { } +template +template +Pimpl::Pimpl(Args&&... args) : m{new T{std::forward(args)...}} {} -template -Pimpl::~Pimpl() { } +template +Pimpl::~Pimpl() {} -template -T* Pimpl::operator->() { return m.get(); } +template +T* Pimpl::operator->() { + return m.get(); +} -template -T& Pimpl::operator*() { return *m.get(); } +template +T& Pimpl::operator*() { + return *m.get(); +} -} // namespace dai +} // namespace dai diff --git a/src/utility/Platform.hpp b/src/utility/Platform.hpp index 75ab32e9c..a8d9f3295 100644 --- a/src/utility/Platform.hpp +++ b/src/utility/Platform.hpp @@ -1,16 +1,17 @@ #pragma once #include -#include "depthai/utility/JoiningThread.hpp" #include +#include "depthai/utility/JoiningThread.hpp" + namespace dai { namespace platform { uint32_t getIPv4AddressAsBinary(std::string address); std::string getIPv4AddressAsString(std::uint32_t binary); std::string getTempPath(); -bool checkPathExists(const std::string& path, bool directory=false); +bool checkPathExists(const std::string& path, bool directory = false); bool checkWritePermissions(const std::string& path); std::string joinPaths(const std::string& path1, const std::string& path2); std::string getDirFromPath(const std::string& path); diff --git a/src/utility/ProtoSerialize.hpp b/src/utility/ProtoSerialize.hpp index 23d0ae794..22c0ffbdd 100644 --- a/src/utility/ProtoSerialize.hpp +++ b/src/utility/ProtoSerialize.hpp @@ -5,9 +5,9 @@ #include -#include "utility/ProtoSerializable.hpp" #include "depthai/common/ImgTransformations.hpp" #include "depthai/schemas/common.pb.h" +#include "utility/ProtoSerializable.hpp" namespace dai { namespace utility { @@ -17,6 +17,5 @@ ProtoSerializable::SchemaPair serializeSchema(std::unique_ptr #include -#include -#include #include -#include #include +#include +#include // project #include @@ -18,14 +18,14 @@ namespace dai { class TarGzAccessor { -public: + public: // Constructor takes a tar.gz file in memory (std::vector) TarGzAccessor(const std::vector& tarGzFile); // Function to get file data by path std::optional> getFile(const std::string& path) const; -private: + private: std::map> resourceMap; // Path to file data }; @@ -47,7 +47,7 @@ class Resources { std::unordered_map> resourceMapBootloader; std::vector getDeviceFwp(const std::string& fwPath, const std::string& envPath) const; -public: + public: static Resources& getInstance(); Resources(Resources const&) = delete; void operator=(Resources const&) = delete; @@ -59,7 +59,6 @@ class Resources { std::vector getDeviceRVC3Fwp() const; std::vector getDeviceRVC4Fwp() const; TarGzAccessor getEmbeddedVisualizer() const; - }; -} // namespace dai +} // namespace dai diff --git a/src/utility/XLinkGlobalProfilingLogger.hpp b/src/utility/XLinkGlobalProfilingLogger.hpp index f608d8617..a7ebc783e 100644 --- a/src/utility/XLinkGlobalProfilingLogger.hpp +++ b/src/utility/XLinkGlobalProfilingLogger.hpp @@ -1,12 +1,12 @@ #pragma once +#include #include -#include -#include #include -#include #include +#include +#include // project #include @@ -25,7 +25,7 @@ class XLinkGlobalProfilingLogger { std::atomic rate{1.0f}; std::thread thr; -public: + public: static XLinkGlobalProfilingLogger& getInstance(); XLinkGlobalProfilingLogger(XLinkGlobalProfilingLogger const&) = delete; void operator=(XLinkGlobalProfilingLogger const&) = delete; @@ -35,4 +35,4 @@ class XLinkGlobalProfilingLogger { float getRate(); }; -} // namespace dai +} // namespace dai diff --git a/src/utility/sha1.hpp b/src/utility/sha1.hpp index 46ac257d2..653f2b8b4 100644 --- a/src/utility/sha1.hpp +++ b/src/utility/sha1.hpp @@ -20,7 +20,6 @@ #ifndef SHA1_HPP #define SHA1_HPP - #include #include #include @@ -28,29 +27,24 @@ #include #include - -class SHA1 -{ -public: +class SHA1 { + public: SHA1(); - void update(const std::string &s); - void update(std::istream &is); + void update(const std::string& s); + void update(std::istream& is); std::string final(); - static std::string from_file(const std::string &filename); + static std::string from_file(const std::string& filename); -private: + private: uint32_t digest[5]; std::string buffer; uint64_t transforms; }; - -static const size_t BLOCK_INTS = 16; /* number of 32bit integers per SHA1 block */ +static const size_t BLOCK_INTS = 16; /* number of 32bit integers per SHA1 block */ static const size_t BLOCK_BYTES = BLOCK_INTS * 4; - -inline static void reset(uint32_t digest[], std::string &buffer, uint64_t &transforms) -{ +inline static void reset(uint32_t digest[], std::string& buffer, uint64_t& transforms) { /* SHA1 initialization constants */ digest[0] = 0x67452301; digest[1] = 0xefcdab89; @@ -63,68 +57,52 @@ inline static void reset(uint32_t digest[], std::string &buffer, uint64_t &trans transforms = 0; } - -inline static uint32_t rol(const uint32_t value, const size_t bits) -{ +inline static uint32_t rol(const uint32_t value, const size_t bits) { return (value << bits) | (value >> (32 - bits)); } - -inline static uint32_t blk(const uint32_t block[BLOCK_INTS], const size_t i) -{ - return rol(block[(i+13)&15] ^ block[(i+8)&15] ^ block[(i+2)&15] ^ block[i], 1); +inline static uint32_t blk(const uint32_t block[BLOCK_INTS], const size_t i) { + return rol(block[(i + 13) & 15] ^ block[(i + 8) & 15] ^ block[(i + 2) & 15] ^ block[i], 1); } - /* * (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ -inline static void R0(const uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i) -{ - z += ((w&(x^y))^y) + block[i] + 0x5a827999 + rol(v, 5); +inline static void R0(const uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t& w, const uint32_t x, const uint32_t y, uint32_t& z, const size_t i) { + z += ((w & (x ^ y)) ^ y) + block[i] + 0x5a827999 + rol(v, 5); w = rol(w, 30); } - -inline static void R1(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i) -{ +inline static void R1(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t& w, const uint32_t x, const uint32_t y, uint32_t& z, const size_t i) { block[i] = blk(block, i); - z += ((w&(x^y))^y) + block[i] + 0x5a827999 + rol(v, 5); + z += ((w & (x ^ y)) ^ y) + block[i] + 0x5a827999 + rol(v, 5); w = rol(w, 30); } - -inline static void R2(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i) -{ +inline static void R2(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t& w, const uint32_t x, const uint32_t y, uint32_t& z, const size_t i) { block[i] = blk(block, i); - z += (w^x^y) + block[i] + 0x6ed9eba1 + rol(v, 5); + z += (w ^ x ^ y) + block[i] + 0x6ed9eba1 + rol(v, 5); w = rol(w, 30); } - -inline static void R3(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i) -{ +inline static void R3(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t& w, const uint32_t x, const uint32_t y, uint32_t& z, const size_t i) { block[i] = blk(block, i); - z += (((w|x)&y)|(w&x)) + block[i] + 0x8f1bbcdc + rol(v, 5); + z += (((w | x) & y) | (w & x)) + block[i] + 0x8f1bbcdc + rol(v, 5); w = rol(w, 30); } - -inline static void R4(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i) -{ +inline static void R4(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t& w, const uint32_t x, const uint32_t y, uint32_t& z, const size_t i) { block[i] = blk(block, i); - z += (w^x^y) + block[i] + 0xca62c1d6 + rol(v, 5); + z += (w ^ x ^ y) + block[i] + 0xca62c1d6 + rol(v, 5); w = rol(w, 30); } - /* * Hash a single 512-bit block. This is the core of the algorithm. */ -inline static void transform(uint32_t digest[], uint32_t block[BLOCK_INTS], uint64_t &transforms) -{ +inline static void transform(uint32_t digest[], uint32_t block[BLOCK_INTS], uint64_t& transforms) { /* Copy digest[] to working vars */ uint32_t a = digest[0]; uint32_t b = digest[1]; @@ -133,80 +111,80 @@ inline static void transform(uint32_t digest[], uint32_t block[BLOCK_INTS], uint uint32_t e = digest[4]; /* 4 rounds of 20 operations each. Loop unrolled. */ - R0(block, a, b, c, d, e, 0); - R0(block, e, a, b, c, d, 1); - R0(block, d, e, a, b, c, 2); - R0(block, c, d, e, a, b, 3); - R0(block, b, c, d, e, a, 4); - R0(block, a, b, c, d, e, 5); - R0(block, e, a, b, c, d, 6); - R0(block, d, e, a, b, c, 7); - R0(block, c, d, e, a, b, 8); - R0(block, b, c, d, e, a, 9); + R0(block, a, b, c, d, e, 0); + R0(block, e, a, b, c, d, 1); + R0(block, d, e, a, b, c, 2); + R0(block, c, d, e, a, b, 3); + R0(block, b, c, d, e, a, 4); + R0(block, a, b, c, d, e, 5); + R0(block, e, a, b, c, d, 6); + R0(block, d, e, a, b, c, 7); + R0(block, c, d, e, a, b, 8); + R0(block, b, c, d, e, a, 9); R0(block, a, b, c, d, e, 10); R0(block, e, a, b, c, d, 11); R0(block, d, e, a, b, c, 12); R0(block, c, d, e, a, b, 13); R0(block, b, c, d, e, a, 14); R0(block, a, b, c, d, e, 15); - R1(block, e, a, b, c, d, 0); - R1(block, d, e, a, b, c, 1); - R1(block, c, d, e, a, b, 2); - R1(block, b, c, d, e, a, 3); - R2(block, a, b, c, d, e, 4); - R2(block, e, a, b, c, d, 5); - R2(block, d, e, a, b, c, 6); - R2(block, c, d, e, a, b, 7); - R2(block, b, c, d, e, a, 8); - R2(block, a, b, c, d, e, 9); + R1(block, e, a, b, c, d, 0); + R1(block, d, e, a, b, c, 1); + R1(block, c, d, e, a, b, 2); + R1(block, b, c, d, e, a, 3); + R2(block, a, b, c, d, e, 4); + R2(block, e, a, b, c, d, 5); + R2(block, d, e, a, b, c, 6); + R2(block, c, d, e, a, b, 7); + R2(block, b, c, d, e, a, 8); + R2(block, a, b, c, d, e, 9); R2(block, e, a, b, c, d, 10); R2(block, d, e, a, b, c, 11); R2(block, c, d, e, a, b, 12); R2(block, b, c, d, e, a, 13); R2(block, a, b, c, d, e, 14); R2(block, e, a, b, c, d, 15); - R2(block, d, e, a, b, c, 0); - R2(block, c, d, e, a, b, 1); - R2(block, b, c, d, e, a, 2); - R2(block, a, b, c, d, e, 3); - R2(block, e, a, b, c, d, 4); - R2(block, d, e, a, b, c, 5); - R2(block, c, d, e, a, b, 6); - R2(block, b, c, d, e, a, 7); - R3(block, a, b, c, d, e, 8); - R3(block, e, a, b, c, d, 9); + R2(block, d, e, a, b, c, 0); + R2(block, c, d, e, a, b, 1); + R2(block, b, c, d, e, a, 2); + R2(block, a, b, c, d, e, 3); + R2(block, e, a, b, c, d, 4); + R2(block, d, e, a, b, c, 5); + R2(block, c, d, e, a, b, 6); + R2(block, b, c, d, e, a, 7); + R3(block, a, b, c, d, e, 8); + R3(block, e, a, b, c, d, 9); R3(block, d, e, a, b, c, 10); R3(block, c, d, e, a, b, 11); R3(block, b, c, d, e, a, 12); R3(block, a, b, c, d, e, 13); R3(block, e, a, b, c, d, 14); R3(block, d, e, a, b, c, 15); - R3(block, c, d, e, a, b, 0); - R3(block, b, c, d, e, a, 1); - R3(block, a, b, c, d, e, 2); - R3(block, e, a, b, c, d, 3); - R3(block, d, e, a, b, c, 4); - R3(block, c, d, e, a, b, 5); - R3(block, b, c, d, e, a, 6); - R3(block, a, b, c, d, e, 7); - R3(block, e, a, b, c, d, 8); - R3(block, d, e, a, b, c, 9); + R3(block, c, d, e, a, b, 0); + R3(block, b, c, d, e, a, 1); + R3(block, a, b, c, d, e, 2); + R3(block, e, a, b, c, d, 3); + R3(block, d, e, a, b, c, 4); + R3(block, c, d, e, a, b, 5); + R3(block, b, c, d, e, a, 6); + R3(block, a, b, c, d, e, 7); + R3(block, e, a, b, c, d, 8); + R3(block, d, e, a, b, c, 9); R3(block, c, d, e, a, b, 10); R3(block, b, c, d, e, a, 11); R4(block, a, b, c, d, e, 12); R4(block, e, a, b, c, d, 13); R4(block, d, e, a, b, c, 14); R4(block, c, d, e, a, b, 15); - R4(block, b, c, d, e, a, 0); - R4(block, a, b, c, d, e, 1); - R4(block, e, a, b, c, d, 2); - R4(block, d, e, a, b, c, 3); - R4(block, c, d, e, a, b, 4); - R4(block, b, c, d, e, a, 5); - R4(block, a, b, c, d, e, 6); - R4(block, e, a, b, c, d, 7); - R4(block, d, e, a, b, c, 8); - R4(block, c, d, e, a, b, 9); + R4(block, b, c, d, e, a, 0); + R4(block, a, b, c, d, e, 1); + R4(block, e, a, b, c, d, 2); + R4(block, d, e, a, b, c, 3); + R4(block, c, d, e, a, b, 4); + R4(block, b, c, d, e, a, 5); + R4(block, a, b, c, d, e, 6); + R4(block, e, a, b, c, d, 7); + R4(block, d, e, a, b, c, 8); + R4(block, c, d, e, a, b, 9); R4(block, b, c, d, e, a, 10); R4(block, a, b, c, d, e, 11); R4(block, e, a, b, c, d, 12); @@ -225,42 +203,28 @@ inline static void transform(uint32_t digest[], uint32_t block[BLOCK_INTS], uint transforms++; } - -inline static void buffer_to_block(const std::string &buffer, uint32_t block[BLOCK_INTS]) -{ +inline static void buffer_to_block(const std::string& buffer, uint32_t block[BLOCK_INTS]) { /* Convert the std::string (byte buffer) to a uint32_t array (MSB) */ - for (size_t i = 0; i < BLOCK_INTS; i++) - { - block[i] = (buffer[4*i+3] & 0xff) - | (buffer[4*i+2] & 0xff)<<8 - | (buffer[4*i+1] & 0xff)<<16 - | (buffer[4*i+0] & 0xff)<<24; + for(size_t i = 0; i < BLOCK_INTS; i++) { + block[i] = (buffer[4 * i + 3] & 0xff) | (buffer[4 * i + 2] & 0xff) << 8 | (buffer[4 * i + 1] & 0xff) << 16 | (buffer[4 * i + 0] & 0xff) << 24; } } - -inline SHA1::SHA1() -{ +inline SHA1::SHA1() { reset(digest, buffer, transforms); } - -inline void SHA1::update(const std::string &s) -{ +inline void SHA1::update(const std::string& s) { std::istringstream is(s); update(is); } - -inline void SHA1::update(std::istream &is) -{ - while (true) - { +inline void SHA1::update(std::istream& is) { + while(true) { char sbuf[BLOCK_BYTES]; is.read(sbuf, BLOCK_BYTES - buffer.size()); buffer.append(sbuf, (std::size_t)is.gcount()); - if (buffer.size() != BLOCK_BYTES) - { + if(buffer.size() != BLOCK_BYTES) { return; } uint32_t block[BLOCK_INTS]; @@ -270,32 +234,27 @@ inline void SHA1::update(std::istream &is) } } - /* * Add padding and return the message digest. */ -inline std::string SHA1::final() -{ +inline std::string SHA1::final() { /* Total number of hashed bits */ - uint64_t total_bits = (transforms*BLOCK_BYTES + buffer.size()) * 8; + uint64_t total_bits = (transforms * BLOCK_BYTES + buffer.size()) * 8; /* Padding */ buffer += (char)0x80; size_t orig_size = buffer.size(); - while (buffer.size() < BLOCK_BYTES) - { + while(buffer.size() < BLOCK_BYTES) { buffer += (char)0x00; } uint32_t block[BLOCK_INTS]; buffer_to_block(buffer, block); - if (orig_size > BLOCK_BYTES - 8) - { + if(orig_size > BLOCK_BYTES - 8) { transform(digest, block, transforms); - for (size_t i = 0; i < BLOCK_INTS - 2; i++) - { + for(size_t i = 0; i < BLOCK_INTS - 2; i++) { block[i] = 0; } } @@ -307,8 +266,7 @@ inline std::string SHA1::final() /* Hex std::string */ std::ostringstream result; - for (size_t i = 0; i < sizeof(digest) / sizeof(digest[0]); i++) - { + for(size_t i = 0; i < sizeof(digest) / sizeof(digest[0]); i++) { result << std::hex << std::setfill('0') << std::setw(8); result << digest[i]; } @@ -319,14 +277,11 @@ inline std::string SHA1::final() return result.str(); } - -inline std::string SHA1::from_file(const std::string &filename) -{ +inline std::string SHA1::from_file(const std::string& filename) { std::ifstream stream(filename.c_str(), std::ios::binary); SHA1 checksum; checksum.update(stream); return checksum.final(); } - #endif /* SHA1_HPP */ diff --git a/src/utility/spdlog-fmt.hpp b/src/utility/spdlog-fmt.hpp old mode 100755 new mode 100644 index a42de2fc6..0959358d9 --- a/src/utility/spdlog-fmt.hpp +++ b/src/utility/spdlog-fmt.hpp @@ -5,10 +5,10 @@ #include "depthai/utility/Path.hpp" #if FMT_VERSION >= 100000 -#include + #include -#include "depthai/common/CameraBoardSocket.hpp" -#include "pipeline/datatype/DatatypeEnum.hpp" + #include "depthai/common/CameraBoardSocket.hpp" + #include "pipeline/datatype/DatatypeEnum.hpp" #endif namespace dai { @@ -28,15 +28,15 @@ struct fmt::formatter : formatter { auto format(const dai::Path& p, FormatContext& ctx) -> decltype(ctx.out()) { #endif std::string output; - try { - output = p.string(); - } catch(const std::exception&) { - output = dai::utility::path_convert_err; - } - return formatter::format(output, ctx); + try { + output = p.string(); + } catch(const std::exception&) { + output = dai::utility::path_convert_err; } -}; - + return formatter::format(output, ctx); +} +} +; #if FMT_VERSION >= 100000 template <>