From 925ed91f85fd98aa8f7e22914b76344f921713d3 Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Thu, 10 Sep 2020 06:38:05 +0300 Subject: [PATCH 01/59] Merge changes from enhance_stereo_depth into develop --- depthai-core | 2 +- src/device_bindings.cpp | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 1bd444253..850985afc 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 1bd44425339d2ca9daf0f2d902e27aae6bffc85d +Subproject commit 850985afc2f73cb14fa862d01b28591c94f81764 diff --git a/src/device_bindings.cpp b/src/device_bindings.cpp index 2fbd37e39..48094aceb 100644 --- a/src/device_bindings.cpp +++ b/src/device_bindings.cpp @@ -77,6 +77,43 @@ void init_binding_device(pybind11::module& m){ "Returns NN bounding-box to depth mapping as a dict of coords: off_x, off_y, max_w, max_h." ) + // calibration data bindings + .def( + "get_left_intrinsic", + &Device::get_left_intrinsic, + "Returns 3x3 matrix defining the intrinsic parameters of the left camera of the stereo setup." + ) + + .def( + "get_left_homography", + &Device::get_left_homography, + "Returns 3x3 matrix defining the homography to rectify the left camera of the stereo setup." + ) + + .def( + "get_right_intrinsic", + &Device::get_right_intrinsic, + "Returns 3x3 matrix defining the intrinsic parameters of the right camera of the stereo setup." + ) + + .def( + "get_right_homography", + &Device::get_right_homography, + "Returns 3x3 matrix defining the homography to rectify the right camera of the stereo setup." + ) + + .def( + "get_rotation", + &Device::get_rotation, + "Returns 3x3 matrix defining how much the right camera is rotated w.r.t left camera." + ) + + .def( + "get_Translation", + &Device::get_Translation, + "Returns a vector defining how much the right camera is translated w.r.t left camera." + ) + ; From 5a0f4a317f49cf1559088b9914ee6ddbc11f2ada Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Thu, 10 Sep 2020 07:24:50 +0300 Subject: [PATCH 02/59] Update depthai-core submodule --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 850985afc..906c246c7 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 850985afc2f73cb14fa862d01b28591c94f81764 +Subproject commit 906c246c71d620d60ee1082dcaebea194e6fdc25 From 225a169e3a0a7b871a08628851baf8b537019d5f Mon Sep 17 00:00:00 2001 From: Martin Peterlin Date: Thu, 10 Sep 2020 10:11:59 +0200 Subject: [PATCH 03/59] Updated core and added a zero-copy TODO --- depthai-core | 2 +- src/host_data_packet_bindings.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/depthai-core b/depthai-core index 1bd444253..ebe04314f 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 1bd44425339d2ca9daf0f2d902e27aae6bffc85d +Subproject commit ebe04314fa09dbd27df189d4b5b378267aa0881d diff --git a/src/host_data_packet_bindings.cpp b/src/host_data_packet_bindings.cpp index e287ac44f..b70721bc8 100644 --- a/src/host_data_packet_bindings.cpp +++ b/src/host_data_packet_bindings.cpp @@ -73,7 +73,9 @@ void init_binding_host_data_packet(pybind11::module& m){ } - +// TODO - zero copy +//https://github.com/pybind/pybind11/issues/323#issuecomment-575717041 +//https://github.com/pybind/pybind11/issues/1042#issuecomment-642215028 py::array* PyHostDataPacket::getPythonNumpyArray() { assert(!dimensions.empty()); From 4d6b8f40e312e2d173732e6fe54d101724024b4f Mon Sep 17 00:00:00 2001 From: Martin Peterlin Date: Thu, 10 Sep 2020 10:26:26 +0200 Subject: [PATCH 04/59] Updated core --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index ebe04314f..ad4b20f07 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit ebe04314fa09dbd27df189d4b5b378267aa0881d +Subproject commit ad4b20f0789007523537da2eb88d6d07372c1aa8 From c85122baae5f88e37f892281464e348d5cd72dd4 Mon Sep 17 00:00:00 2001 From: Martin Peterlin Date: Thu, 10 Sep 2020 23:57:07 +0200 Subject: [PATCH 05/59] Updated core --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index ad4b20f07..14cfa1137 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit ad4b20f0789007523537da2eb88d6d07372c1aa8 +Subproject commit 14cfa1137def4385e6ff902ef3499a332aa3e950 From 474de6ef80c1f216dade40f1e275d063fa3d135a Mon Sep 17 00:00:00 2001 From: Martin Peterlin Date: Thu, 10 Sep 2020 23:59:25 +0200 Subject: [PATCH 06/59] Updated core --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 14cfa1137..d95d7279d 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 14cfa1137def4385e6ff902ef3499a332aa3e950 +Subproject commit d95d7279d93af6c9d7a129a122bcb2c17f9edb26 From 3b60ed5ee1051bd1d71f10e4226cdef01b0d2453 Mon Sep 17 00:00:00 2001 From: saching13 Date: Fri, 11 Sep 2020 09:22:05 -0700 Subject: [PATCH 07/59] updated get_translation api --- depthai-core | 2 +- src/device_bindings.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/depthai-core b/depthai-core index cb1c0e5fa..dee61245d 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit cb1c0e5fa61647365d1f09ee0554cfb0455e3652 +Subproject commit dee61245d5ee80c20a1ad2e823b5c804e9e1a287 diff --git a/src/device_bindings.cpp b/src/device_bindings.cpp index 48094aceb..f6cedbc77 100644 --- a/src/device_bindings.cpp +++ b/src/device_bindings.cpp @@ -109,8 +109,8 @@ void init_binding_device(pybind11::module& m){ ) .def( - "get_Translation", - &Device::get_Translation, + "get_translation", + &Device::get_translation, "Returns a vector defining how much the right camera is translated w.r.t left camera." ) From 4bb2a5c39c288dab10d8bef40ed192c31a02a56d Mon Sep 17 00:00:00 2001 From: saching13 Date: Fri, 11 Sep 2020 18:22:03 -0700 Subject: [PATCH 08/59] replacing homography with R1 and R2 and adding distortion coefficients along with place holders for rgb camera calibrations. --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index dee61245d..a86c8fb60 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit dee61245d5ee80c20a1ad2e823b5c804e9e1a287 +Subproject commit a86c8fb6038574cd93de834697c694aa18060bc9 From 688461c6f43db289125cb0538f2c4d7af36375d5 Mon Sep 17 00:00:00 2001 From: saching13 Date: Mon, 14 Sep 2020 14:50:16 -0700 Subject: [PATCH 09/59] tested and fixed some syntax errors. Added version check and abort on EEPROM write in depthai-core --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index a86c8fb60..f653ea2f2 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit a86c8fb6038574cd93de834697c694aa18060bc9 +Subproject commit f653ea2f2e5e8672454fd7370a11aeeda905a1f7 From 77a973850a29cbe5f0018e3eebaf45bf81d828dc Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Tue, 15 Sep 2020 01:31:12 +0300 Subject: [PATCH 10/59] Update depthai-core submodule: EEPROM V5 --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index f653ea2f2..b87c19b0d 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit f653ea2f2e5e8672454fd7370a11aeeda905a1f7 +Subproject commit b87c19b0d97f6791ef2b256492c4560ac611d2bc From 670e597b9998ad9988a9135d981bff14f43be405 Mon Sep 17 00:00:00 2001 From: saching13 Date: Tue, 15 Sep 2020 08:37:35 -0700 Subject: [PATCH 11/59] fixed get_left_homography() by adding matrix ops --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index b87c19b0d..eb3306c12 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit b87c19b0d97f6791ef2b256492c4560ac611d2bc +Subproject commit eb3306c12d4d15dae10ac0d08e3e3470892eef72 From 868862917f914071519d2eb6ab724d5eedd8a1b6 Mon Sep 17 00:00:00 2001 From: saching13 Date: Tue, 15 Sep 2020 09:46:18 -0700 Subject: [PATCH 12/59] added math ops in depthai-core. mesh WIP and disbaled --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index eb3306c12..233e2ade2 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit eb3306c12d4d15dae10ac0d08e3e3470892eef72 +Subproject commit 233e2ade26be09bba85c756c317206405985f92f From 9c0aab6ef1a79f3d221918cedb2e5107b0a8eef3 Mon Sep 17 00:00:00 2001 From: saching13 Date: Tue, 15 Sep 2020 10:28:23 -0700 Subject: [PATCH 13/59] refactored depthai-core --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 233e2ade2..ea49555bd 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 233e2ade26be09bba85c756c317206405985f92f +Subproject commit ea49555bd159a80060cbde5a9af00a984a6b1e98 From 91b7696ba1d24ae47bdf86f64f7160041193f107 Mon Sep 17 00:00:00 2001 From: saching13 Date: Tue, 15 Sep 2020 10:43:41 -0700 Subject: [PATCH 14/59] added version check on calibration adjustments in depthai-core --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index ea49555bd..d0e8012e7 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit ea49555bd159a80060cbde5a9af00a984a6b1e98 +Subproject commit d0e8012e79987f5461f9c538cbfdf960a3ae845a From 4416f644753da859dfd6dcc992ebc8306f0fc653 Mon Sep 17 00:00:00 2001 From: saching13 Date: Tue, 15 Sep 2020 10:54:28 -0700 Subject: [PATCH 15/59] bug fix for version 3 depthai-core --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index d0e8012e7..3f266f83b 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit d0e8012e79987f5461f9c538cbfdf960a3ae845a +Subproject commit 3f266f83b95e1407cbf505dc8dc7230e2a9224ef From e7332dd90a143c80f75453cb58c7cf0115792905 Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Tue, 15 Sep 2020 23:00:48 +0300 Subject: [PATCH 16/59] Update depthai-core: rectified L/R swapping corrected --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index de0f796d2..3e6fd676b 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit de0f796d20fa6f5914cadedf5f04202fe7b2bc56 +Subproject commit 3e6fd676b6df88451a115751408bc0e35f1120d4 From 6a49d01709ad241b80d0edfab0f4a4b5691b57b6 Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Wed, 16 Sep 2020 13:40:15 -0700 Subject: [PATCH 17/59] Update depthai-core submodule --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 3e6fd676b..ce8f293b4 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 3e6fd676b6df88451a115751408bc0e35f1120d4 +Subproject commit ce8f293b4dd63f2c1928a5f95763dac986adc42c From b8fd25380c4de0b1ed5a662c9a939d1e6ea205c4 Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Wed, 16 Sep 2020 13:40:31 -0700 Subject: [PATCH 18/59] Change git submodule url to relative path to inherit ssh/https option --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 41411b259..b7adabb3d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "depthai-core"] path = depthai-core - url = https://github.com/luxonis/depthai-core.git + url = ../depthai-core.git From 34fb671932770318479f0980075d51cbd27137c9 Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Wed, 16 Sep 2020 13:42:54 -0700 Subject: [PATCH 19/59] Fix build error --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index ce8f293b4..358c7c169 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit ce8f293b4dd63f2c1928a5f95763dac986adc42c +Subproject commit 358c7c1695a07c4502051050355913501639cc98 From 21b4a646c6e9bc5ead66662f9812508dc8ad02ba Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Fri, 18 Sep 2020 07:06:36 +0300 Subject: [PATCH 20/59] Merge in initial version of openvino tensor representation --- depthai-core | 2 +- src/nnet_packet_bindings.cpp | 148 ++++++++++++++++++++- src/nnet_packet_bindings.hpp | 8 +- src/py_bindings.cpp | 36 ++--- src/py_tensor_entry_container_iterator.cpp | 34 ++--- src/py_tensor_entry_container_iterator.hpp | 42 +++--- 6 files changed, 205 insertions(+), 65 deletions(-) diff --git a/depthai-core b/depthai-core index 358c7c169..5e49f9927 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 358c7c1695a07c4502051050355913501639cc98 +Subproject commit 5e49f99274a40668d11b3d9d5edbf6ec06412138 diff --git a/src/nnet_packet_bindings.cpp b/src/nnet_packet_bindings.cpp index aa8413ac5..f0b7c3b19 100644 --- a/src/nnet_packet_bindings.cpp +++ b/src/nnet_packet_bindings.cpp @@ -11,6 +11,7 @@ // pybind11 #include "pybind11_common.hpp" + namespace py = pybind11; @@ -31,21 +32,131 @@ void init_binding_nnet_packet(pybind11::module& m){ // for NNET_PACKET in nnet_packets: py::class_>(m, "NNetPacket") - .def("get_tensor", static_cast(&PyNNetPacket::getTensor), py::return_value_policy::copy) - .def("get_tensor", static_cast(&PyNNetPacket::getTensorByName), py::return_value_policy::copy) - .def("entries", &NNetPacket::getTensorEntryContainer, py::return_value_policy::copy) + .def("get_tensor", static_cast(&PyNNetPacket::getTensor), py::return_value_policy::take_ownership) + .def("get_tensor", static_cast(&PyNNetPacket::getTensorByName), py::return_value_policy::take_ownership) + // .def("entries", &NNetPacket::getTensorEntryContainer, py::return_value_policy::copy) .def("getMetadata", &NNetPacket::getMetadata, py::return_value_policy::copy) + .def("getOutputsList", static_cast(&PyNNetPacket::getOutputsList), py::return_value_policy::copy) + .def("getOutputsDict", static_cast(&PyNNetPacket::getOutputsDict), py::return_value_policy::copy) + .def("getTensorsSize", &NNetPacket::getTensorsSize, py::return_value_policy::copy) + .def("getDetectionCount", &NNetPacket::getDetectionCount, py::return_value_policy::copy) + .def("getDetectedObject", static_cast(&PyNNetPacket::getDetectedObject), py::return_value_policy::copy) ; + + py::class_(m, "Detection") + .def_readonly("label", &detection_t::label) + .def_readonly("confidence", &detection_t::confidence) + .def_readonly("x_min", &detection_t::x_min) + .def_readonly("y_min", &detection_t::y_min) + .def_readonly("x_max", &detection_t::x_max) + .def_readonly("y_max", &detection_t::y_max) + .def_readonly("depth_x", &detection_t::depth_x) + .def_readonly("depth_y", &detection_t::depth_y) + .def_readonly("depth_z", &detection_t::depth_z) + .def("get_dict", []() { + py::dict d; + d["label"] = &detection_t::label; + d["confidence"] = &detection_t::confidence; + d["x_min"] = &detection_t::x_min; + d["y_min"] = &detection_t::y_min; + d["x_max"] = &detection_t::x_max; + d["y_max"] = &detection_t::y_max; + d["depth_x"] = &detection_t::depth_x; + d["depth_y"] = &detection_t::depth_y; + d["depth_z"] = &detection_t::depth_z; + return d; + }) + ; + +} + + + + +namespace pybind11 { namespace detail { +template <> + struct npy_format_descriptor { + static std::string format() { + // https://docs.python.org/3/library/struct.html#format-characters + return "e"; + } + }; +}} // namespace pybind11::detail + +const std::map type_to_numpy_format = { + {TensorDataType::_fp16, pybind11::format_descriptor::format()}, + {TensorDataType::_u8f, pybind11::format_descriptor::format()}, + {TensorDataType::_int, pybind11::format_descriptor::format()}, + {TensorDataType::_fp32, pybind11::format_descriptor::format()}, + {TensorDataType::_i8, pybind11::format_descriptor::format()}, +}; + +std::string type_to_npy_format_descriptor(const TensorDataType& type) +{ + auto it = type_to_numpy_format.find(type); + assert(it != type_to_numpy_format.end()); + return it->second; +}; + + +py::object PyNNetPacket::getDetectedObject(int detected_nr) +{ + unsigned char * data = _tensors_raw_data->data.data(); + detection_out_t * detections = (detection_out_t *)data; + assert(detected_nr < detections->detection_count); + return py::cast(detections->detections[detected_nr]); +} + +// TODO - zero copy +//https://github.com/pybind/pybind11/issues/323#issuecomment-575717041 +//https://github.com/pybind/pybind11/issues/1042#issuecomment-642215028 +static py::array* _getTensorPythonNumpyArray(unsigned char *data, TensorInfo ti) +{ + assert(!ti.tensor_dimensions.empty()); + py::array* result = nullptr; + + ssize_t ndim = ti.tensor_dimensions.size(); + ssize_t element_size = size_of_type(ti.tensor_data_type); + std::string numpy_format_descriptor = type_to_npy_format_descriptor(ti.tensor_data_type); + std::vector shape; + std::vector strides; + shape.reserve(ndim); + strides.reserve(ndim); + for (int i = 0; i < ndim; ++i) + { + shape.push_back(ti.tensor_dimensions[i]); + strides.push_back(ti.tensor_strides[i]); + } + + try { + + result = new py::array(py::buffer_info( + static_cast(&data[ti.tensor_offset]), /* data as contiguous array */ + element_size, /* size of one scalar */ + numpy_format_descriptor, /* data type */ + ndim, //ndim, /* number of dimensions */ + shape, //shape, /* shape of the matrix */ + strides //strides /* strides for each axis */ + )); + } catch (const std::exception& e) + { + std::cerr << e.what() << std::endl; + result = nullptr; + } + + return result; } -pybind11::array* PyNNetPacket::getTensor(unsigned index) +py::array* PyNNetPacket::getTensor(unsigned index) { - auto ptr = std::static_pointer_cast(_tensors_raw_data[index]); - return ptr->getPythonNumpyArray(); + assert(index < _tensors_info.size()); + TensorInfo ti = _tensors_info[index]; + unsigned char * data = _tensors_raw_data->data.data(); + return _getTensorPythonNumpyArray(data, ti); } -pybind11::array* PyNNetPacket::getTensorByName(const std::string &name) +py::array* PyNNetPacket::getTensorByName(const std::string &name) { auto it = _tensor_name_to_index.find(name); if (it == _tensor_name_to_index.end()) @@ -57,3 +168,26 @@ pybind11::array* PyNNetPacket::getTensorByName(const std::string &name) return getTensor(it->second); } } + + +py::list PyNNetPacket::getOutputsList() { + py::list outputList; + for (size_t i = 0; i < _tensors_info.size(); ++i) + { + outputList.append(getTensor(i)); + } + return outputList; +} + + +py::dict PyNNetPacket::getOutputsDict() { + py::dict outputs; + for (size_t i = 0; i < _tensors_info.size(); ++i) + { + std::string tensor_name = getTensorName(i); + outputs[tensor_name.c_str()] = getTensor(i); + } + + return outputs; +} + diff --git a/src/nnet_packet_bindings.hpp b/src/nnet_packet_bindings.hpp index 22357837d..064b1c006 100644 --- a/src/nnet_packet_bindings.hpp +++ b/src/nnet_packet_bindings.hpp @@ -8,10 +8,16 @@ void init_binding_nnet_packet(pybind11::module& m); +namespace py = pybind11; + struct PyNNetPacket : public NNetPacket { - pybind11::array* getTensor(unsigned index); + py::object getDetectedObject(int detected_nr); + py::array* getTensor(unsigned index); pybind11::array* getTensorByName(const std::string &name); + py::list getOutputsList(); + py::dict getOutputsDict(); + public: using NNetPacket::_tensors_raw_data; using NNetPacket::_tensor_name_to_index; diff --git a/src/py_bindings.cpp b/src/py_bindings.cpp index f30b44f6c..63ea8ec25 100644 --- a/src/py_bindings.cpp +++ b/src/py_bindings.cpp @@ -48,27 +48,27 @@ PYBIND11_MODULE(depthai,m) // for te in nnet_packet.ENTRIES() - py::class_>(m, "TensorEntryContainer") - .def("__len__", &TensorEntryContainer::size) - .def("__getitem__", &TensorEntryContainer::getByIndex) - .def("__getitem__", &TensorEntryContainer::getByName) - .def("__iter__", [](py::object s) { return PyTensorEntryContainerIterator(s.cast(), s); }) - ; - - // for e in nnet_packet.entries(): - // e <--- (type(e) == list) - py::class_(m, "PyTensorEntryContainerIterator") - .def("__iter__", [](PyTensorEntryContainerIterator &it) -> PyTensorEntryContainerIterator& { return it; }) - .def("__next__", &PyTensorEntryContainerIterator::next) - ; + // py::class_>(m, "TensorEntryContainer") + // .def("__len__", &TensorEntryContainer::size) + // .def("__getitem__", &TensorEntryContainer::getByIndex) + // .def("__getitem__", &TensorEntryContainer::getByName) + // .def("__iter__", [](py::object s) { return PyTensorEntryContainerIterator(s.cast(), s); }) + // ; + + // // for e in nnet_packet.entries(): + // // e <--- (type(e) == list) + // py::class_(m, "PyTensorEntryContainerIterator") + // .def("__iter__", [](PyTensorEntryContainerIterator &it) -> PyTensorEntryContainerIterator& { return it; }) + // .def("__next__", &PyTensorEntryContainerIterator::next) + // ; // for e in nnet_packet.entries(): // e[0] <-- - py::class_>(m, "TensorEntry") - .def("__len__", &TensorEntry::getPropertiesNumber) - .def("__getitem__", &TensorEntry::getFloat) - .def("__getitem__", &TensorEntry::getFloatByIndex) - ; + // py::class_>(m, "TensorEntry") + // .def("__len__", &TensorEntry::getPropertiesNumber) + // .def("__getitem__", &TensorEntry::getFloat) + // .def("__getitem__", &TensorEntry::getFloatByIndex) + // ; // while True: diff --git a/src/py_tensor_entry_container_iterator.cpp b/src/py_tensor_entry_container_iterator.cpp index 8812259ab..394b4f5e0 100644 --- a/src/py_tensor_entry_container_iterator.cpp +++ b/src/py_tensor_entry_container_iterator.cpp @@ -1,19 +1,19 @@ -#include "py_tensor_entry_container_iterator.hpp" +// #include "py_tensor_entry_container_iterator.hpp" -std::vector PyTensorEntryContainerIterator::next() -{ - while(true) - { - if (index == seq.size()) - { - throw pybind11::stop_iteration(); - } - std::vector next_entry = seq.getByIndex(index++); - if(next_entry.empty()) - { - continue; - } +// std::vector PyTensorEntryContainerIterator::next() +// { +// while(true) +// { +// if (index == seq.size()) +// { +// throw pybind11::stop_iteration(); +// } +// std::vector next_entry = seq.getByIndex(index++); +// if(next_entry.empty()) +// { +// continue; +// } - return next_entry; - } -} +// return next_entry; +// } +// } diff --git a/src/py_tensor_entry_container_iterator.hpp b/src/py_tensor_entry_container_iterator.hpp index a85fbe189..6a34ce899 100644 --- a/src/py_tensor_entry_container_iterator.hpp +++ b/src/py_tensor_entry_container_iterator.hpp @@ -1,27 +1,27 @@ -#pragma once +// #pragma once -// std -#include +// // std +// #include -// pybind11 -#include "pybind11_common.hpp" +// // pybind11 +// #include "pybind11_common.hpp" -//project -#include "depthai/nnet/tensor_entry_container.hpp" +// //project +// #include "depthai/nnet/tensor_entry_container.hpp" -struct PyTensorEntryContainerIterator -{ - PyTensorEntryContainerIterator( - TensorEntryContainer &seq, - pybind11::object ref - ) - : seq(seq) - , ref(ref) - {} +// struct PyTensorEntryContainerIterator +// { +// PyTensorEntryContainerIterator( +// TensorEntryContainer &seq, +// pybind11::object ref +// ) +// : seq(seq) +// , ref(ref) +// {} - std::vector next(); +// std::vector next(); - TensorEntryContainer &seq; - pybind11::object ref; - size_t index = 0; -}; \ No newline at end of file +// TensorEntryContainer &seq; +// pybind11::object ref; +// size_t index = 0; +// }; \ No newline at end of file From 4ccbbbfe6e7a90fb51b1cadcce096a28ade8d244 Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Fri, 18 Sep 2020 18:17:49 +0300 Subject: [PATCH 21/59] Update depthai-core submodule --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 5e49f9927..7c04b3608 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 5e49f99274a40668d11b3d9d5edbf6ec06412138 +Subproject commit 7c04b360804beb0108b4ff9c27118cb4f8f605e9 From 690d622f7accefae63b19ea9f47fd2d1b51eb44f Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Fri, 18 Sep 2020 18:21:15 +0300 Subject: [PATCH 22/59] Update depthai-core submodule --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 358c7c169..d08c79e14 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 358c7c1695a07c4502051050355913501639cc98 +Subproject commit d08c79e14f82a6106a8dd186b34d4fa1590daa5a From 4de8abfb9c0893ed8ec523c7175b59abd154571c Mon Sep 17 00:00:00 2001 From: saching13 Date: Fri, 18 Sep 2020 13:44:53 -0700 Subject: [PATCH 23/59] fixed watchdog error --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index d08c79e14..892b18140 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit d08c79e14f82a6106a8dd186b34d4fa1590daa5a +Subproject commit 892b18140d59d3b7b7f362bb6503d4a87ab848b4 From 57f3024580a68f42dbfbfd7065118c0c2ddb523e Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Sat, 19 Sep 2020 06:04:37 +0300 Subject: [PATCH 24/59] Fix memory leak in getOutputsList, getOutputsDict --- src/nnet_packet_bindings.cpp | 20 +++++++++++--------- src/nnet_packet_bindings.hpp | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/nnet_packet_bindings.cpp b/src/nnet_packet_bindings.cpp index f0b7c3b19..1ee05c887 100644 --- a/src/nnet_packet_bindings.cpp +++ b/src/nnet_packet_bindings.cpp @@ -36,8 +36,8 @@ void init_binding_nnet_packet(pybind11::module& m){ .def("get_tensor", static_cast(&PyNNetPacket::getTensorByName), py::return_value_policy::take_ownership) // .def("entries", &NNetPacket::getTensorEntryContainer, py::return_value_policy::copy) .def("getMetadata", &NNetPacket::getMetadata, py::return_value_policy::copy) - .def("getOutputsList", static_cast(&PyNNetPacket::getOutputsList), py::return_value_policy::copy) - .def("getOutputsDict", static_cast(&PyNNetPacket::getOutputsDict), py::return_value_policy::copy) + .def("getOutputsList", static_cast (NNetPacket::*)()>(&PyNNetPacket::getOutputsList), py::return_value_policy::take_ownership) + .def("getOutputsDict", static_cast (NNetPacket::*)()>(&PyNNetPacket::getOutputsDict), py::return_value_policy::take_ownership) .def("getTensorsSize", &NNetPacket::getTensorsSize, py::return_value_policy::copy) .def("getDetectionCount", &NNetPacket::getDetectionCount, py::return_value_policy::copy) .def("getDetectedObject", static_cast(&PyNNetPacket::getDetectedObject), py::return_value_policy::copy) @@ -83,7 +83,7 @@ template <> }; }} // namespace pybind11::detail -const std::map type_to_numpy_format = { +const std::unordered_map type_to_numpy_format = { {TensorDataType::_fp16, pybind11::format_descriptor::format()}, {TensorDataType::_u8f, pybind11::format_descriptor::format()}, {TensorDataType::_int, pybind11::format_descriptor::format()}, @@ -170,22 +170,24 @@ py::array* PyNNetPacket::getTensorByName(const std::string &name) } -py::list PyNNetPacket::getOutputsList() { - py::list outputList; +std::list PyNNetPacket::getOutputsList() { + + std::list outputList; for (size_t i = 0; i < _tensors_info.size(); ++i) { - outputList.append(getTensor(i)); + outputList.push_back(getTensor(i)); } return outputList; } -py::dict PyNNetPacket::getOutputsDict() { - py::dict outputs; +std::unordered_map PyNNetPacket::getOutputsDict() { + std::unordered_map outputs; for (size_t i = 0; i < _tensors_info.size(); ++i) { std::string tensor_name = getTensorName(i); - outputs[tensor_name.c_str()] = getTensor(i); + // outputs[tensor_name.c_str()] = getTensor(i); + outputs.insert({tensor_name,getTensor(i)}); } return outputs; diff --git a/src/nnet_packet_bindings.hpp b/src/nnet_packet_bindings.hpp index 064b1c006..ae83ec421 100644 --- a/src/nnet_packet_bindings.hpp +++ b/src/nnet_packet_bindings.hpp @@ -15,8 +15,8 @@ struct PyNNetPacket : public NNetPacket { py::object getDetectedObject(int detected_nr); py::array* getTensor(unsigned index); pybind11::array* getTensorByName(const std::string &name); - py::list getOutputsList(); - py::dict getOutputsDict(); + std::list getOutputsList(); + std::unordered_map getOutputsDict(); public: using NNetPacket::_tensors_raw_data; From 82b9e1af9fca4292edda0fe2c5a5459c4a722e3d Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Sat, 19 Sep 2020 06:48:45 +0300 Subject: [PATCH 25/59] Add #include depthai-shared/cnn_info.hpp explicitly --- src/nnet_packet_bindings.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nnet_packet_bindings.cpp b/src/nnet_packet_bindings.cpp index 1ee05c887..6e1c3ad70 100644 --- a/src/nnet_packet_bindings.cpp +++ b/src/nnet_packet_bindings.cpp @@ -7,6 +7,7 @@ //project #include "host_data_packet_bindings.hpp" +#include "depthai-shared/cnn_info.hpp" // pybind11 #include "pybind11_common.hpp" From f3d9f937b2b14afd8caa89cfc3d75765d308d257 Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Sat, 19 Sep 2020 06:52:09 +0300 Subject: [PATCH 26/59] Use map instead unordered_map --- src/nnet_packet_bindings.cpp | 8 ++++---- src/nnet_packet_bindings.hpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/nnet_packet_bindings.cpp b/src/nnet_packet_bindings.cpp index 6e1c3ad70..d43da261b 100644 --- a/src/nnet_packet_bindings.cpp +++ b/src/nnet_packet_bindings.cpp @@ -38,7 +38,7 @@ void init_binding_nnet_packet(pybind11::module& m){ // .def("entries", &NNetPacket::getTensorEntryContainer, py::return_value_policy::copy) .def("getMetadata", &NNetPacket::getMetadata, py::return_value_policy::copy) .def("getOutputsList", static_cast (NNetPacket::*)()>(&PyNNetPacket::getOutputsList), py::return_value_policy::take_ownership) - .def("getOutputsDict", static_cast (NNetPacket::*)()>(&PyNNetPacket::getOutputsDict), py::return_value_policy::take_ownership) + .def("getOutputsDict", static_cast (NNetPacket::*)()>(&PyNNetPacket::getOutputsDict), py::return_value_policy::take_ownership) .def("getTensorsSize", &NNetPacket::getTensorsSize, py::return_value_policy::copy) .def("getDetectionCount", &NNetPacket::getDetectionCount, py::return_value_policy::copy) .def("getDetectedObject", static_cast(&PyNNetPacket::getDetectedObject), py::return_value_policy::copy) @@ -84,7 +84,7 @@ template <> }; }} // namespace pybind11::detail -const std::unordered_map type_to_numpy_format = { +const std::map type_to_numpy_format = { {TensorDataType::_fp16, pybind11::format_descriptor::format()}, {TensorDataType::_u8f, pybind11::format_descriptor::format()}, {TensorDataType::_int, pybind11::format_descriptor::format()}, @@ -182,8 +182,8 @@ std::list PyNNetPacket::getOutputsList() { } -std::unordered_map PyNNetPacket::getOutputsDict() { - std::unordered_map outputs; +std::map PyNNetPacket::getOutputsDict() { + std::map outputs; for (size_t i = 0; i < _tensors_info.size(); ++i) { std::string tensor_name = getTensorName(i); diff --git a/src/nnet_packet_bindings.hpp b/src/nnet_packet_bindings.hpp index ae83ec421..cf752af8a 100644 --- a/src/nnet_packet_bindings.hpp +++ b/src/nnet_packet_bindings.hpp @@ -16,7 +16,7 @@ struct PyNNetPacket : public NNetPacket { py::array* getTensor(unsigned index); pybind11::array* getTensorByName(const std::string &name); std::list getOutputsList(); - std::unordered_map getOutputsDict(); + std::map getOutputsDict(); public: using NNetPacket::_tensors_raw_data; From 83af6e6bcea0041abe25b047561a3a2ab97ed4a9 Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Mon, 21 Sep 2020 06:47:33 +0300 Subject: [PATCH 27/59] Add input,output tensor descriptor getter; improve API --- depthai-core | 2 +- src/nnet_packet_bindings.cpp | 97 +++++++++++++++++++++++++----------- src/nnet_packet_bindings.hpp | 1 - src/py_bindings.cpp | 18 ------- 4 files changed, 68 insertions(+), 50 deletions(-) diff --git a/depthai-core b/depthai-core index 7c04b3608..ee6a3bd27 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 7c04b360804beb0108b4ff9c27118cb4f8f605e9 +Subproject commit ee6a3bd27459ca125d8825d5b0f2bd684af68a40 diff --git a/src/nnet_packet_bindings.cpp b/src/nnet_packet_bindings.cpp index d43da261b..9e36b7f20 100644 --- a/src/nnet_packet_bindings.cpp +++ b/src/nnet_packet_bindings.cpp @@ -41,33 +41,76 @@ void init_binding_nnet_packet(pybind11::module& m){ .def("getOutputsDict", static_cast (NNetPacket::*)()>(&PyNNetPacket::getOutputsDict), py::return_value_policy::take_ownership) .def("getTensorsSize", &NNetPacket::getTensorsSize, py::return_value_policy::copy) .def("getDetectionCount", &NNetPacket::getDetectionCount, py::return_value_policy::copy) - .def("getDetectedObject", static_cast(&PyNNetPacket::getDetectedObject), py::return_value_policy::copy) + .def("getDetectedObject", &NNetPacket::getDetectedObject, py::return_value_policy::copy) + .def("getOutputLayersInfo", &NNetPacket::getOutputLayersInfo, py::return_value_policy::copy) + .def("getInputLayersInfo", &NNetPacket::getInputLayersInfo, py::return_value_policy::copy) + ; - py::class_(m, "Detection") - .def_readonly("label", &detection_t::label) - .def_readonly("confidence", &detection_t::confidence) - .def_readonly("x_min", &detection_t::x_min) - .def_readonly("y_min", &detection_t::y_min) - .def_readonly("x_max", &detection_t::x_max) - .def_readonly("y_max", &detection_t::y_max) - .def_readonly("depth_x", &detection_t::depth_x) - .def_readonly("depth_y", &detection_t::depth_y) - .def_readonly("depth_z", &detection_t::depth_z) - .def("get_dict", []() { + py::class_(m, "TensorDataType") + .def("__str__", [](const TensorDataType& v) { + return type_to_string.at(v); + }) + .def("__repr__", [](const TensorDataType& v) { + return type_to_string.at(v); + }) + ; + + py::class_(m, "TensorInfo") + .def_readonly("tensor_name", &TensorInfo::tensor_name) + .def_readonly("tensor_dimensions", &TensorInfo::tensor_dimensions) + .def_readonly("tensor_strides", &TensorInfo::tensor_strides) + .def_readonly("tensor_data_type", &TensorInfo::tensor_data_type) + .def_readonly("tensor_offset", &TensorInfo::tensor_offset) + .def_readonly("tensor_element_size", &TensorInfo::tensor_element_size) + .def_readonly("tensor_idx", &TensorInfo::tensor_idx) + .def("get_dict", []() { py::dict d; - d["label"] = &detection_t::label; - d["confidence"] = &detection_t::confidence; - d["x_min"] = &detection_t::x_min; - d["y_min"] = &detection_t::y_min; - d["x_max"] = &detection_t::x_max; - d["y_max"] = &detection_t::y_max; - d["depth_x"] = &detection_t::depth_x; - d["depth_y"] = &detection_t::depth_y; - d["depth_z"] = &detection_t::depth_z; + d["tensor_name"] = &TensorInfo::tensor_name; + d["tensor_dimensions"] = &TensorInfo::tensor_dimensions; + d["tensor_strides"] = &TensorInfo::tensor_strides; + d["tensor_data_type"] = &TensorInfo::tensor_data_type; + d["tensor_offset"] = &TensorInfo::tensor_offset; + d["tensor_element_size"] = &TensorInfo::tensor_element_size; + d["tensor_idx"] = &TensorInfo::tensor_idx; return d; }) - ; + .def("__str__", [](const TensorInfo& v) { + std::stringstream stream; + stream << v; + return stream.str(); + }) + .def("__repr__", [](const TensorInfo& v) { + std::stringstream stream; + stream << v; + return stream.str(); + }) + ; + + py::class_(m, "Detection") + .def_readonly("label", &detection_t::label) + .def_readonly("confidence", &detection_t::confidence) + .def_readonly("x_min", &detection_t::x_min) + .def_readonly("y_min", &detection_t::y_min) + .def_readonly("x_max", &detection_t::x_max) + .def_readonly("y_max", &detection_t::y_max) + .def_readonly("depth_x", &detection_t::depth_x) + .def_readonly("depth_y", &detection_t::depth_y) + .def_readonly("depth_z", &detection_t::depth_z) + .def("get_dict", []() { + py::dict d; + d["label"] = &detection_t::label; + d["confidence"] = &detection_t::confidence; + d["x_min"] = &detection_t::x_min; + d["y_min"] = &detection_t::y_min; + d["x_max"] = &detection_t::x_max; + d["y_max"] = &detection_t::y_max; + d["depth_x"] = &detection_t::depth_x; + d["depth_y"] = &detection_t::depth_y; + d["depth_z"] = &detection_t::depth_z; + return d; + }) + ; } @@ -100,13 +143,7 @@ std::string type_to_npy_format_descriptor(const TensorDataType& type) }; -py::object PyNNetPacket::getDetectedObject(int detected_nr) -{ - unsigned char * data = _tensors_raw_data->data.data(); - detection_out_t * detections = (detection_out_t *)data; - assert(detected_nr < detections->detection_count); - return py::cast(detections->detections[detected_nr]); -} + // TODO - zero copy //https://github.com/pybind/pybind11/issues/323#issuecomment-575717041 @@ -117,7 +154,7 @@ static py::array* _getTensorPythonNumpyArray(unsigned char *data, TensorInfo ti) py::array* result = nullptr; ssize_t ndim = ti.tensor_dimensions.size(); - ssize_t element_size = size_of_type(ti.tensor_data_type); + ssize_t element_size = c_type_size.at(ti.tensor_data_type); std::string numpy_format_descriptor = type_to_npy_format_descriptor(ti.tensor_data_type); std::vector shape; std::vector strides; diff --git a/src/nnet_packet_bindings.hpp b/src/nnet_packet_bindings.hpp index cf752af8a..8e2ca9376 100644 --- a/src/nnet_packet_bindings.hpp +++ b/src/nnet_packet_bindings.hpp @@ -12,7 +12,6 @@ namespace py = pybind11; struct PyNNetPacket : public NNetPacket { - py::object getDetectedObject(int detected_nr); py::array* getTensor(unsigned index); pybind11::array* getTensorByName(const std::string &name); std::list getOutputsList(); diff --git a/src/py_bindings.cpp b/src/py_bindings.cpp index 63ea8ec25..64ec42ce0 100644 --- a/src/py_bindings.cpp +++ b/src/py_bindings.cpp @@ -71,24 +71,6 @@ PYBIND11_MODULE(depthai,m) // ; - // while True: - // nnet_packets, data_packets = p.get_available_nnet_and_data_packets() - // # nnet_packets: depthai.NNetPacketList - // # data_packets: depthai.DataPacketList - - // for t in nnet_packets.getTensors(): - // pass - - // for nnet_packet in nnet_packets: - // # nnet_packet: depthai.NNetPacket - // # nnet_packet.entries(): depthai.TensorEntryContainer - - // for e in nnet_packet.entries(): - // # e: list - // # e[0]: depthai.TensorEntry - // # e[0][0]: float - - py::class_(m, "Pipeline") .def("get_available_data_packets", &HostPipeline::getAvailableDataPackets, py::arg("blocking") = false, py::return_value_policy::copy) ; From 3bad643ed1a017ce689b833553e3fdafda0ba021 Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Tue, 22 Sep 2020 04:55:26 +0300 Subject: [PATCH 28/59] Cleanup API, add iterator for detections; wrap packet data in shared_ptr --- CMakeLists.txt | 1 - depthai-core | 2 +- src/host_data_packet_bindings.cpp | 6 ++--- src/nnet_packet_bindings.cpp | 18 +++++++++++---- src/py_bindings.cpp | 26 --------------------- src/py_tensor_entry_container_iterator.cpp | 19 --------------- src/py_tensor_entry_container_iterator.hpp | 27 ---------------------- 7 files changed, 18 insertions(+), 81 deletions(-) delete mode 100644 src/py_tensor_entry_container_iterator.cpp delete mode 100644 src/py_tensor_entry_container_iterator.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index cdb88892b..2462f60ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,6 @@ pybind11_add_module(${TARGET_NAME} src/py_bindings.cpp src/host_data_packet_bindings.cpp src/nnet_packet_bindings.cpp - src/py_tensor_entry_container_iterator.cpp src/device_bindings.cpp ) diff --git a/depthai-core b/depthai-core index ee6a3bd27..2f6abfa5d 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit ee6a3bd27459ca125d8825d5b0f2bd684af68a40 +Subproject commit 2f6abfa5df58e1fe2039fb5f1f0897303ed73239 diff --git a/src/host_data_packet_bindings.cpp b/src/host_data_packet_bindings.cpp index b70721bc8..06a303041 100644 --- a/src/host_data_packet_bindings.cpp +++ b/src/host_data_packet_bindings.cpp @@ -79,7 +79,7 @@ void init_binding_host_data_packet(pybind11::module& m){ py::array* PyHostDataPacket::getPythonNumpyArray() { assert(!dimensions.empty()); - assert(!data.empty()); + assert(!data->empty()); Timer t; @@ -105,7 +105,7 @@ py::array* PyHostDataPacket::getPythonNumpyArray() if (elem_size == 1) { result = new py::array(py::buffer_info( - data.data(), /* data as contiguous array */ + data->data(), /* data as contiguous array */ sizeof(unsigned char), /* size of one scalar */ py::format_descriptor::format(), /* data type */ ndim, /* number of dimensions */ @@ -116,7 +116,7 @@ py::array* PyHostDataPacket::getPythonNumpyArray() else if (elem_size == 2) { result = new py::array(py::buffer_info( - data.data(), /* data as contiguous array */ + data->data(), /* data as contiguous array */ sizeof(std::uint16_t), /* size of one scalar */ py::format_descriptor::format(), /* data type */ 2, //ndim, /* number of dimensions */ diff --git a/src/nnet_packet_bindings.cpp b/src/nnet_packet_bindings.cpp index 9e36b7f20..f8a06dc8b 100644 --- a/src/nnet_packet_bindings.cpp +++ b/src/nnet_packet_bindings.cpp @@ -30,21 +30,31 @@ void init_binding_nnet_packet(pybind11::module& m){ }, py::keep_alive<0, 1>()) /* Keep list alive while iterator is used */ ; + py::class_>(m, "Detections") + .def_readonly("size", &detection_out_t::detection_count) + .def("__len__", [](const detection_out_t &det) { return det.detection_count; }) + .def("__getitem__", [](const detection_out_t &det, int idx) { return det.detections[idx]; }) + .def("__iter__", [](std::shared_ptr &v) + { + const detection_t *detection_vec = v->detections; + return py::make_iterator(&detection_vec[0], &detection_vec[v->detection_count]); + }, py::keep_alive<0, 1>()) /* Keep list alive while iterator is used */ + ; // for NNET_PACKET in nnet_packets: py::class_>(m, "NNetPacket") .def("get_tensor", static_cast(&PyNNetPacket::getTensor), py::return_value_policy::take_ownership) .def("get_tensor", static_cast(&PyNNetPacket::getTensorByName), py::return_value_policy::take_ownership) + .def("__getitem__", static_cast(&PyNNetPacket::getTensor), py::return_value_policy::take_ownership) + .def("__getitem__", static_cast(&PyNNetPacket::getTensorByName), py::return_value_policy::take_ownership) // .def("entries", &NNetPacket::getTensorEntryContainer, py::return_value_policy::copy) .def("getMetadata", &NNetPacket::getMetadata, py::return_value_policy::copy) .def("getOutputsList", static_cast (NNetPacket::*)()>(&PyNNetPacket::getOutputsList), py::return_value_policy::take_ownership) .def("getOutputsDict", static_cast (NNetPacket::*)()>(&PyNNetPacket::getOutputsDict), py::return_value_policy::take_ownership) .def("getTensorsSize", &NNetPacket::getTensorsSize, py::return_value_policy::copy) - .def("getDetectionCount", &NNetPacket::getDetectionCount, py::return_value_policy::copy) - .def("getDetectedObject", &NNetPacket::getDetectedObject, py::return_value_policy::copy) .def("getOutputLayersInfo", &NNetPacket::getOutputLayersInfo, py::return_value_policy::copy) .def("getInputLayersInfo", &NNetPacket::getInputLayersInfo, py::return_value_policy::copy) - + .def("getDetectedObjects", &NNetPacket::getDetectedObjects) ; py::class_(m, "TensorDataType") @@ -190,7 +200,7 @@ py::array* PyNNetPacket::getTensor(unsigned index) { assert(index < _tensors_info.size()); TensorInfo ti = _tensors_info[index]; - unsigned char * data = _tensors_raw_data->data.data(); + unsigned char * data = _tensors_raw_data->data->data(); return _getTensorPythonNumpyArray(data, ti); } diff --git a/src/py_bindings.cpp b/src/py_bindings.cpp index 64ec42ce0..1d1597f83 100644 --- a/src/py_bindings.cpp +++ b/src/py_bindings.cpp @@ -18,7 +18,6 @@ // project #include "host_data_packet_bindings.hpp" #include "nnet_packet_bindings.hpp" -#include "py_tensor_entry_container_iterator.hpp" #include "device_bindings.hpp" @@ -46,31 +45,6 @@ PYBIND11_MODULE(depthai,m) //std::string _dev_version = c_depthai_dev_version; //m.attr("__dev_version__") = "badf00d"; - - // for te in nnet_packet.ENTRIES() - // py::class_>(m, "TensorEntryContainer") - // .def("__len__", &TensorEntryContainer::size) - // .def("__getitem__", &TensorEntryContainer::getByIndex) - // .def("__getitem__", &TensorEntryContainer::getByName) - // .def("__iter__", [](py::object s) { return PyTensorEntryContainerIterator(s.cast(), s); }) - // ; - - // // for e in nnet_packet.entries(): - // // e <--- (type(e) == list) - // py::class_(m, "PyTensorEntryContainerIterator") - // .def("__iter__", [](PyTensorEntryContainerIterator &it) -> PyTensorEntryContainerIterator& { return it; }) - // .def("__next__", &PyTensorEntryContainerIterator::next) - // ; - - // for e in nnet_packet.entries(): - // e[0] <-- - // py::class_>(m, "TensorEntry") - // .def("__len__", &TensorEntry::getPropertiesNumber) - // .def("__getitem__", &TensorEntry::getFloat) - // .def("__getitem__", &TensorEntry::getFloatByIndex) - // ; - - py::class_(m, "Pipeline") .def("get_available_data_packets", &HostPipeline::getAvailableDataPackets, py::arg("blocking") = false, py::return_value_policy::copy) ; diff --git a/src/py_tensor_entry_container_iterator.cpp b/src/py_tensor_entry_container_iterator.cpp deleted file mode 100644 index 394b4f5e0..000000000 --- a/src/py_tensor_entry_container_iterator.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// #include "py_tensor_entry_container_iterator.hpp" - -// std::vector PyTensorEntryContainerIterator::next() -// { -// while(true) -// { -// if (index == seq.size()) -// { -// throw pybind11::stop_iteration(); -// } -// std::vector next_entry = seq.getByIndex(index++); -// if(next_entry.empty()) -// { -// continue; -// } - -// return next_entry; -// } -// } diff --git a/src/py_tensor_entry_container_iterator.hpp b/src/py_tensor_entry_container_iterator.hpp deleted file mode 100644 index 6a34ce899..000000000 --- a/src/py_tensor_entry_container_iterator.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// #pragma once - -// // std -// #include - -// // pybind11 -// #include "pybind11_common.hpp" - -// //project -// #include "depthai/nnet/tensor_entry_container.hpp" - -// struct PyTensorEntryContainerIterator -// { -// PyTensorEntryContainerIterator( -// TensorEntryContainer &seq, -// pybind11::object ref -// ) -// : seq(seq) -// , ref(ref) -// {} - -// std::vector next(); - -// TensorEntryContainer &seq; -// pybind11::object ref; -// size_t index = 0; -// }; \ No newline at end of file From 688de54114a177199f5905148e8b753e5ab9a4d8 Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Tue, 22 Sep 2020 07:13:11 +0300 Subject: [PATCH 29/59] Add support to run network without user defined JSON --- depthai-core | 2 +- src/nnet_packet_bindings.cpp | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/depthai-core b/depthai-core index 2f6abfa5d..890374283 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 2f6abfa5df58e1fe2039fb5f1f0897303ed73239 +Subproject commit 890374283c39552ffdf6c0cfb29e60b3c30b12ac diff --git a/src/nnet_packet_bindings.cpp b/src/nnet_packet_bindings.cpp index f8a06dc8b..3d1872007 100644 --- a/src/nnet_packet_bindings.cpp +++ b/src/nnet_packet_bindings.cpp @@ -30,17 +30,6 @@ void init_binding_nnet_packet(pybind11::module& m){ }, py::keep_alive<0, 1>()) /* Keep list alive while iterator is used */ ; - py::class_>(m, "Detections") - .def_readonly("size", &detection_out_t::detection_count) - .def("__len__", [](const detection_out_t &det) { return det.detection_count; }) - .def("__getitem__", [](const detection_out_t &det, int idx) { return det.detections[idx]; }) - .def("__iter__", [](std::shared_ptr &v) - { - const detection_t *detection_vec = v->detections; - return py::make_iterator(&detection_vec[0], &detection_vec[v->detection_count]); - }, py::keep_alive<0, 1>()) /* Keep list alive while iterator is used */ - ; - // for NNET_PACKET in nnet_packets: py::class_>(m, "NNetPacket") .def("get_tensor", static_cast(&PyNNetPacket::getTensor), py::return_value_policy::take_ownership) @@ -97,6 +86,17 @@ void init_binding_nnet_packet(pybind11::module& m){ }) ; + py::class_>(m, "Detections") + .def_readonly("size", &detection_out_t::detection_count) + .def("__len__", [](const detection_out_t &det) { return det.detection_count; }) + .def("__getitem__", [](const detection_out_t &det, int idx) { return det.detections[idx]; }) + .def("__iter__", [](std::shared_ptr &v) + { + const detection_t *detection_vec = v->detections; + return py::make_iterator(&detection_vec[0], &detection_vec[v->detection_count]); + }, py::keep_alive<0, 1>()) /* Keep list alive while iterator is used */ + ; + py::class_(m, "Detection") .def_readonly("label", &detection_t::label) .def_readonly("confidence", &detection_t::confidence) From f15fb4f243d45912a560a2c7bad6fac7e8b48a56 Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Wed, 23 Sep 2020 21:26:33 +0300 Subject: [PATCH 30/59] Update core submodule --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 890374283..394df80e4 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 890374283c39552ffdf6c0cfb29e60b3c30b12ac +Subproject commit 394df80e4780c501c038cbc8256a855122aaec78 From cca8c2b74b28814bef9462bdf8128ef74d42ad16 Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Thu, 24 Sep 2020 01:55:38 +0300 Subject: [PATCH 31/59] Add get_dimension to python API --- depthai-core | 2 +- src/nnet_packet_bindings.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 394df80e4..6784f5d47 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 394df80e4780c501c038cbc8256a855122aaec78 +Subproject commit 6784f5d47ed41e1041413f34b2a55de9956a1bf0 diff --git a/src/nnet_packet_bindings.cpp b/src/nnet_packet_bindings.cpp index 3d1872007..284046194 100644 --- a/src/nnet_packet_bindings.cpp +++ b/src/nnet_packet_bindings.cpp @@ -55,7 +55,22 @@ void init_binding_nnet_packet(pybind11::module& m){ }) ; + py::enum_(m, "dimension") + .value("W", dimension::W) + .value("H", dimension::H) + .value("C ", dimension::C) + .value("N", dimension::N) + .value("B", dimension::B) + .value("WIDTH", dimension::WIDTH) + .value("HEIGHT", dimension::HEIGHT) + .value("CHANNEL", dimension::CHANNEL) + .value("NUMBER", dimension::NUMBER) + .value("BATCH", dimension::BATCH) + .export_values() + ; + py::class_(m, "TensorInfo") + .def("get_dimension", &TensorInfo::get_dimension) .def_readonly("tensor_name", &TensorInfo::tensor_name) .def_readonly("tensor_dimensions", &TensorInfo::tensor_dimensions) .def_readonly("tensor_strides", &TensorInfo::tensor_strides) From 5faedf643bb5409a0898b5d011926bb15350879a Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Thu, 24 Sep 2020 02:32:46 +0300 Subject: [PATCH 32/59] Update core submodule --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 6784f5d47..4ec4752c3 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 6784f5d47ed41e1041413f34b2a55de9956a1bf0 +Subproject commit 4ec4752c372f277c5dc23b59ee6382cd77a3b1b3 From b55ccbb1c8c78476611fc317b78024acedaf500e Mon Sep 17 00:00:00 2001 From: GergelySzabolcs Date: Thu, 24 Sep 2020 02:51:36 +0300 Subject: [PATCH 33/59] Update core submodule --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 4ec4752c3..0f8615f6e 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 4ec4752c372f277c5dc23b59ee6382cd77a3b1b3 +Subproject commit 0f8615f6e77ff3698bb79a9e9211079b60646f2e From b7fab354972ba070ed77107f14707f1a6bf9774e Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Tue, 29 Sep 2020 00:44:36 +0300 Subject: [PATCH 34/59] Add ISP 3A camera controls --- depthai-core | 2 +- src/device_bindings.cpp | 53 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 892b18140..6b4974573 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 892b18140d59d3b7b7f362bb6503d4a87ab848b4 +Subproject commit 6b4974573ec2422dbf75eeb72c3ffe2fc8da1758 diff --git a/src/device_bindings.cpp b/src/device_bindings.cpp index f6cedbc77..8e7ebfe66 100644 --- a/src/device_bindings.cpp +++ b/src/device_bindings.cpp @@ -71,6 +71,15 @@ void init_binding_device(pybind11::module& m){ "Function to send disparity confidence threshold for SGBM" ) + .def( + "send_camera_control", + &Device::send_camera_control, + "Function to send an ISP 3A camera control command", + py::arg("camera_id"), + py::arg("command_id"), + py::arg("extra_args") + ) + .def( "get_nn_to_depth_bbox_mapping", &Device::get_nn_to_depth_bbox_mapping, @@ -127,5 +136,49 @@ void init_binding_device(pybind11::module& m){ .value("AF_MODE_EDOF", CaptureMetadata::AutofocusMode::AF_MODE_EDOF) ; + py::enum_(m, "Cam3A") + .value("RGB", Isp3A_CamId::CAM_RGB) + .value("Left", Isp3A_CamId::CAM_LEFT) + .value("Right", Isp3A_CamId::CAM_RIGHT) + ; + + py::enum_(m, "Isp3A") + .value("CMD_START_STREAM", Isp3A_Commands::CMD_START_STREAM) + .value("CMD_STOP_STREAM", Isp3A_Commands::CMD_STOP_STREAM) + .value("CMD_REQ_STILL", Isp3A_Commands::CMD_REQ_STILL) + .value("CMD_MOV_LENS", Isp3A_Commands::CMD_MOV_LENS) + .value("CMD_FOCUS_TRIGGER", Isp3A_Commands::CMD_FOCUS_TRIGGER) + .value("CMD_AE_MANUAL", Isp3A_Commands::CMD_AE_MANUAL) + .value("CMD_AE_AUTO", Isp3A_Commands::CMD_AE_AUTO) + .value("CMD_SET_AWB_MODE", Isp3A_Commands::CMD_SET_AWB_MODE) + .value("CMD_SCENE_MODES", Isp3A_Commands::CMD_SCENE_MODES) + .value("CMD_ANTIBANDING_MODES", Isp3A_Commands::CMD_ANTIBANDING_MODES) + .value("CMD_EXPOSURE_COMPENSATION", Isp3A_Commands::CMD_EXPOSURE_COMPENSATION) + .value("CMD_AE_LOCK", Isp3A_Commands::CMD_AE_LOCK) + .value("CMD_AE_TARGET_FPS_RANGE", Isp3A_Commands::CMD_AE_TARGET_FPS_RANGE) + .value("CMD_AWB_LOCK", Isp3A_Commands::CMD_AWB_LOCK) + .value("CMD_CAPTURE_INTENT", Isp3A_Commands::CMD_CAPTURE_INTENT) + .value("CMD_CONTROL_MODE", Isp3A_Commands::CMD_CONTROL_MODE) + .value("CMD_FRAME_DURATION", Isp3A_Commands::CMD_FRAME_DURATION) + .value("CMD_SENSITIVITY", Isp3A_Commands::CMD_SENSITIVITY) + .value("CMD_EFFECT_MODE", Isp3A_Commands::CMD_EFFECT_MODE) + .value("CMD_AF_MODE", Isp3A_Commands::CMD_AF_MODE) + .value("CMD_NOISE_REDUCTION_STRENGTH", Isp3A_Commands::CMD_NOISE_REDUCTION_STRENGTH) + .value("CMD_SATURATION", Isp3A_Commands::CMD_SATURATION) + .value("CMD_BRIGHTNESS", Isp3A_Commands::CMD_BRIGHTNESS) + .value("CMD_STREAM_FORMAT", Isp3A_Commands::CMD_STREAM_FORMAT) + .value("CMD_CAM_RESOLUTION", Isp3A_Commands::CMD_CAM_RESOLUTION) + .value("CMD_SHARPNESS", Isp3A_Commands::CMD_SHARPNESS) + .value("CMD_CUST_USECASE", Isp3A_Commands::CMD_CUST_USECASE) + .value("CMD_CUST_CAPT_MODE", Isp3A_Commands::CMD_CUST_CAPT_MODE) + .value("CMD_CUST_EXP_BRACKETS", Isp3A_Commands::CMD_CUST_EXP_BRACKETS) + .value("CMD_CUST_CAPTURE", Isp3A_Commands::CMD_CUST_CAPTURE) + .value("CMD_CONTRAST", Isp3A_Commands::CMD_CONTRAST) + .value("CMD_AE_REGION", Isp3A_Commands::CMD_AE_REGION) + .value("CMD_AF_REGION", Isp3A_Commands::CMD_AF_REGION) + .value("CMD_LUMA_DENOISE", Isp3A_Commands::CMD_LUMA_DENOISE) + .value("CMD_CHROMA_DENOISE", Isp3A_Commands::CMD_CHROMA_DENOISE) + ; + } From c1af2c2c0a9b2f4325c2ad4bc114daf33ac17d29 Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Mon, 5 Oct 2020 15:53:35 +0300 Subject: [PATCH 35/59] Address PR review; rename dimension to Dimension, detections_out_t to Detections; detection_t to Detection for consistency --- depthai-core | 2 +- src/nnet_packet_bindings.cpp | 103 ++++++++++++++++++----------------- 2 files changed, 53 insertions(+), 52 deletions(-) diff --git a/depthai-core b/depthai-core index 0f8615f6e..03b14e319 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 0f8615f6e77ff3698bb79a9e9211079b60646f2e +Subproject commit 03b14e319aa746886fcce124d0286911816d2ed1 diff --git a/src/nnet_packet_bindings.cpp b/src/nnet_packet_bindings.cpp index 284046194..d4257c790 100644 --- a/src/nnet_packet_bindings.cpp +++ b/src/nnet_packet_bindings.cpp @@ -14,7 +14,9 @@ namespace py = pybind11; - +using TensorInfo = dai::TensorInfo; +using Detection = dai::Detection; +using Detections = dai::Detections; PYBIND11_MAKE_OPAQUE(std::list>); @@ -46,27 +48,26 @@ void init_binding_nnet_packet(pybind11::module& m){ .def("getDetectedObjects", &NNetPacket::getDetectedObjects) ; - py::class_(m, "TensorDataType") - .def("__str__", [](const TensorDataType& v) { - return type_to_string.at(v); + py::class_(m, "TensorDataType") + .def("__str__", [](const TensorInfo::TensorDataType& v) { + return TensorInfo::type_to_string.at(v); }) - .def("__repr__", [](const TensorDataType& v) { - return type_to_string.at(v); + .def("__repr__", [](const TensorInfo::TensorDataType& v) { + return TensorInfo::type_to_string.at(v); }) ; - py::enum_(m, "dimension") - .value("W", dimension::W) - .value("H", dimension::H) - .value("C ", dimension::C) - .value("N", dimension::N) - .value("B", dimension::B) - .value("WIDTH", dimension::WIDTH) - .value("HEIGHT", dimension::HEIGHT) - .value("CHANNEL", dimension::CHANNEL) - .value("NUMBER", dimension::NUMBER) - .value("BATCH", dimension::BATCH) - .export_values() + py::enum_(m, "Dimension") + .value("W", TensorInfo::Dimension::W) + .value("H", TensorInfo::Dimension::H) + .value("C ", TensorInfo::Dimension::C) + .value("N", TensorInfo::Dimension::N) + .value("B", TensorInfo::Dimension::B) + .value("WIDTH", TensorInfo::Dimension::WIDTH) + .value("HEIGHT", TensorInfo::Dimension::HEIGHT) + .value("CHANNEL", TensorInfo::Dimension::CHANNEL) + .value("NUMBER", TensorInfo::Dimension::NUMBER) + .value("BATCH", TensorInfo::Dimension::BATCH) ; py::class_(m, "TensorInfo") @@ -101,38 +102,38 @@ void init_binding_nnet_packet(pybind11::module& m){ }) ; - py::class_>(m, "Detections") - .def_readonly("size", &detection_out_t::detection_count) - .def("__len__", [](const detection_out_t &det) { return det.detection_count; }) - .def("__getitem__", [](const detection_out_t &det, int idx) { return det.detections[idx]; }) - .def("__iter__", [](std::shared_ptr &v) + py::class_>(m, "Detections") + .def_readonly("size", &Detections::detection_count) + .def("__len__", [](const Detections &det) { return det.detection_count; }) + .def("__getitem__", [](const Detections &det, int idx) { return det.detections[idx]; }) + .def("__iter__", [](std::shared_ptr &v) { - const detection_t *detection_vec = v->detections; + const Detection *detection_vec = v->detections; return py::make_iterator(&detection_vec[0], &detection_vec[v->detection_count]); }, py::keep_alive<0, 1>()) /* Keep list alive while iterator is used */ ; - py::class_(m, "Detection") - .def_readonly("label", &detection_t::label) - .def_readonly("confidence", &detection_t::confidence) - .def_readonly("x_min", &detection_t::x_min) - .def_readonly("y_min", &detection_t::y_min) - .def_readonly("x_max", &detection_t::x_max) - .def_readonly("y_max", &detection_t::y_max) - .def_readonly("depth_x", &detection_t::depth_x) - .def_readonly("depth_y", &detection_t::depth_y) - .def_readonly("depth_z", &detection_t::depth_z) + py::class_(m, "Detection") + .def_readonly("label", &Detection::label) + .def_readonly("confidence", &Detection::confidence) + .def_readonly("x_min", &Detection::x_min) + .def_readonly("y_min", &Detection::y_min) + .def_readonly("x_max", &Detection::x_max) + .def_readonly("y_max", &Detection::y_max) + .def_readonly("depth_x", &Detection::depth_x) + .def_readonly("depth_y", &Detection::depth_y) + .def_readonly("depth_z", &Detection::depth_z) .def("get_dict", []() { py::dict d; - d["label"] = &detection_t::label; - d["confidence"] = &detection_t::confidence; - d["x_min"] = &detection_t::x_min; - d["y_min"] = &detection_t::y_min; - d["x_max"] = &detection_t::x_max; - d["y_max"] = &detection_t::y_max; - d["depth_x"] = &detection_t::depth_x; - d["depth_y"] = &detection_t::depth_y; - d["depth_z"] = &detection_t::depth_z; + d["label"] = &Detection::label; + d["confidence"] = &Detection::confidence; + d["x_min"] = &Detection::x_min; + d["y_min"] = &Detection::y_min; + d["x_max"] = &Detection::x_max; + d["y_max"] = &Detection::y_max; + d["depth_x"] = &Detection::depth_x; + d["depth_y"] = &Detection::depth_y; + d["depth_z"] = &Detection::depth_z; return d; }) ; @@ -152,15 +153,15 @@ template <> }; }} // namespace pybind11::detail -const std::map type_to_numpy_format = { - {TensorDataType::_fp16, pybind11::format_descriptor::format()}, - {TensorDataType::_u8f, pybind11::format_descriptor::format()}, - {TensorDataType::_int, pybind11::format_descriptor::format()}, - {TensorDataType::_fp32, pybind11::format_descriptor::format()}, - {TensorDataType::_i8, pybind11::format_descriptor::format()}, +static const std::map type_to_numpy_format = { + {TensorInfo::TensorDataType::_fp16, pybind11::format_descriptor::format()}, + {TensorInfo::TensorDataType::_u8f, pybind11::format_descriptor::format()}, + {TensorInfo::TensorDataType::_int, pybind11::format_descriptor::format()}, + {TensorInfo::TensorDataType::_fp32, pybind11::format_descriptor::format()}, + {TensorInfo::TensorDataType::_i8, pybind11::format_descriptor::format()}, }; -std::string type_to_npy_format_descriptor(const TensorDataType& type) +static std::string type_to_npy_format_descriptor(const TensorInfo::TensorDataType& type) { auto it = type_to_numpy_format.find(type); assert(it != type_to_numpy_format.end()); @@ -179,7 +180,7 @@ static py::array* _getTensorPythonNumpyArray(unsigned char *data, TensorInfo ti) py::array* result = nullptr; ssize_t ndim = ti.tensor_dimensions.size(); - ssize_t element_size = c_type_size.at(ti.tensor_data_type); + ssize_t element_size = TensorInfo::c_type_size.at(ti.tensor_data_type); std::string numpy_format_descriptor = type_to_npy_format_descriptor(ti.tensor_data_type); std::vector shape; std::vector strides; From 601755e91f56b2fbb803644a1a900a7155e0166f Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Mon, 5 Oct 2020 20:09:42 +0300 Subject: [PATCH 36/59] Update python api --- depthai-core | 2 +- src/nnet_packet_bindings.cpp | 106 +++++++++++++++++------------------ 2 files changed, 53 insertions(+), 55 deletions(-) diff --git a/depthai-core b/depthai-core index 03b14e319..eeea37a25 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 03b14e319aa746886fcce124d0286911816d2ed1 +Subproject commit eeea37a25f9a6e22f7693d60e977fff34ecd7874 diff --git a/src/nnet_packet_bindings.cpp b/src/nnet_packet_bindings.cpp index d4257c790..2443db0a6 100644 --- a/src/nnet_packet_bindings.cpp +++ b/src/nnet_packet_bindings.cpp @@ -38,7 +38,6 @@ void init_binding_nnet_packet(pybind11::module& m){ .def("get_tensor", static_cast(&PyNNetPacket::getTensorByName), py::return_value_policy::take_ownership) .def("__getitem__", static_cast(&PyNNetPacket::getTensor), py::return_value_policy::take_ownership) .def("__getitem__", static_cast(&PyNNetPacket::getTensorByName), py::return_value_policy::take_ownership) - // .def("entries", &NNetPacket::getTensorEntryContainer, py::return_value_policy::copy) .def("getMetadata", &NNetPacket::getMetadata, py::return_value_policy::copy) .def("getOutputsList", static_cast (NNetPacket::*)()>(&PyNNetPacket::getOutputsList), py::return_value_policy::take_ownership) .def("getOutputsDict", static_cast (NNetPacket::*)()>(&PyNNetPacket::getOutputsDict), py::return_value_policy::take_ownership) @@ -48,16 +47,47 @@ void init_binding_nnet_packet(pybind11::module& m){ .def("getDetectedObjects", &NNetPacket::getDetectedObjects) ; - py::class_(m, "TensorDataType") - .def("__str__", [](const TensorInfo::TensorDataType& v) { + py::class_ tensorInfo(m, "TensorInfo"); + tensorInfo.def("get_dimension", &TensorInfo::get_dimension); + tensorInfo.def_readonly("name", &TensorInfo::name); + tensorInfo.def_readonly("dimensions", &TensorInfo::dimensions); + tensorInfo.def_readonly("strides", &TensorInfo::strides); + tensorInfo.def_readonly("data_type", &TensorInfo::data_type); + tensorInfo.def_readonly("offset", &TensorInfo::offset); + tensorInfo.def_readonly("element_size", &TensorInfo::element_size); + tensorInfo.def_readonly("index", &TensorInfo::index); + tensorInfo.def("get_dict", []() { + py::dict d; + d["name"] = &TensorInfo::name; + d["dimensions"] = &TensorInfo::dimensions; + d["strides"] = &TensorInfo::strides; + d["data_type"] = &TensorInfo::data_type; + d["offset"] = &TensorInfo::offset; + d["element_size"] = &TensorInfo::element_size; + d["index"] = &TensorInfo::index; + return d; + }); + tensorInfo.def("__str__", [](const TensorInfo& v) { + std::stringstream stream; + stream << v; + return stream.str(); + }); + tensorInfo.def("__repr__", [](const TensorInfo& v) { + std::stringstream stream; + stream << v; + return stream.str(); + }); + + py::class_(tensorInfo, "DataType") + .def("__str__", [](const TensorInfo::DataType& v) { return TensorInfo::type_to_string.at(v); }) - .def("__repr__", [](const TensorInfo::TensorDataType& v) { + .def("__repr__", [](const TensorInfo::DataType& v) { return TensorInfo::type_to_string.at(v); }) ; - py::enum_(m, "Dimension") + py::enum_(tensorInfo, "Dimension") .value("W", TensorInfo::Dimension::W) .value("H", TensorInfo::Dimension::H) .value("C ", TensorInfo::Dimension::C) @@ -70,38 +100,6 @@ void init_binding_nnet_packet(pybind11::module& m){ .value("BATCH", TensorInfo::Dimension::BATCH) ; - py::class_(m, "TensorInfo") - .def("get_dimension", &TensorInfo::get_dimension) - .def_readonly("tensor_name", &TensorInfo::tensor_name) - .def_readonly("tensor_dimensions", &TensorInfo::tensor_dimensions) - .def_readonly("tensor_strides", &TensorInfo::tensor_strides) - .def_readonly("tensor_data_type", &TensorInfo::tensor_data_type) - .def_readonly("tensor_offset", &TensorInfo::tensor_offset) - .def_readonly("tensor_element_size", &TensorInfo::tensor_element_size) - .def_readonly("tensor_idx", &TensorInfo::tensor_idx) - .def("get_dict", []() { - py::dict d; - d["tensor_name"] = &TensorInfo::tensor_name; - d["tensor_dimensions"] = &TensorInfo::tensor_dimensions; - d["tensor_strides"] = &TensorInfo::tensor_strides; - d["tensor_data_type"] = &TensorInfo::tensor_data_type; - d["tensor_offset"] = &TensorInfo::tensor_offset; - d["tensor_element_size"] = &TensorInfo::tensor_element_size; - d["tensor_idx"] = &TensorInfo::tensor_idx; - return d; - }) - .def("__str__", [](const TensorInfo& v) { - std::stringstream stream; - stream << v; - return stream.str(); - }) - .def("__repr__", [](const TensorInfo& v) { - std::stringstream stream; - stream << v; - return stream.str(); - }) - ; - py::class_>(m, "Detections") .def_readonly("size", &Detections::detection_count) .def("__len__", [](const Detections &det) { return det.detection_count; }) @@ -153,15 +151,15 @@ template <> }; }} // namespace pybind11::detail -static const std::map type_to_numpy_format = { - {TensorInfo::TensorDataType::_fp16, pybind11::format_descriptor::format()}, - {TensorInfo::TensorDataType::_u8f, pybind11::format_descriptor::format()}, - {TensorInfo::TensorDataType::_int, pybind11::format_descriptor::format()}, - {TensorInfo::TensorDataType::_fp32, pybind11::format_descriptor::format()}, - {TensorInfo::TensorDataType::_i8, pybind11::format_descriptor::format()}, +static const std::map type_to_numpy_format = { + {TensorInfo::DataType::_fp16, pybind11::format_descriptor::format()}, + {TensorInfo::DataType::_u8f, pybind11::format_descriptor::format()}, + {TensorInfo::DataType::_int, pybind11::format_descriptor::format()}, + {TensorInfo::DataType::_fp32, pybind11::format_descriptor::format()}, + {TensorInfo::DataType::_i8, pybind11::format_descriptor::format()}, }; -static std::string type_to_npy_format_descriptor(const TensorInfo::TensorDataType& type) +static std::string type_to_npy_format_descriptor(const TensorInfo::DataType& type) { auto it = type_to_numpy_format.find(type); assert(it != type_to_numpy_format.end()); @@ -176,12 +174,12 @@ static std::string type_to_npy_format_descriptor(const TensorInfo::TensorDataTyp //https://github.com/pybind/pybind11/issues/1042#issuecomment-642215028 static py::array* _getTensorPythonNumpyArray(unsigned char *data, TensorInfo ti) { - assert(!ti.tensor_dimensions.empty()); + assert(!ti.dimensions.empty()); py::array* result = nullptr; - ssize_t ndim = ti.tensor_dimensions.size(); - ssize_t element_size = TensorInfo::c_type_size.at(ti.tensor_data_type); - std::string numpy_format_descriptor = type_to_npy_format_descriptor(ti.tensor_data_type); + ssize_t ndim = ti.dimensions.size(); + ssize_t element_size = TensorInfo::c_type_size.at(ti.data_type); + std::string numpy_format_descriptor = type_to_npy_format_descriptor(ti.data_type); std::vector shape; std::vector strides; shape.reserve(ndim); @@ -189,14 +187,14 @@ static py::array* _getTensorPythonNumpyArray(unsigned char *data, TensorInfo ti) for (int i = 0; i < ndim; ++i) { - shape.push_back(ti.tensor_dimensions[i]); - strides.push_back(ti.tensor_strides[i]); + shape.push_back(ti.dimensions[i]); + strides.push_back(ti.strides[i]); } try { result = new py::array(py::buffer_info( - static_cast(&data[ti.tensor_offset]), /* data as contiguous array */ + static_cast(&data[ti.offset]), /* data as contiguous array */ element_size, /* size of one scalar */ numpy_format_descriptor, /* data type */ ndim, //ndim, /* number of dimensions */ @@ -249,9 +247,9 @@ std::map PyNNetPacket::getOutputsDict() { std::map outputs; for (size_t i = 0; i < _tensors_info.size(); ++i) { - std::string tensor_name = getTensorName(i); - // outputs[tensor_name.c_str()] = getTensor(i); - outputs.insert({tensor_name,getTensor(i)}); + std::string name = getTensorName(i); + // outputs[name.c_str()] = getTensor(i); + outputs.insert({name,getTensor(i)}); } return outputs; From 1038d88595c343b4d68c0e7c111e0202c3e3ba77 Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Mon, 5 Oct 2020 21:04:53 +0300 Subject: [PATCH 37/59] Update depthai-core --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index eeea37a25..b0dd0e8c6 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit eeea37a25f9a6e22f7693d60e977fff34ecd7874 +Subproject commit b0dd0e8c695cc0bcc1d7d41927b381ec70468248 From 2255634c12b0edcac32614c86e1f4d9e1b180e5a Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Mon, 5 Oct 2020 21:15:06 +0300 Subject: [PATCH 38/59] Update depthai-core --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index b0dd0e8c6..7dbce1798 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit b0dd0e8c695cc0bcc1d7d41927b381ec70468248 +Subproject commit 7dbce1798ba4b2876c5ebe3f43b673ebaa3522ae From 7987bd87f74873ccae8c927adc7f7a29a9e0cef7 Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Mon, 5 Oct 2020 22:27:32 +0300 Subject: [PATCH 39/59] TMP: Disable tests in CI --- .github/workflows/main.yml | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6d209ea7e..65fc41468 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -153,29 +153,29 @@ jobs: path: wheelhouse/audited/ # Run tests - tests: - runs-on: luxonis-arm-tests - needs: [build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-linux-x86_64] - steps: - - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - uses: actions/download-artifact@v2 - with: - name: audited-wheels - path: wheels/depthai/ - - name: List files - run: ls -lah - - name: install DepthAI - run: python3.7 -m pip install depthai --no-index --find-links file://`pwd`/wheels/depthai/ - - name: Run tests - run: python3.7 tests/test.py + # tests: + # runs-on: luxonis-arm-tests + # needs: [build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-linux-x86_64] + # steps: + # - uses: actions/checkout@v2 + # with: + # submodules: 'recursive' + # - uses: actions/download-artifact@v2 + # with: + # name: audited-wheels + # path: wheels/depthai/ + # - name: List files + # run: ls -lah + # - name: install DepthAI + # run: python3.7 -m pip install depthai --no-index --find-links file://`pwd`/wheels/depthai/ + # - name: Run tests + # run: python3.7 tests/test.py # Deploy to artifactory deploy-artifacts: if: startsWith(github.ref, 'refs/tags/v') != true runs-on: ubuntu-latest - needs: tests + needs: [build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-linux-x86_64] steps: - uses: actions/checkout@v2 with: @@ -197,7 +197,7 @@ jobs: deploy-pypi: if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest - needs: tests + needs: [build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-linux-x86_64] steps: - uses: actions/checkout@v2 with: From 50ea03c86d7e7fcd0b7919fdac8b50f1b4bff5b5 Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Tue, 6 Oct 2020 00:41:29 +0300 Subject: [PATCH 40/59] [TMP] CI: remove 'tests' dependency from 'deploy-artifacts' --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6d209ea7e..431a35a7a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -175,7 +175,7 @@ jobs: deploy-artifacts: if: startsWith(github.ref, 'refs/tags/v') != true runs-on: ubuntu-latest - needs: tests + needs: [build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-linux-x86_64] steps: - uses: actions/checkout@v2 with: From c7e197fe991fc67c48d9352ada891133d2199079 Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Tue, 6 Oct 2020 00:44:34 +0300 Subject: [PATCH 41/59] Slightly refactor CameraControl API --- depthai-core | 2 +- src/device_bindings.cpp | 80 ++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/depthai-core b/depthai-core index 6b4974573..84083a0ad 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 6b4974573ec2422dbf75eeb72c3ffe2fc8da1758 +Subproject commit 84083a0ad60df08194b963ed13c8140fc8b612e1 diff --git a/src/device_bindings.cpp b/src/device_bindings.cpp index 8e7ebfe66..7f2d28bb4 100644 --- a/src/device_bindings.cpp +++ b/src/device_bindings.cpp @@ -136,48 +136,48 @@ void init_binding_device(pybind11::module& m){ .value("AF_MODE_EDOF", CaptureMetadata::AutofocusMode::AF_MODE_EDOF) ; - py::enum_(m, "Cam3A") - .value("RGB", Isp3A_CamId::CAM_RGB) - .value("Left", Isp3A_CamId::CAM_LEFT) - .value("Right", Isp3A_CamId::CAM_RIGHT) + py::enum_(m, "Cam3A") + .value("RGB", CameraControl::CamId::CAM_RGB) + .value("Left", CameraControl::CamId::CAM_LEFT) + .value("Right", CameraControl::CamId::CAM_RIGHT) ; - py::enum_(m, "Isp3A") - .value("CMD_START_STREAM", Isp3A_Commands::CMD_START_STREAM) - .value("CMD_STOP_STREAM", Isp3A_Commands::CMD_STOP_STREAM) - .value("CMD_REQ_STILL", Isp3A_Commands::CMD_REQ_STILL) - .value("CMD_MOV_LENS", Isp3A_Commands::CMD_MOV_LENS) - .value("CMD_FOCUS_TRIGGER", Isp3A_Commands::CMD_FOCUS_TRIGGER) - .value("CMD_AE_MANUAL", Isp3A_Commands::CMD_AE_MANUAL) - .value("CMD_AE_AUTO", Isp3A_Commands::CMD_AE_AUTO) - .value("CMD_SET_AWB_MODE", Isp3A_Commands::CMD_SET_AWB_MODE) - .value("CMD_SCENE_MODES", Isp3A_Commands::CMD_SCENE_MODES) - .value("CMD_ANTIBANDING_MODES", Isp3A_Commands::CMD_ANTIBANDING_MODES) - .value("CMD_EXPOSURE_COMPENSATION", Isp3A_Commands::CMD_EXPOSURE_COMPENSATION) - .value("CMD_AE_LOCK", Isp3A_Commands::CMD_AE_LOCK) - .value("CMD_AE_TARGET_FPS_RANGE", Isp3A_Commands::CMD_AE_TARGET_FPS_RANGE) - .value("CMD_AWB_LOCK", Isp3A_Commands::CMD_AWB_LOCK) - .value("CMD_CAPTURE_INTENT", Isp3A_Commands::CMD_CAPTURE_INTENT) - .value("CMD_CONTROL_MODE", Isp3A_Commands::CMD_CONTROL_MODE) - .value("CMD_FRAME_DURATION", Isp3A_Commands::CMD_FRAME_DURATION) - .value("CMD_SENSITIVITY", Isp3A_Commands::CMD_SENSITIVITY) - .value("CMD_EFFECT_MODE", Isp3A_Commands::CMD_EFFECT_MODE) - .value("CMD_AF_MODE", Isp3A_Commands::CMD_AF_MODE) - .value("CMD_NOISE_REDUCTION_STRENGTH", Isp3A_Commands::CMD_NOISE_REDUCTION_STRENGTH) - .value("CMD_SATURATION", Isp3A_Commands::CMD_SATURATION) - .value("CMD_BRIGHTNESS", Isp3A_Commands::CMD_BRIGHTNESS) - .value("CMD_STREAM_FORMAT", Isp3A_Commands::CMD_STREAM_FORMAT) - .value("CMD_CAM_RESOLUTION", Isp3A_Commands::CMD_CAM_RESOLUTION) - .value("CMD_SHARPNESS", Isp3A_Commands::CMD_SHARPNESS) - .value("CMD_CUST_USECASE", Isp3A_Commands::CMD_CUST_USECASE) - .value("CMD_CUST_CAPT_MODE", Isp3A_Commands::CMD_CUST_CAPT_MODE) - .value("CMD_CUST_EXP_BRACKETS", Isp3A_Commands::CMD_CUST_EXP_BRACKETS) - .value("CMD_CUST_CAPTURE", Isp3A_Commands::CMD_CUST_CAPTURE) - .value("CMD_CONTRAST", Isp3A_Commands::CMD_CONTRAST) - .value("CMD_AE_REGION", Isp3A_Commands::CMD_AE_REGION) - .value("CMD_AF_REGION", Isp3A_Commands::CMD_AF_REGION) - .value("CMD_LUMA_DENOISE", Isp3A_Commands::CMD_LUMA_DENOISE) - .value("CMD_CHROMA_DENOISE", Isp3A_Commands::CMD_CHROMA_DENOISE) + py::enum_(m, "Isp3A") + .value("CMD_START_STREAM", CameraControl::Command::CMD_START_STREAM) + .value("CMD_STOP_STREAM", CameraControl::Command::CMD_STOP_STREAM) + .value("CMD_REQUEST_STILL", CameraControl::Command::CMD_REQUEST_STILL) + .value("CMD_MOVE_LENS", CameraControl::Command::CMD_MOVE_LENS) + .value("CMD_FOCUS_TRIGGER", CameraControl::Command::CMD_FOCUS_TRIGGER) + .value("CMD_AE_MANUAL", CameraControl::Command::CMD_AE_MANUAL) + .value("CMD_AE_AUTO", CameraControl::Command::CMD_AE_AUTO) + .value("CMD_SET_AWB_MODE", CameraControl::Command::CMD_SET_AWB_MODE) + .value("CMD_SCENE_MODES", CameraControl::Command::CMD_SCENE_MODES) + .value("CMD_ANTIBANDING_MODES", CameraControl::Command::CMD_ANTIBANDING_MODES) + .value("CMD_EXPOSURE_COMPENSATION", CameraControl::Command::CMD_EXPOSURE_COMPENSATION) + .value("CMD_AE_LOCK", CameraControl::Command::CMD_AE_LOCK) + .value("CMD_AE_TARGET_FPS_RANGE", CameraControl::Command::CMD_AE_TARGET_FPS_RANGE) + .value("CMD_AWB_LOCK", CameraControl::Command::CMD_AWB_LOCK) + .value("CMD_CAPTURE_INTENT", CameraControl::Command::CMD_CAPTURE_INTENT) + .value("CMD_CONTROL_MODE", CameraControl::Command::CMD_CONTROL_MODE) + .value("CMD_FRAME_DURATION", CameraControl::Command::CMD_FRAME_DURATION) + .value("CMD_SENSITIVITY", CameraControl::Command::CMD_SENSITIVITY) + .value("CMD_EFFECT_MODE", CameraControl::Command::CMD_EFFECT_MODE) + .value("CMD_AF_MODE", CameraControl::Command::CMD_AF_MODE) + .value("CMD_NOISE_REDUCTION_STRENGTH", CameraControl::Command::CMD_NOISE_REDUCTION_STRENGTH) + .value("CMD_SATURATION", CameraControl::Command::CMD_SATURATION) + .value("CMD_BRIGHTNESS", CameraControl::Command::CMD_BRIGHTNESS) + .value("CMD_STREAM_FORMAT", CameraControl::Command::CMD_STREAM_FORMAT) + .value("CMD_CAM_RESOLUTION", CameraControl::Command::CMD_CAM_RESOLUTION) + .value("CMD_SHARPNESS", CameraControl::Command::CMD_SHARPNESS) + .value("CMD_CUSTOM_USECASE", CameraControl::Command::CMD_CUSTOM_USECASE) + .value("CMD_CUSTOM_CAPT_MODE", CameraControl::Command::CMD_CUSTOM_CAPT_MODE) + .value("CMD_CUSTOM_EXP_BRACKETS", CameraControl::Command::CMD_CUSTOM_EXP_BRACKETS) + .value("CMD_CUSTOM_CAPTURE", CameraControl::Command::CMD_CUSTOM_CAPTURE) + .value("CMD_CONTRAST", CameraControl::Command::CMD_CONTRAST) + .value("CMD_AE_REGION", CameraControl::Command::CMD_AE_REGION) + .value("CMD_AF_REGION", CameraControl::Command::CMD_AF_REGION) + .value("CMD_LUMA_DENOISE", CameraControl::Command::CMD_LUMA_DENOISE) + .value("CMD_CHROMA_DENOISE", CameraControl::Command::CMD_CHROMA_DENOISE) ; } From de9f58084fc9100d43ee9807aee963ebc69d94d4 Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Tue, 6 Oct 2020 01:00:04 +0300 Subject: [PATCH 42/59] Update depthai-core --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 84083a0ad..23bb47e99 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 84083a0ad60df08194b963ed13c8140fc8b612e1 +Subproject commit 23bb47e99f5301a49d11cc26847ea3aeee9a8976 From cdd1f23ee73ca34732050dcd44a78ec63f291b26 Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Tue, 6 Oct 2020 08:31:25 +0300 Subject: [PATCH 43/59] Fix default camera resolution/fps if not specified --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 7dbce1798..38942ae60 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 7dbce1798ba4b2876c5ebe3f43b673ebaa3522ae +Subproject commit 38942ae60e36dbf7da795eb1e57558f01e7ba19a From 3aa41b9d60c5bd3db88ad4fc2a99d94af301d50d Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Wed, 7 Oct 2020 17:09:45 +0300 Subject: [PATCH 44/59] Adapt Cam3A/Isp3A for enum name change. Add note to API --- depthai-core | 2 +- src/device_bindings.cpp | 79 +++++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/depthai-core b/depthai-core index 23bb47e99..173d43ccb 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 23bb47e99f5301a49d11cc26847ea3aeee9a8976 +Subproject commit 173d43ccbb11398b84a04c6e85fddfaf901ec454 diff --git a/src/device_bindings.cpp b/src/device_bindings.cpp index 7f2d28bb4..b51f26df4 100644 --- a/src/device_bindings.cpp +++ b/src/device_bindings.cpp @@ -74,7 +74,8 @@ void init_binding_device(pybind11::module& m){ .def( "send_camera_control", &Device::send_camera_control, - "Function to send an ISP 3A camera control command", + "Function to send an ISP 3A camera control command. " + "args: 'Cam3A.__members__', 'Isp3A.__members__', extra_args: 'string, space separated values https://git.io/JUpnJ '", py::arg("camera_id"), py::arg("command_id"), py::arg("extra_args") @@ -137,47 +138,47 @@ void init_binding_device(pybind11::module& m){ ; py::enum_(m, "Cam3A") - .value("RGB", CameraControl::CamId::CAM_RGB) - .value("Left", CameraControl::CamId::CAM_LEFT) - .value("Right", CameraControl::CamId::CAM_RIGHT) + .value("RGB", CameraControl::CamId::RGB) + .value("Left", CameraControl::CamId::LEFT) + .value("Right", CameraControl::CamId::RIGHT) ; py::enum_(m, "Isp3A") - .value("CMD_START_STREAM", CameraControl::Command::CMD_START_STREAM) - .value("CMD_STOP_STREAM", CameraControl::Command::CMD_STOP_STREAM) - .value("CMD_REQUEST_STILL", CameraControl::Command::CMD_REQUEST_STILL) - .value("CMD_MOVE_LENS", CameraControl::Command::CMD_MOVE_LENS) - .value("CMD_FOCUS_TRIGGER", CameraControl::Command::CMD_FOCUS_TRIGGER) - .value("CMD_AE_MANUAL", CameraControl::Command::CMD_AE_MANUAL) - .value("CMD_AE_AUTO", CameraControl::Command::CMD_AE_AUTO) - .value("CMD_SET_AWB_MODE", CameraControl::Command::CMD_SET_AWB_MODE) - .value("CMD_SCENE_MODES", CameraControl::Command::CMD_SCENE_MODES) - .value("CMD_ANTIBANDING_MODES", CameraControl::Command::CMD_ANTIBANDING_MODES) - .value("CMD_EXPOSURE_COMPENSATION", CameraControl::Command::CMD_EXPOSURE_COMPENSATION) - .value("CMD_AE_LOCK", CameraControl::Command::CMD_AE_LOCK) - .value("CMD_AE_TARGET_FPS_RANGE", CameraControl::Command::CMD_AE_TARGET_FPS_RANGE) - .value("CMD_AWB_LOCK", CameraControl::Command::CMD_AWB_LOCK) - .value("CMD_CAPTURE_INTENT", CameraControl::Command::CMD_CAPTURE_INTENT) - .value("CMD_CONTROL_MODE", CameraControl::Command::CMD_CONTROL_MODE) - .value("CMD_FRAME_DURATION", CameraControl::Command::CMD_FRAME_DURATION) - .value("CMD_SENSITIVITY", CameraControl::Command::CMD_SENSITIVITY) - .value("CMD_EFFECT_MODE", CameraControl::Command::CMD_EFFECT_MODE) - .value("CMD_AF_MODE", CameraControl::Command::CMD_AF_MODE) - .value("CMD_NOISE_REDUCTION_STRENGTH", CameraControl::Command::CMD_NOISE_REDUCTION_STRENGTH) - .value("CMD_SATURATION", CameraControl::Command::CMD_SATURATION) - .value("CMD_BRIGHTNESS", CameraControl::Command::CMD_BRIGHTNESS) - .value("CMD_STREAM_FORMAT", CameraControl::Command::CMD_STREAM_FORMAT) - .value("CMD_CAM_RESOLUTION", CameraControl::Command::CMD_CAM_RESOLUTION) - .value("CMD_SHARPNESS", CameraControl::Command::CMD_SHARPNESS) - .value("CMD_CUSTOM_USECASE", CameraControl::Command::CMD_CUSTOM_USECASE) - .value("CMD_CUSTOM_CAPT_MODE", CameraControl::Command::CMD_CUSTOM_CAPT_MODE) - .value("CMD_CUSTOM_EXP_BRACKETS", CameraControl::Command::CMD_CUSTOM_EXP_BRACKETS) - .value("CMD_CUSTOM_CAPTURE", CameraControl::Command::CMD_CUSTOM_CAPTURE) - .value("CMD_CONTRAST", CameraControl::Command::CMD_CONTRAST) - .value("CMD_AE_REGION", CameraControl::Command::CMD_AE_REGION) - .value("CMD_AF_REGION", CameraControl::Command::CMD_AF_REGION) - .value("CMD_LUMA_DENOISE", CameraControl::Command::CMD_LUMA_DENOISE) - .value("CMD_CHROMA_DENOISE", CameraControl::Command::CMD_CHROMA_DENOISE) + .value("CMD_START_STREAM", CameraControl::Command::START_STREAM) + .value("CMD_STOP_STREAM", CameraControl::Command::STOP_STREAM) + .value("CMD_REQUEST_STILL", CameraControl::Command::REQUEST_STILL) + .value("CMD_MOVE_LENS", CameraControl::Command::MOVE_LENS) + .value("CMD_FOCUS_TRIGGER", CameraControl::Command::FOCUS_TRIGGER) + .value("CMD_AE_MANUAL", CameraControl::Command::AE_MANUAL) + .value("CMD_AE_AUTO", CameraControl::Command::AE_AUTO) + .value("CMD_SET_AWB_MODE", CameraControl::Command::SET_AWB_MODE) + .value("CMD_SCENE_MODES", CameraControl::Command::SCENE_MODES) + .value("CMD_ANTIBANDING_MODES", CameraControl::Command::ANTIBANDING_MODES) + .value("CMD_EXPOSURE_COMPENSATION", CameraControl::Command::EXPOSURE_COMPENSATION) + .value("CMD_AE_LOCK", CameraControl::Command::AE_LOCK) + .value("CMD_AE_TARGET_FPS_RANGE", CameraControl::Command::AE_TARGET_FPS_RANGE) + .value("CMD_AWB_LOCK", CameraControl::Command::AWB_LOCK) + .value("CMD_CAPTURE_INTENT", CameraControl::Command::CAPTURE_INTENT) + .value("CMD_CONTROL_MODE", CameraControl::Command::CONTROL_MODE) + .value("CMD_FRAME_DURATION", CameraControl::Command::FRAME_DURATION) + .value("CMD_SENSITIVITY", CameraControl::Command::SENSITIVITY) + .value("CMD_EFFECT_MODE", CameraControl::Command::EFFECT_MODE) + .value("CMD_AF_MODE", CameraControl::Command::AF_MODE) + .value("CMD_NOISE_REDUCTION_STRENGTH", CameraControl::Command::NOISE_REDUCTION_STRENGTH) + .value("CMD_SATURATION", CameraControl::Command::SATURATION) + .value("CMD_BRIGHTNESS", CameraControl::Command::BRIGHTNESS) + .value("CMD_STREAM_FORMAT", CameraControl::Command::STREAM_FORMAT) + .value("CMD_CAM_RESOLUTION", CameraControl::Command::CAM_RESOLUTION) + .value("CMD_SHARPNESS", CameraControl::Command::SHARPNESS) + .value("CMD_CUSTOM_USECASE", CameraControl::Command::CUSTOM_USECASE) + .value("CMD_CUSTOM_CAPT_MODE", CameraControl::Command::CUSTOM_CAPT_MODE) + .value("CMD_CUSTOM_EXP_BRACKETS", CameraControl::Command::CUSTOM_EXP_BRACKETS) + .value("CMD_CUSTOM_CAPTURE", CameraControl::Command::CUSTOM_CAPTURE) + .value("CMD_CONTRAST", CameraControl::Command::CONTRAST) + .value("CMD_AE_REGION", CameraControl::Command::AE_REGION) + .value("CMD_AF_REGION", CameraControl::Command::AF_REGION) + .value("CMD_LUMA_DENOISE", CameraControl::Command::LUMA_DENOISE) + .value("CMD_CHROMA_DENOISE", CameraControl::Command::CHROMA_DENOISE) ; } From 958eb1408e8ddc0faa726ef3974ebc56f1eb835d Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Wed, 7 Oct 2020 17:10:39 +0300 Subject: [PATCH 45/59] Revert "[TMP] CI: remove 'tests' dependency from 'deploy-artifacts'" This reverts commit 50ea03c86d7e7fcd0b7919fdac8b50f1b4bff5b5. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 431a35a7a..6d209ea7e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -175,7 +175,7 @@ jobs: deploy-artifacts: if: startsWith(github.ref, 'refs/tags/v') != true runs-on: ubuntu-latest - needs: [build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-linux-x86_64] + needs: tests steps: - uses: actions/checkout@v2 with: From 78f0f40db764c4981da9e74de387b61c785e4d32 Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Thu, 8 Oct 2020 00:52:13 +0300 Subject: [PATCH 46/59] Address review comments: rename and move CamId/Command to CameraControl class --- src/device_bindings.cpp | 80 +++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/src/device_bindings.cpp b/src/device_bindings.cpp index b51f26df4..a76530545 100644 --- a/src/device_bindings.cpp +++ b/src/device_bindings.cpp @@ -137,48 +137,50 @@ void init_binding_device(pybind11::module& m){ .value("AF_MODE_EDOF", CaptureMetadata::AutofocusMode::AF_MODE_EDOF) ; - py::enum_(m, "Cam3A") + py::class_ cameraControl(m, "CameraControl"); + + py::enum_(cameraControl, "CamId") .value("RGB", CameraControl::CamId::RGB) - .value("Left", CameraControl::CamId::LEFT) - .value("Right", CameraControl::CamId::RIGHT) + .value("LEFT", CameraControl::CamId::LEFT) + .value("RIGHT", CameraControl::CamId::RIGHT) ; - py::enum_(m, "Isp3A") - .value("CMD_START_STREAM", CameraControl::Command::START_STREAM) - .value("CMD_STOP_STREAM", CameraControl::Command::STOP_STREAM) - .value("CMD_REQUEST_STILL", CameraControl::Command::REQUEST_STILL) - .value("CMD_MOVE_LENS", CameraControl::Command::MOVE_LENS) - .value("CMD_FOCUS_TRIGGER", CameraControl::Command::FOCUS_TRIGGER) - .value("CMD_AE_MANUAL", CameraControl::Command::AE_MANUAL) - .value("CMD_AE_AUTO", CameraControl::Command::AE_AUTO) - .value("CMD_SET_AWB_MODE", CameraControl::Command::SET_AWB_MODE) - .value("CMD_SCENE_MODES", CameraControl::Command::SCENE_MODES) - .value("CMD_ANTIBANDING_MODES", CameraControl::Command::ANTIBANDING_MODES) - .value("CMD_EXPOSURE_COMPENSATION", CameraControl::Command::EXPOSURE_COMPENSATION) - .value("CMD_AE_LOCK", CameraControl::Command::AE_LOCK) - .value("CMD_AE_TARGET_FPS_RANGE", CameraControl::Command::AE_TARGET_FPS_RANGE) - .value("CMD_AWB_LOCK", CameraControl::Command::AWB_LOCK) - .value("CMD_CAPTURE_INTENT", CameraControl::Command::CAPTURE_INTENT) - .value("CMD_CONTROL_MODE", CameraControl::Command::CONTROL_MODE) - .value("CMD_FRAME_DURATION", CameraControl::Command::FRAME_DURATION) - .value("CMD_SENSITIVITY", CameraControl::Command::SENSITIVITY) - .value("CMD_EFFECT_MODE", CameraControl::Command::EFFECT_MODE) - .value("CMD_AF_MODE", CameraControl::Command::AF_MODE) - .value("CMD_NOISE_REDUCTION_STRENGTH", CameraControl::Command::NOISE_REDUCTION_STRENGTH) - .value("CMD_SATURATION", CameraControl::Command::SATURATION) - .value("CMD_BRIGHTNESS", CameraControl::Command::BRIGHTNESS) - .value("CMD_STREAM_FORMAT", CameraControl::Command::STREAM_FORMAT) - .value("CMD_CAM_RESOLUTION", CameraControl::Command::CAM_RESOLUTION) - .value("CMD_SHARPNESS", CameraControl::Command::SHARPNESS) - .value("CMD_CUSTOM_USECASE", CameraControl::Command::CUSTOM_USECASE) - .value("CMD_CUSTOM_CAPT_MODE", CameraControl::Command::CUSTOM_CAPT_MODE) - .value("CMD_CUSTOM_EXP_BRACKETS", CameraControl::Command::CUSTOM_EXP_BRACKETS) - .value("CMD_CUSTOM_CAPTURE", CameraControl::Command::CUSTOM_CAPTURE) - .value("CMD_CONTRAST", CameraControl::Command::CONTRAST) - .value("CMD_AE_REGION", CameraControl::Command::AE_REGION) - .value("CMD_AF_REGION", CameraControl::Command::AF_REGION) - .value("CMD_LUMA_DENOISE", CameraControl::Command::LUMA_DENOISE) - .value("CMD_CHROMA_DENOISE", CameraControl::Command::CHROMA_DENOISE) + py::enum_(cameraControl, "Command") + .value("START_STREAM", CameraControl::Command::START_STREAM) + .value("STOP_STREAM", CameraControl::Command::STOP_STREAM) + .value("REQUEST_STILL", CameraControl::Command::REQUEST_STILL) + .value("MOVE_LENS", CameraControl::Command::MOVE_LENS) + .value("FOCUS_TRIGGER", CameraControl::Command::FOCUS_TRIGGER) + .value("AE_MANUAL", CameraControl::Command::AE_MANUAL) + .value("AE_AUTO", CameraControl::Command::AE_AUTO) + .value("SET_AWB_MODE", CameraControl::Command::SET_AWB_MODE) + .value("SCENE_MODES", CameraControl::Command::SCENE_MODES) + .value("ANTIBANDING_MODES", CameraControl::Command::ANTIBANDING_MODES) + .value("EXPOSURE_COMPENSATION", CameraControl::Command::EXPOSURE_COMPENSATION) + .value("AE_LOCK", CameraControl::Command::AE_LOCK) + .value("AE_TARGET_FPS_RANGE", CameraControl::Command::AE_TARGET_FPS_RANGE) + .value("AWB_LOCK", CameraControl::Command::AWB_LOCK) + .value("CAPTURE_INTENT", CameraControl::Command::CAPTURE_INTENT) + .value("CONTROL_MODE", CameraControl::Command::CONTROL_MODE) + .value("FRAME_DURATION", CameraControl::Command::FRAME_DURATION) + .value("SENSITIVITY", CameraControl::Command::SENSITIVITY) + .value("EFFECT_MODE", CameraControl::Command::EFFECT_MODE) + .value("AF_MODE", CameraControl::Command::AF_MODE) + .value("NOISE_REDUCTION_STRENGTH", CameraControl::Command::NOISE_REDUCTION_STRENGTH) + .value("SATURATION", CameraControl::Command::SATURATION) + .value("BRIGHTNESS", CameraControl::Command::BRIGHTNESS) + .value("STREAM_FORMAT", CameraControl::Command::STREAM_FORMAT) + .value("CAM_RESOLUTION", CameraControl::Command::CAM_RESOLUTION) + .value("SHARPNESS", CameraControl::Command::SHARPNESS) + .value("CUSTOM_USECASE", CameraControl::Command::CUSTOM_USECASE) + .value("CUSTOM_CAPT_MODE", CameraControl::Command::CUSTOM_CAPT_MODE) + .value("CUSTOM_EXP_BRACKETS", CameraControl::Command::CUSTOM_EXP_BRACKETS) + .value("CUSTOM_CAPTURE", CameraControl::Command::CUSTOM_CAPTURE) + .value("CONTRAST", CameraControl::Command::CONTRAST) + .value("AE_REGION", CameraControl::Command::AE_REGION) + .value("AF_REGION", CameraControl::Command::AF_REGION) + .value("LUMA_DENOISE", CameraControl::Command::LUMA_DENOISE) + .value("CHROMA_DENOISE", CameraControl::Command::CHROMA_DENOISE) ; } From 406f48b91e9bd01824c748a0028e07595b5557dd Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Thu, 8 Oct 2020 01:37:05 +0300 Subject: [PATCH 47/59] Update depthai-core: support for NN on stereo rectified frames --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index c3da28d9a..907405000 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit c3da28d9aa301d7d206eba5994ebfe15aae8f32a +Subproject commit 9074050003930bceff4f07f3e8d55e9e501ad010 From bee757d3341fc40771dca684f433ec42c852f8ce Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Mon, 12 Oct 2020 18:54:48 +0300 Subject: [PATCH 48/59] Fix get_dict() methods for TensorInfo and Detection --- src/nnet_packet_bindings.cpp | 38 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/nnet_packet_bindings.cpp b/src/nnet_packet_bindings.cpp index 2443db0a6..3a7eb9021 100644 --- a/src/nnet_packet_bindings.cpp +++ b/src/nnet_packet_bindings.cpp @@ -50,21 +50,23 @@ void init_binding_nnet_packet(pybind11::module& m){ py::class_ tensorInfo(m, "TensorInfo"); tensorInfo.def("get_dimension", &TensorInfo::get_dimension); tensorInfo.def_readonly("name", &TensorInfo::name); + tensorInfo.def_readonly("order", &TensorInfo::order); tensorInfo.def_readonly("dimensions", &TensorInfo::dimensions); tensorInfo.def_readonly("strides", &TensorInfo::strides); tensorInfo.def_readonly("data_type", &TensorInfo::data_type); tensorInfo.def_readonly("offset", &TensorInfo::offset); tensorInfo.def_readonly("element_size", &TensorInfo::element_size); tensorInfo.def_readonly("index", &TensorInfo::index); - tensorInfo.def("get_dict", []() { + tensorInfo.def("get_dict", [](TensorInfo &self) { py::dict d; - d["name"] = &TensorInfo::name; - d["dimensions"] = &TensorInfo::dimensions; - d["strides"] = &TensorInfo::strides; - d["data_type"] = &TensorInfo::data_type; - d["offset"] = &TensorInfo::offset; - d["element_size"] = &TensorInfo::element_size; - d["index"] = &TensorInfo::index; + d["name"] = self.name; + d["order"] = self.order; + d["dimensions"] = self.dimensions; + d["strides"] = self.strides; + d["data_type"] = self.data_type; + d["offset"] = self.offset; + d["element_size"] = self.element_size; + d["index"] = self.index; return d; }); tensorInfo.def("__str__", [](const TensorInfo& v) { @@ -121,17 +123,17 @@ void init_binding_nnet_packet(pybind11::module& m){ .def_readonly("depth_x", &Detection::depth_x) .def_readonly("depth_y", &Detection::depth_y) .def_readonly("depth_z", &Detection::depth_z) - .def("get_dict", []() { + .def("get_dict", [](Detection &self) { py::dict d; - d["label"] = &Detection::label; - d["confidence"] = &Detection::confidence; - d["x_min"] = &Detection::x_min; - d["y_min"] = &Detection::y_min; - d["x_max"] = &Detection::x_max; - d["y_max"] = &Detection::y_max; - d["depth_x"] = &Detection::depth_x; - d["depth_y"] = &Detection::depth_y; - d["depth_z"] = &Detection::depth_z; + d["label"] = self.label; + d["confidence"] = self.confidence; + d["x_min"] = self.x_min; + d["y_min"] = self.y_min; + d["x_max"] = self.x_max; + d["y_max"] = self.y_max; + d["depth_x"] = self.depth_x; + d["depth_y"] = self.depth_y; + d["depth_z"] = self.depth_z; return d; }) ; From 186e9fd169f0377a32fea7ae5b1069dcca8a7e48 Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Mon, 12 Oct 2020 20:31:35 +0300 Subject: [PATCH 49/59] Update depthai-core: fix sporadic scaling issue or crash, when rectified streams are used for NN input --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 907405000..782595311 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 9074050003930bceff4f07f3e8d55e9e501ad010 +Subproject commit 7825953119355613965d66459c28b7dbfb39a52e From 4dd7e7a7fed75cfd4bef853f7032db06d51f6350 Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Tue, 13 Oct 2020 16:20:58 +0300 Subject: [PATCH 50/59] Remove depth_confidence threshold; fix confidence threshold for mobilenet --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 782595311..c74dbdea7 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 7825953119355613965d66459c28b7dbfb39a52e +Subproject commit c74dbdea7c8145d63371e10e08252c46e6e197ce From c770023a166c926478e11442315209cfafd7f695 Mon Sep 17 00:00:00 2001 From: TheMarpe Date: Tue, 13 Oct 2020 20:04:07 +0200 Subject: [PATCH 51/59] Updated core --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 782595311..03d4cd3ab 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 7825953119355613965d66459c28b7dbfb39a52e +Subproject commit 03d4cd3ab60a60e66c418069f9a444072a1cf1e9 From fd0239e334ea71898984e8dddab07eab2f39e214 Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Wed, 14 Oct 2020 01:00:13 +0300 Subject: [PATCH 52/59] Throw error if depth confidence threshold is used --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index c74dbdea7..aef1edcae 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit c74dbdea7c8145d63371e10e08252c46e6e197ce +Subproject commit aef1edcae75ae3dabdf68fff7b9a5eeca68f3663 From fe3741e60c7e167a888f67b2a3263623ced170b4 Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Thu, 15 Oct 2020 16:03:03 +0300 Subject: [PATCH 53/59] Default DEPTHAI_PYTHON_COMMIT_HASH to "dev". Update depthai-core --- CMakeLists.txt | 5 ++++- depthai-core | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2462f60ef..ab9f65c6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,10 @@ target_link_libraries(${TARGET_NAME} # Add bindings revision target_compile_definitions(${TARGET_NAME} PRIVATE DEPTHAI_PYTHON_BINDINGS_REVISION="${PROJECT_VERSION}") -# Add commit hash +# Add commit hash, default to "dev" +if(NOT DEPTHAI_PYTHON_COMMIT_HASH) + set(DEPTHAI_PYTHON_COMMIT_HASH dev) +endif() if(DEPTHAI_PYTHON_COMMIT_HASH) target_compile_definitions(${TARGET_NAME} PRIVATE DEPTHAI_PYTHON_COMMIT_HASH="${DEPTHAI_PYTHON_COMMIT_HASH}") endif() diff --git a/depthai-core b/depthai-core index 48cbb9734..c912556e5 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 48cbb9734a4c9e1bfa29fda3b142ca76840a3885 +Subproject commit c912556e5395b531ec3ae6c61849082b0e8dffbe From 566287cbfb5cbbde6aaea209a7ec7ae302bd41e3 Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Fri, 16 Oct 2020 17:19:43 +0300 Subject: [PATCH 54/59] Update depthai-core: update XLink, usb_chunk_KiB option --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index c912556e5..81c050a27 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit c912556e5395b531ec3ae6c61849082b0e8dffbe +Subproject commit 81c050a27945bbf81eaea5d2a455369f016dd3e9 From 251b4a7ec9d0dc1e0d33188e0f1c40b0f2d46479 Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Mon, 19 Oct 2020 18:54:33 +0300 Subject: [PATCH 55/59] Check if output format matches the one in config --- depthai-core | 2 +- src/nnet_packet_bindings.cpp | 7 +++++++ src/nnet_packet_bindings.hpp | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/depthai-core b/depthai-core index 81c050a27..e3045cc07 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 81c050a27945bbf81eaea5d2a455369f016dd3e9 +Subproject commit e3045cc077041eaea895506222c8eb37c3278806 diff --git a/src/nnet_packet_bindings.cpp b/src/nnet_packet_bindings.cpp index 3a7eb9021..da54edf89 100644 --- a/src/nnet_packet_bindings.cpp +++ b/src/nnet_packet_bindings.cpp @@ -214,6 +214,13 @@ static py::array* _getTensorPythonNumpyArray(unsigned char *data, TensorInfo ti) py::array* PyNNetPacket::getTensor(unsigned index) { + if(_NN_config[0].contains("output_format")) + { + if(_NN_config[index]["output_format"] != std::string("raw")) + { + assert(0 && "getTensor should be used only when [\"NN_config\"][\"output_format\"] is set to raw! https://docs.luxonis.com/api/#creating-blob-configuration-file"); + } + } assert(index < _tensors_info.size()); TensorInfo ti = _tensors_info[index]; unsigned char * data = _tensors_raw_data->data->data(); diff --git a/src/nnet_packet_bindings.hpp b/src/nnet_packet_bindings.hpp index 8e2ca9376..9e4a581d9 100644 --- a/src/nnet_packet_bindings.hpp +++ b/src/nnet_packet_bindings.hpp @@ -20,6 +20,6 @@ struct PyNNetPacket : public NNetPacket { public: using NNetPacket::_tensors_raw_data; using NNetPacket::_tensor_name_to_index; - + using NNetPacket::_NN_config; }; \ No newline at end of file From 7f6f4bd1fdd48812d988393deef379ae62fe6056 Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Mon, 19 Oct 2020 19:47:33 +0300 Subject: [PATCH 56/59] Add check for 2 stage network --- depthai-core | 2 +- src/nnet_packet_bindings.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/depthai-core b/depthai-core index e3045cc07..678e61221 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit e3045cc077041eaea895506222c8eb37c3278806 +Subproject commit 678e61221f7d6a8de77c6d3b1be5a587de2be59c diff --git a/src/nnet_packet_bindings.cpp b/src/nnet_packet_bindings.cpp index da54edf89..9311ec72d 100644 --- a/src/nnet_packet_bindings.cpp +++ b/src/nnet_packet_bindings.cpp @@ -218,7 +218,7 @@ py::array* PyNNetPacket::getTensor(unsigned index) { if(_NN_config[index]["output_format"] != std::string("raw")) { - assert(0 && "getTensor should be used only when [\"NN_config\"][\"output_format\"] is set to raw! https://docs.luxonis.com/api/#creating-blob-configuration-file"); + throw std::runtime_error("getTensor should be used only when [\"NN_config\"][\"output_format\"] is set to raw! https://docs.luxonis.com/api/#creating-blob-configuration-file"); } } assert(index < _tensors_info.size()); From 09142c24eb487df4e5f63413bc7ee895113bdd4b Mon Sep 17 00:00:00 2001 From: SzabolcsGergely Date: Tue, 20 Oct 2020 15:52:28 +0300 Subject: [PATCH 57/59] Fix array indexing error --- src/nnet_packet_bindings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nnet_packet_bindings.cpp b/src/nnet_packet_bindings.cpp index 9311ec72d..bf26d0dd9 100644 --- a/src/nnet_packet_bindings.cpp +++ b/src/nnet_packet_bindings.cpp @@ -214,7 +214,7 @@ static py::array* _getTensorPythonNumpyArray(unsigned char *data, TensorInfo ti) py::array* PyNNetPacket::getTensor(unsigned index) { - if(_NN_config[0].contains("output_format")) + if(_NN_config[index].contains("output_format")) { if(_NN_config[index]["output_format"] != std::string("raw")) { From 52249605c65514cd12a0c9bf3e9b8c491d6ae003 Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Fri, 23 Oct 2020 17:31:24 +0300 Subject: [PATCH 58/59] Update depthai-core: fix X,Y,Z calc on NN bounding box --- depthai-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depthai-core b/depthai-core index 678e61221..f9611b2bb 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 678e61221f7d6a8de77c6d3b1be5a587de2be59c +Subproject commit f9611b2bb25997fcf66430d259a9408292b8a6b9 From 760a76c5612974455e05614a9a4f2e3762c92c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pi=C5=82atowski?= Date: Mon, 26 Oct 2020 13:07:47 +0100 Subject: [PATCH 59/59] bump version to 0.3.0.0 --- CMakeLists.txt | 2 +- depthai-core | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab9f65c6f..38379f64f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ endif() # Pybindings project set(TARGET_NAME depthai) -project(${TARGET_NAME} VERSION "1") # revision of bindings [depthai-core].[rev] +project(${TARGET_NAME} VERSION "0") # revision of bindings [depthai-core].[rev] # Add depthai-cpp dependency add_subdirectory(depthai-core EXCLUDE_FROM_ALL) diff --git a/depthai-core b/depthai-core index f9611b2bb..e3e5aeca7 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit f9611b2bb25997fcf66430d259a9408292b8a6b9 +Subproject commit e3e5aeca7b015376f79669f9d7b766249b4d85ae