From ad9bf0fb8303b1fd61f7c6d35a8fd3c83a9e42dc Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Fri, 9 Apr 2021 21:41:48 +0300 Subject: [PATCH 1/3] Update SpatialCalculator data output with a new field: depthAveragePixelCount --- depthai-core | 2 +- src/DatatypeBindings.cpp | 41 ++++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/depthai-core b/depthai-core index a4dd44b95..8109c7dd9 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit a4dd44b957f2730ef0b8103f8382bf5aea836c34 +Subproject commit 8109c7dd9bc31b87f2f700289511e5a4c55e5f85 diff --git a/src/DatatypeBindings.cpp b/src/DatatypeBindings.cpp index 055f57a59..afe15ff34 100644 --- a/src/DatatypeBindings.cpp +++ b/src/DatatypeBindings.cpp @@ -64,14 +64,14 @@ void DatatypeBindings::bind(pybind11::module& m){ .def_readwrite("instanceNum", &RawImgFrame::instanceNum) .def_readwrite("sequenceNum", &RawImgFrame::sequenceNum) .def_property("ts", - [](const RawImgFrame& o){ - double ts = o.ts.sec + o.ts.nsec / 1000000000.0; - return ts; + [](const RawImgFrame& o){ + double ts = o.ts.sec + o.ts.nsec / 1000000000.0; + return ts; }, - [](RawImgFrame& o, double ts){ - o.ts.sec = ts; - o.ts.nsec = (ts - o.ts.sec) * 1000000000.0; - } + [](RawImgFrame& o, double ts){ + o.ts.sec = ts; + o.ts.nsec = (ts - o.ts.sec) * 1000000000.0; + } ) ; @@ -150,7 +150,7 @@ void DatatypeBindings::bind(pybind11::module& m){ .value("FP32", TensorInfo::DataType::FP32) .value("I8", TensorInfo::DataType::I8) ; - + py::enum_(tensorInfo, "StorageOrder") .value("NHWC", TensorInfo::StorageOrder::NHWC) .value("NHCW", TensorInfo::StorageOrder::NHCW) @@ -194,7 +194,7 @@ void DatatypeBindings::bind(pybind11::module& m){ .def(py::init<>()) .def_readwrite("detections", &RawSpatialImgDetections::detections) ; - + // Bind RawImageManipConfig py::class_> rawImageManipConfig(m, "RawImageManipConfig", DOC(dai, RawImageManipConfig)); rawImageManipConfig @@ -277,7 +277,7 @@ void DatatypeBindings::bind(pybind11::module& m){ .value("TRACKED", Tracklet::TrackingStatus::TRACKED) .value("LOST", Tracklet::TrackingStatus::LOST) ; - + // Bind RawTracklets py::class_> rawTacklets(m, "RawTracklets", DOC(dai, RawTracklets)); rawTacklets @@ -410,7 +410,7 @@ void DatatypeBindings::bind(pybind11::module& m){ py::array contiguous = numpy.attr("ascontiguousarray")(arr); frm.getData().resize(contiguous.nbytes()); - memcpy(frm.getData().data(), contiguous.data(), contiguous.nbytes()); + memcpy(frm.getData().data(), contiguous.data(), contiguous.nbytes()); }, py::arg("array"), "Copies array bytes to ImgFrame buffer") .def("getFrame", [](py::object &obj, bool copy){ @@ -426,14 +426,14 @@ void DatatypeBindings::bind(pybind11::module& m){ // obj is "Python" object, which we used then to bind the numpy view lifespan to // creates numpy array (zero-copy) which holds correct information such as shape, ... auto& img = obj.cast(); - + // shape bool valid = img.getWidth() > 0 && img.getHeight() > 0; std::vector shape = {img.getData().size()}; py::dtype dtype = py::dtype::of(); switch(img.getType()){ - + case ImgFrame::Type::RGB888i : case ImgFrame::Type::BGR888i : // HWC @@ -463,12 +463,12 @@ void DatatypeBindings::bind(pybind11::module& m){ break; case ImgFrame::Type::GRAYF16: - shape = {img.getHeight(), img.getWidth()}; + shape = {img.getHeight(), img.getWidth()}; dtype = py::dtype("half"); break; case ImgFrame::Type::RAW16: - shape = {img.getHeight(), img.getWidth()}; + shape = {img.getHeight(), img.getWidth()}; dtype = py::dtype::of(); break; @@ -477,7 +477,7 @@ void DatatypeBindings::bind(pybind11::module& m){ shape = {img.getHeight(), img.getWidth(), 3}; dtype = py::dtype("half"); break; - + case ImgFrame::Type::RGBF16F16F16p: case ImgFrame::Type::BGRF16F16F16p: shape = {3, img.getHeight(), img.getWidth()}; @@ -488,7 +488,7 @@ void DatatypeBindings::bind(pybind11::module& m){ default: shape = {img.getData().size()}; dtype = py::dtype::of(); - break; + break; } // Check if enough data @@ -504,13 +504,13 @@ void DatatypeBindings::bind(pybind11::module& m){ if(copy){ py::array a(dtype, shape); std::memcpy(a.mutable_data(), img.getData().data(), std::min( (long) (img.getData().size()), (long) (a.nbytes()))); - return a; + return a; } else { return py::array(dtype, shape, img.getData().data(), obj); } }, py::arg("copy") = false, "Returns numpy array with shape as specified by width, height and type") - + .def("getCvFrame", [](py::object &obj){ using namespace pybind11::literals; @@ -744,9 +744,10 @@ void DatatypeBindings::bind(pybind11::module& m){ .def(py::init<>()) .def_readwrite("config", &SpatialLocations::config) .def_readwrite("depthAverage", &SpatialLocations::depthAverage) + .def_readwrite("depthAveragePixelCount", &SpatialLocations::depthAveragePixelCount) .def_readwrite("spatialCoordinates", &SpatialLocations::spatialCoordinates) ; - + py::class_ (m, "Rect", DOC(dai, Rect)) .def(py::init<>()) From 2cfcc04282dcb391b4c3eeeda098236f415336e4 Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Tue, 13 Apr 2021 01:00:35 +0300 Subject: [PATCH 2/3] Update core --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 8109c7dd9..d32418104 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 8109c7dd9bc31b87f2f700289511e5a4c55e5f85 +Subproject commit d32418104ccadcde2b15453e7cba2263e23b051e From 2f1dc9dbf0b80dbef21b11b270509e441b29ced0 Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Tue, 13 Apr 2021 02:11:33 +0300 Subject: [PATCH 3/3] Update submodule --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index a2a06f8cc..6e0815443 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit a2a06f8ccf1ac3b288640c4ac34063639a0ce568 +Subproject commit 6e0815443b0a43802b061714993cc8d8b951d533