diff --git a/host/core/depth/depth_packet.hpp b/host/core/depth/depth_packet.hpp deleted file mode 100644 index b0d51e0eb..000000000 --- a/host/core/depth/depth_packet.hpp +++ /dev/null @@ -1,160 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "../host_data_packet.hpp" -#include "../../shared/disparity_luts.hpp" - - -class DepthPacket -{ -public: - // data_packet may point to nullptr - DepthPacket(std::shared_ptr &data_packet) - : _data_packet(data_packet) - {} - - bool canCalculateDistance() - { - return _data_packet.get() != nullptr; - } - - std::tuple innerBoundingBox( - float left, - float top, - float right, - float bottom, - int width, - int height, - float fraction - ) - { - // bounding box - int x1 = std::max(std::min(int(left * width ), width ), 0); - int y1 = std::max(std::min(int(top * height), height), 0); - int x2 = std::max(std::min(int(right * width ), width ), 0); - int y2 = std::max(std::min(int(bottom * height), height), 0); - - int bb_w = x2 - x1; - int bb_h = y2 - y1; - - // center-cut (inner bounding box) - int dx = bb_w * fraction; - int dy = bb_h * fraction; - - int ix1 = x1 + dx; - int iy1 = y1 + dy; - int ix2 = x2 - dx; - int iy2 = y2 - dy; - - return std::make_tuple(ix1, iy1, ix2, iy2); - } - - float getAverageDistanceForRectangle( - float left, - float top, - float right, - float bottom, - float padding_factor - ) - { - assert(_data_packet->stream_name == c_stream_name_depth); - - // TODO: better way ? - int h = _data_packet->dimensions[0]; - int w = _data_packet->dimensions[1]; - - int x1, y1, x2, y2; - std::tie(x1, y1, x2, y2) = innerBoundingBox(left, top, right, bottom, w, h, padding_factor); - - int iw = x2 - x1; - int ih = y2 - y1; - - // average calc - const uint16_t* data = reinterpret_cast(_data_packet->data.data()); - - long sum = 0; - long n = 0; - - for (int y = y1; y < y2; ++y) - { - const auto* data_y = data + y * w; - for (int x = x1; x < x2; ++x) - { - if (data_y[x] != 0 && data_y[x] < 10000) - { - sum += data_y[x]; - ++n; - } - } - } - - if (n == 0) - { - return -1.f; - } - else - { - return sum / float(n) / 1000.f; - } - } - - float getMedianDistanceForRectangle( - float left, - float top, - float right, - float bottom, - float padding_factor, - float h_fov_deg, - float baseline_m - ) - { - assert(_data_packet->stream_name == c_stream_name_disparity); - - // TODO: better way ? - int h = _data_packet->dimensions[0]; - int w = _data_packet->dimensions[1]; - - int x1, y1, x2, y2; - std::tie(x1, y1, x2, y2) = innerBoundingBox(left, top, right, bottom, w, h, padding_factor); - - int iw = x2 - x1; - int ih = y2 - y1; - - // average calc - const unsigned char* data = reinterpret_cast(_data_packet->data.data()); - - long n = 0; - int counters[256] = {0}; - - for (int y = y1; y < y2; ++y) - { - const auto* data_y = data + y * w; - for (int x = x1; x < x2; ++x) - { - if (data_y[x] != 0) - { - ++counters[ data_y[x] ]; - ++n; - } - } - } - - - long mid_n = n / 2; - long pos = 0; - int disparity = 0; - while (pos < mid_n) { pos += counters[disparity]; ++disparity; }; - - return calculateDisparityToDepthMM(disparity, w, h_fov_deg, baseline_m) / 1000.f; - } - - -private: - const std::string c_stream_name_depth = "depth"; - const std::string c_stream_name_disparity = "disparity"; - - std::shared_ptr _data_packet; -}; diff --git a/host/core/disparity_stream_post_processor.cpp b/host/core/disparity_stream_post_processor.cpp index 35a30e299..78d524452 100644 --- a/host/core/disparity_stream_post_processor.cpp +++ b/host/core/disparity_stream_post_processor.cpp @@ -7,22 +7,15 @@ DisparityStreamPostProcessor::DisparityStreamPostProcessor( - bool produce_d_color, - bool produce_d_mm + bool produce_d_color ) : _produce_depth_color(produce_d_color) - , _produce_depth_mm(produce_d_mm) { - // TODO: remove hardcode - _lut_disp_to_depth_mm = generateLUTDisparityToDepthMM(1280, 69.0f, 0.035f); -} -std::vector DisparityStreamPostProcessor::getLutDisparityToMillimeters() const -{ - return _lut_disp_to_depth_mm; } + void DisparityStreamPostProcessor::onNewData( const StreamInfo &data_info, const StreamData &data @@ -30,11 +23,6 @@ void DisparityStreamPostProcessor::onNewData( { assert(data_info.name == c_stream_in); - if (_produce_depth_mm) - { - prepareDepthMMAndNotifyObservers(data_info, data); - } - if (_produce_depth_color) { prepareDepthColorAndNotifyObservers(data_info, data); @@ -67,29 +55,3 @@ void DisparityStreamPostProcessor::prepareDepthColorAndNotifyObservers( notifyObservers(depth_si, depth_d); } - - -void DisparityStreamPostProcessor::prepareDepthMMAndNotifyObservers( - const StreamInfo &data_info, - const StreamData &data -) -{ - // TODO: remove hardcode - StreamInfo depth_si(c_stream_out_mm.c_str(), 720*1280*2, { 720, 1280}, 2); - - std::vector depth_raw(depth_si.size); - const unsigned char* disp_uc = (const unsigned char*) data.data; - - for (int i = 0; i < data.size; ++i) - { - const unsigned char &disp = *(disp_uc + i); - depth_raw[i] = _lut_disp_to_depth_mm[disp]; - } - - StreamData depth_d; - depth_d.packet_number = data.packet_number; - depth_d.data = depth_raw.data(); - depth_d.size = depth_raw.size(); - - notifyObservers(depth_si, depth_d); -} diff --git a/host/core/disparity_stream_post_processor.hpp b/host/core/disparity_stream_post_processor.hpp index 1e3029550..9e0859860 100644 --- a/host/core/disparity_stream_post_processor.hpp +++ b/host/core/disparity_stream_post_processor.hpp @@ -1,7 +1,5 @@ #pragma once -// This file is created as temporary solution for calculation -// of distance data from disparity #include @@ -16,10 +14,7 @@ class DisparityStreamPostProcessor , public DataObserver { public: - DisparityStreamPostProcessor(bool produce_d_color, bool produce_d_mm); - - std::vector getLutDisparityToMillimeters() const; - + DisparityStreamPostProcessor(bool produce_d_color); protected: // class DataObserver @@ -29,18 +24,8 @@ class DisparityStreamPostProcessor private: const std::string c_stream_in = "disparity"; const std::string c_stream_out_color = "depth_color_h"; - const std::string c_stream_out_mm = "depth_mm_h"; const bool _produce_depth_color = false; - const bool _produce_depth_mm = false; - - - std::vector _lut_disp_to_depth_mm; - - std::vector generateDispToDepthMM( - unsigned width, float fov, float base_line_dist) const; - void prepareDepthColorAndNotifyObservers(const StreamInfo &data_info, const StreamData &data); - void prepareDepthMMAndNotifyObservers(const StreamInfo &data_info, const StreamData &data); }; diff --git a/host/core/float16_to_float32_converter.hpp b/host/core/float16_to_float32_converter.hpp deleted file mode 100644 index ba2950bed..000000000 --- a/host/core/float16_to_float32_converter.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#define EXP_MASK_F32 0x7F800000U -#define EXP_MASK_F16 0x7C00U - -static float f16tof32(uint16_t x) -{ - // this is storage for output result - uint32_t u = x; - - // get sign in 32bit format - uint32_t s = ((u & 0x8000) << 16); - - // check for NAN and INF - if ((u & EXP_MASK_F16) == EXP_MASK_F16) { - // keep mantissa only - u &= 0x03FF; - - // check if it is NAN and raise 10 bit to be align with intrin - if (u) { - u |= 0x0200; - } - - u <<= (23 - 10); - u |= EXP_MASK_F32; - u |= s; - } else if ((x & EXP_MASK_F16) == 0) { // check for zero and denormals. both are converted to zero - u = s; - } else { - // abs - u = (u & 0x7FFF); - - // shift mantissa and exp from f16 to f32 position - u <<= (23 - 10); - - // new bias for exp (f16 bias is 15 and f32 bias is 127) - u += ((127 - 15) << 23); - - // add sign - u |= s; - } - - // finaly represent result as float and return - return *reinterpret_cast(&u); -} \ No newline at end of file diff --git a/host/core/landmarks_parser.hpp b/host/core/landmarks_parser.hpp deleted file mode 100644 index aacf1bdf1..000000000 --- a/host/core/landmarks_parser.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include - -#include "float16_to_float32_converter.hpp" - -typedef struct { - uint16_t x0; - uint16_t y0; - uint16_t x1; - uint16_t y1; - uint16_t x2; - uint16_t y2; - uint16_t x3; - uint16_t y3; - uint16_t x4; - uint16_t y4; -} landmarks_out_struct; - - - -static std::vector parseLandmarks(const void* data) -{ - const uint16_t* d = (const uint16_t*) data; - - // mobilenet_detection det; - - - // det.id = std::max(0.f, f16tof32(d[0])); // TODO: check id max is needed - std::vector landmarks; - for(int i = 0; i < 10; i++) - { - float c = f16tof32(d[i]); - landmarks.push_back(c); - - } - - - - - - - // det.label = std::max(0.f, f16tof32(d[1])); // TODO: check id max is needed - // det.label = f16tof32(d[1]); - - // det.confidence = f16tof32(d[2]); - // det.confidence = (det.confidence > 1.0f || det.confidence < 0.0f) ? 0 : det.confidence; - - // det.left = f16tof32(d[3]); - // det.top = f16tof32(d[4]); - // det.right = f16tof32(d[5]); - // det.bottom = f16tof32(d[6]); - - return landmarks; -} diff --git a/host/core/mobilenet_metadata.h b/host/core/mobilenet_metadata.h deleted file mode 100644 index af1a5d630..000000000 --- a/host/core/mobilenet_metadata.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include "float16_to_float32_converter.hpp" - -typedef struct { - uint16_t id; - uint16_t label; - uint16_t confidence; - uint16_t left; - uint16_t top; - uint16_t right; - uint16_t bottom; -} mobilenet_out_struct; - -typedef struct { - int id; - int label; - float confidence; - float left, top, right, bottom; -} mobilenet_detection; - -static mobilenet_detection parseMobilenetMetadata(const void* data) -{ - const uint16_t* d = (const uint16_t*) data; - - mobilenet_detection det; - - // det.id = std::max(0.f, f16tof32(d[0])); // TODO: check id max is needed - det.id = f16tof32(d[0]); - // det.label = std::max(0.f, f16tof32(d[1])); // TODO: check id max is needed - det.label = f16tof32(d[1]); - - det.confidence = f16tof32(d[2]); - // det.confidence = (det.confidence > 1.0f || det.confidence < 0.0f) ? 0 : det.confidence; - - det.left = f16tof32(d[3]); - det.top = f16tof32(d[4]); - det.right = f16tof32(d[5]); - det.bottom = f16tof32(d[6]); - - return det; -} diff --git a/host/core/nnet/nnet_packet.hpp b/host/core/nnet/nnet_packet.hpp index 0cf5173b8..0917cf88f 100644 --- a/host/core/nnet/nnet_packet.hpp +++ b/host/core/nnet/nnet_packet.hpp @@ -10,7 +10,6 @@ #include "tensor_info.hpp" #include "tensor_entry_container.hpp" #include "../host_data_packet.hpp" -#include "../pipeline/depth_calculation_interface.hpp" class NNetPacket @@ -18,16 +17,13 @@ class NNetPacket public: NNetPacket( std::vector> &tensors_raw_data, - const std::vector &tensors_info, - DepthCalculationInterface* depth_calculation_interface + const std::vector &tensors_info ) : _tensors_raw_data(tensors_raw_data) , _tensors_info(&tensors_info) , _tensor_entry_container(new TensorEntryContainer( - tensors_raw_data, tensors_info, depth_calculation_interface)) + tensors_raw_data, tensors_info)) { - assert(nullptr != depth_calculation_interface); - for (size_t i = 0; i < tensors_info.size(); ++i) { _tensor_name_to_index[ tensors_info.at(i).output_tensor_name ] = i; diff --git a/host/core/nnet/tensor_entry.hpp b/host/core/nnet/tensor_entry.hpp index 8f9ed922a..0b4a53581 100644 --- a/host/core/nnet/tensor_entry.hpp +++ b/host/core/nnet/tensor_entry.hpp @@ -6,7 +6,6 @@ #include "tensor_info.hpp" #include "../types.hpp" -#include "../pipeline/depth_calculation_interface.hpp" struct TensorEntry @@ -17,7 +16,6 @@ struct TensorEntry unsigned properties_number = 0; int nnet_input_width = 0; int nnet_input_height = 0; - DepthCalculationInterface* depth_calulator = nullptr; const std::unordered_map* output_property_key_string_to_index = nullptr; const std::vector>* output_property_value_string_to_index = nullptr; @@ -47,26 +45,4 @@ struct TensorEntry return getFloatByIndex(arr_index); } - float getDistance() - { - assert(nullptr != depth_calulator); - assert(0 != nnet_input_height); - assert(0 != nnet_input_width); - - float result = depth_calulator->c_distance_undefined; - - if (depth_calulator->canCalculateDistance()) - { - // TODO: remove hardcode - auto rx1 = getFloat("left"); - auto ry1 = getFloat("top"); - auto rx2 = getFloat("right"); - auto ry2 = getFloat("bottom"); - - return depth_calulator->getDistanceForRectangle( - rx1, ry1, rx2, ry2, nnet_input_width, nnet_input_height); - } - - return result; - } }; diff --git a/host/core/nnet/tensor_entry_container.hpp b/host/core/nnet/tensor_entry_container.hpp index 379f20da9..7f9739804 100644 --- a/host/core/nnet/tensor_entry_container.hpp +++ b/host/core/nnet/tensor_entry_container.hpp @@ -17,12 +17,9 @@ class TensorEntryContainer public: TensorEntryContainer( std::vector> &tensors_raw_data, - const std::vector &tensors_info, - DepthCalculationInterface* depth_calculation_interface - ) + const std::vector &tensors_info ) : _tensors_raw_data(tensors_raw_data) , _tensors_info(&tensors_info) - , _depth_calculation_interface(depth_calculation_interface) {} unsigned size() const @@ -65,7 +62,6 @@ class TensorEntryContainer te.properties_number = entry_byte_size / te.output_properties_type_size; te.nnet_input_width = ti.nnet_input_width; te.nnet_input_height = ti.nnet_input_height; - te.depth_calulator = _depth_calculation_interface; if (ti.output_properties_dimensions.size() == 1) { @@ -100,7 +96,6 @@ class TensorEntryContainer private: std::vector> _tensors_raw_data; const std::vector* _tensors_info = nullptr; - DepthCalculationInterface* _depth_calculation_interface = nullptr; }; diff --git a/host/core/pipeline/cnn_host_pipeline.cpp b/host/core/pipeline/cnn_host_pipeline.cpp index 5e34a509a..90e54f431 100644 --- a/host/core/pipeline/cnn_host_pipeline.cpp +++ b/host/core/pipeline/cnn_host_pipeline.cpp @@ -1,133 +1,24 @@ #include #include "cnn_host_pipeline.hpp" -#include "../depth/depth_packet.hpp" #include "../../../shared/timer.hpp" -void CNNHostPipeline::searchAndCacheStreamsForDepth() -{ - if (_depth_type == DepthType::DepthAverage) - { - searchAndCacheStreamsForDepthAverage(); - } - else if (_depth_type == DepthType::DepthMedian) - { - searchAndCacheStreamsForDepthMedian(); - } -} - - -void CNNHostPipeline::searchAndCacheStreamsForDepthAverage() -{ - for (auto &packet : _consumed_packets) - { - if ((packet->size() > 16) && - (c_depth_stream_names.find(packet->stream_name) != c_depth_stream_names.end())) - { - // update cache - _depth_packet_cached = packet; - } - } -} - - -void CNNHostPipeline::searchAndCacheStreamsForDepthMedian() -{ - for (auto &packet : _consumed_packets) - { - if ((packet->size() > 16) && (packet->stream_name == c_disparity_stream_name)) - { - // update cache - _depth_packet_cached = packet; - } - } -} - - -bool CNNHostPipeline::setHostCalcDepthConfigs( - const std::string &depth_type, float padding_factor, - float horizontal_fov_deg, float baseline_m -) -{ - bool result = false; - - do - { - // padding_factor - _padding_factor = padding_factor; - _horizontal_fov_deg = horizontal_fov_deg; - _baseline_m = baseline_m; - - // string -> depth_type - auto it = c_string_to_depth_type.find(depth_type); - if (it == c_string_to_depth_type.end()) - { - std::cout << "Wrong depth type: " << depth_type << "\n"; - break; - } - else - { - _depth_type = it->second; - } - - // check available streams - if (_depth_type == DepthType::DepthAverage) - { - // for average - bool has_stream = false; - - for (const auto &sname : c_depth_stream_names) - { - if (_observing_stream_names.find(sname) != - _observing_stream_names.end()) - { - has_stream = true; - break; - } - } - - if (!has_stream) - { - std::cout << "Theres is no required stream for depth calculation;\n"; - break; - } - } - else if (_depth_type == DepthType::DepthMedian) - { - // for median - if (_observing_stream_names.find(c_disparity_stream_name) == - _observing_stream_names.end()) - { - std::cout << "Theres is no required stream for depth calculation: " << c_disparity_stream_name << "\n"; - break; - } - } - - result = true; - } - while (false); - - return result; -} - std::list> CNNHostPipeline::getConsumedNNetPackets() { std::list> result; - searchAndCacheStreamsForDepth(); - // search for cnn result packet for (auto &packet : _consumed_packets) { - if ((packet->size() > 16) && (packet->stream_name == c_nn_result_stream_name)) + if ((packet->size() > 16) && (packet->stream_name == cnn_result_stream_name)) { std::vector> tensors; tensors.push_back(packet); std::shared_ptr tensor_result(new NNetPacket( - tensors, _tensors_info, this)); + tensors, _tensors_info)); result.push_back(tensor_result); } } @@ -160,42 +51,3 @@ CNNHostPipeline::getAvailableNNetAndDataPackets() return result; } - -bool CNNHostPipeline::canCalculateDistance() const -{ - return - _depth_type != DepthType::DepthNone && - nullptr != _depth_packet_cached; -} - - -float CNNHostPipeline::getDistanceForRectangle( - float rx1, float ry1, - float rx2, float ry2, - int width, int height -) -{ - assert(_depth_type != DepthType::DepthNone); - assert(nullptr != _depth_packet_cached); - - float result = -1.f; - - auto x1 = rx1; - auto y1 = ry1; - auto x2 = rx2; - auto y2 = ry2; - - if (_depth_type == DepthType::DepthAverage) - { - result = DepthPacket(_depth_packet_cached) - .getAverageDistanceForRectangle(x1, y1, x2, y2, _padding_factor); - } - else if (_depth_type == DepthType::DepthMedian) - { - result = DepthPacket(_depth_packet_cached) - .getMedianDistanceForRectangle(x1, y1, x2, y2, - _padding_factor, _horizontal_fov_deg, _baseline_m); - } - - return result; -} diff --git a/host/core/pipeline/cnn_host_pipeline.hpp b/host/core/pipeline/cnn_host_pipeline.hpp index a718ea1d7..8bd025b5c 100644 --- a/host/core/pipeline/cnn_host_pipeline.hpp +++ b/host/core/pipeline/cnn_host_pipeline.hpp @@ -3,7 +3,6 @@ #include #include -#include "depth_calculation_interface.hpp" #include "host_pipeline.hpp" #include "../nnet/tensor_info.hpp" #include "../nnet/nnet_packet.hpp" @@ -11,38 +10,14 @@ class CNNHostPipeline : public HostPipeline - , public DepthCalculationInterface { private: - enum class DepthType { - DepthNone, - DepthAverage, - DepthMedian - }; - const std::unordered_map c_string_to_depth_type = - { - {"", DepthType::DepthNone}, - {"average", DepthType::DepthAverage}, - {"median", DepthType::DepthMedian} - }; - - - const std::string c_nn_result_stream_name = "metaout"; + const std::string cnn_result_stream_name = "metaout"; const std::string c_disparity_stream_name = "disparity"; - const std::set c_depth_stream_names = {"depth_mm_h", "depth"}; const std::vector _tensors_info; - DepthType _depth_type = DepthType::DepthNone; - float _padding_factor = 0.3f; - float _horizontal_fov_deg = 69.f; - float _baseline_m = 0.035f; - std::shared_ptr _depth_packet_cached; - - void searchAndCacheStreamsForDepth(); - void searchAndCacheStreamsForDepthAverage(); - void searchAndCacheStreamsForDepthMedian(); std::list> getConsumedNNetPackets(); @@ -52,10 +27,6 @@ class CNNHostPipeline {} virtual ~CNNHostPipeline() {} - bool setHostCalcDepthConfigs( - const std::string &depth_type, float padding_factor, - float horizontal_fov_deg, float baseline_m); - std::tuple< std::list>, @@ -63,12 +34,4 @@ class CNNHostPipeline > getAvailableNNetAndDataPackets(); - - virtual bool canCalculateDistance() const; - - virtual float getDistanceForRectangle( - float rx1, float ry1, - float rx2, float ry2, - int width, int height - ); }; diff --git a/host/core/pipeline/depth_calculation_interface.hpp b/host/core/pipeline/depth_calculation_interface.hpp deleted file mode 100644 index 74decd390..000000000 --- a/host/core/pipeline/depth_calculation_interface.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - - -class DepthCalculationInterface -{ -public: - const float c_distance_undefined = -1.f; - - - virtual ~DepthCalculationInterface() {} - - - virtual bool canCalculateDistance() const = 0; - - virtual float getDistanceForRectangle( - float rx1, float ry1, - float rx2, float ry2, - int width, int height - ) = 0; -}; diff --git a/host/core/pipeline/host_pipeline_config.cpp b/host/core/pipeline/host_pipeline_config.cpp index 73daebb88..2f1352d53 100644 --- a/host/core/pipeline/host_pipeline_config.cpp +++ b/host/core/pipeline/host_pipeline_config.cpp @@ -67,15 +67,6 @@ bool HostPipelineConfig::initWithJSON(const json &json_obj) depth.type = depth_obj.at("type").get(); } - if (depth.type == "average" && !hasStream("depth_mm_h")) - { - streams.emplace_back("depth_mm_h"); - } - else if (depth.type == "median" && !hasStream("disparity")) - { - streams.emplace_back("disparity"); - } - // "padding_factor" if (depth_obj.contains("padding_factor")) { diff --git a/host/core/pipeline/pipeline_builder.cpp b/host/core/pipeline/pipeline_builder.cpp deleted file mode 100644 index ae3330c88..000000000 --- a/host/core/pipeline/pipeline_builder.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "pipeline_builder.hpp" diff --git a/host/core/pipeline/pipeline_builder.hpp b/host/core/pipeline/pipeline_builder.hpp deleted file mode 100644 index 3f59c932d..000000000 --- a/host/core/pipeline/pipeline_builder.hpp +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once - diff --git a/host/core/types.cpp b/host/core/types.cpp index 2f8569aea..fcf143415 100644 --- a/host/core/types.cpp +++ b/host/core/types.cpp @@ -26,7 +26,6 @@ unsigned size_of_type(const Type& type) -#define MAX_NUM_FACES 32 #define EXP_MASK_F32 0x7F800000U #define EXP_MASK_F16 0x7C00U float float16to32(uint16_t x) diff --git a/host/py_module/CMakeLists.txt b/host/py_module/CMakeLists.txt index ddf8984fe..e18cfdf52 100644 --- a/host/py_module/CMakeLists.txt +++ b/host/py_module/CMakeLists.txt @@ -57,7 +57,6 @@ pybind11_add_module( ../../shared/json_helper.cpp ../../shared/stream/stream_info.cpp ../../shared/xlink/xlink_wrapper.cpp - ../../shared/disparity_luts.cpp ${XLINK_SOURCES} ) diff --git a/host/py_module/py_bindings.cpp b/host/py_module/py_bindings.cpp index bcc5920e2..13bc6d9ec 100644 --- a/host/py_module/py_bindings.cpp +++ b/host/py_module/py_bindings.cpp @@ -416,7 +416,6 @@ std::shared_ptr create_pipeline( json_config_obj["ai"]["calc_dist_to_bb"] = config.ai.calc_dist_to_bb; bool add_disparity_post_processing_color = false; - bool add_disparity_post_processing_mm = false; std::vector pipeline_device_streams; for (const auto &stream : config.streams) @@ -425,12 +424,7 @@ std::shared_ptr create_pipeline( { add_disparity_post_processing_color = true; json obj = { {"name", "disparity"} }; - json_config_obj["_pipeline"]["_streams"].push_back(obj); - } - else if (stream.name == "depth_mm_h") - { - add_disparity_post_processing_mm = true; - json obj = { {"name", "disparity"} }; + if (0.f != stream.max_fps) { obj["max_fps"] = stream.max_fps; }; json_config_obj["_pipeline"]["_streams"].push_back(obj); } else @@ -625,19 +619,14 @@ std::shared_ptr create_pipeline( // disparity post processor - if (add_disparity_post_processing_mm || - add_disparity_post_processing_color - ) + if (add_disparity_post_processing_color) { g_disparity_post_proc = std::unique_ptr( new DisparityStreamPostProcessor( - add_disparity_post_processing_color, - add_disparity_post_processing_mm - )); + add_disparity_post_processing_color)); const std::string stream_in_name = "disparity"; const std::string stream_out_color_name = "depth_color_h"; - const std::string stream_out_mm_name = "depth_mm_h"; if (g_xlink->openStreamInThreadAndNotifyObservers(c_streams_myriad_to_pc.at(stream_in_name))) { @@ -648,12 +637,6 @@ std::shared_ptr create_pipeline( gl_result->makeStreamPublic(stream_out_color_name); gl_result->observe(*g_disparity_post_proc.get(), c_streams_myriad_to_pc.at(stream_out_color_name)); } - - if (add_disparity_post_processing_mm) - { - gl_result->makeStreamPublic(stream_out_mm_name); - gl_result->observe(*g_disparity_post_proc.get(), c_streams_myriad_to_pc.at(stream_out_mm_name)); - } } else { @@ -662,19 +645,6 @@ std::shared_ptr create_pipeline( break; } } - - if (!gl_result->setHostCalcDepthConfigs( - config.depth.type, - config.depth.padding_factor, - config.board_config.left_fov_deg, - config.board_config.left_to_right_distance_m - )) - { - std::cout << "depthai: Cant set depth;\n"; - break; - } - - init_ok = true; std::cout << "depthai: INIT OK!\n"; } @@ -831,7 +801,6 @@ PYBIND11_MODULE(depthai, m) .def("__len__", &TensorEntry::getPropertiesNumber) .def("__getitem__", &TensorEntry::getFloat) .def("__getitem__", &TensorEntry::getFloatByIndex) - .def("distance", &TensorEntry::getDistance) ; diff --git a/shared/depthai_constants.hpp b/shared/depthai_constants.hpp index 3b1313957..db7aefd49 100644 --- a/shared/depthai_constants.hpp +++ b/shared/depthai_constants.hpp @@ -24,10 +24,9 @@ std::unordered_map c_streams_myriad_to_pc = {"right", StreamInfo("right", 921600 + sizeof(FrameMetadata), { 720, 1280} )}, {"disparity", StreamInfo("disparity", 921600, { 720, 1280} )}, - {"depth", StreamInfo("depth", 921600, { 720, 1280} )}, + // {"depth", StreamInfo("depth", 921600, { 720, 1280} )}, {"depth_sipp", StreamInfo("depth_sipp", 0, { 720, 1280}, 2 )}, {"depth_color_h", StreamInfo("depth_color_h", 720*1280*3, { 720, 1280, 3} )}, - {"depth_mm_h", StreamInfo("depth_mm_h", 720*1280*2, { 720, 1280}, 2 )}, {"metaout", StreamInfo("metaout", 2*2816)}, // 1408 {"previewout", StreamInfo("previewout", 1920256)}, diff --git a/shared/disparity_luts.cpp b/shared/disparity_luts.cpp deleted file mode 100644 index 942ebab68..000000000 --- a/shared/disparity_luts.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include - -#include -#include - -#include "disparity_luts.hpp" - - -float calculateDisparityToDepthMM( - unsigned disparity, - unsigned width, - float fov, - float base_line_dist -) -{ - if (disparity == 0) - { - return -1.f; - } - else - { - const float pi = std::acos(-1); - float focal_length = width / (2.f * std::tan(fov / 2 / 180.f * pi)); - float z_m = (focal_length * base_line_dist / disparity); - return z_m * 1000.f; - } -} - -std::vector generateLUTDisparityToDepthMM( - unsigned width, - float fov, - float base_line_dist -) -{ - std::vector result(256, 0); - - const float pi = std::acos(-1); - float focal_length = width / (2.f * std::tan(fov / 2 / 180.f * pi)); - - for (int i = 0; i < DISPARITY_SIZE; ++i) - { - float z_m = (focal_length * base_line_dist / i); - result[i] = std::min(65535.f, z_m * 1000.f); // m -> mm - } - - return result; -} diff --git a/shared/disparity_luts.hpp b/shared/disparity_luts.hpp index f4b331dbc..3654c1245 100644 --- a/shared/disparity_luts.hpp +++ b/shared/disparity_luts.hpp @@ -70,16 +70,3 @@ static unsigned char c_disp_to_color[DISPARITY_SIZE][3] = {0, 0, 148} }; - -float calculateDisparityToDepthMM( - unsigned disparity, - unsigned width, - float fov, - float base_line_dist -); - -std::vector generateLUTDisparityToDepthMM( - unsigned width, - float fov, - float base_line_dist -);