Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Openvino tensor representation #8

Merged
merged 16 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ add_library(${TARGET_NAME}
src/disparity_stream_post_processor.cpp
src/host_data_reader.cpp
src/host_json_helper.cpp
src/types.cpp
src/device.cpp
src/matrix_ops.cpp
src/bspatch/bspatch.c
Expand Down
2 changes: 1 addition & 1 deletion cmake/Depthai/DepthaiDeviceSideConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")

# "full commit hash of device side binary"
set(DEPTHAI_DEVICE_SIDE_COMMIT "2f9c918bc823a0fbeb4ce54696966045ca7cb13c")
set(DEPTHAI_DEVICE_SIDE_COMMIT "6c0eed5cbc62fb423e96e4be9e720ab8033e02f5")

# "version if applicable"
set(DEPTHAI_DEVICE_SIDE_VERSION "")
45 changes: 0 additions & 45 deletions include/depthai/float16_to_float32_converter.hpp

This file was deleted.

15 changes: 8 additions & 7 deletions include/depthai/host_data_packet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,25 @@ struct HostDataPacket
std::uint8_t* pData = (std::uint8_t*) in_data;

// Regular copy (1 allocation only)
data = std::vector<std::uint8_t>(pData, pData + frameSize);
data = std::make_shared<std::vector<std::uint8_t>>(pData, pData + frameSize);

constructor_timer = Timer();
}

unsigned size()
{
return data.size();
return data->size();
}

const unsigned char* getData() const
{
return data.data();
return data->data();
}

std::string getDataAsString()
{
assert(data[data.size() - 1] == 0); // checking '\0'
const unsigned char* data = getData();
assert(data[size() - 1] == 0); // checking '\0'
return reinterpret_cast<const char*>(&data[0]);
}

Expand All @@ -84,13 +85,13 @@ struct HostDataPacket

ObjectTracker getObjectTracker(){
ObjectTracker ot_tracklets;
assert(data.size() == sizeof(ObjectTracker));
memcpy(&ot_tracklets, data.data(), sizeof(ObjectTracker));
assert(size() == sizeof(ObjectTracker));
memcpy(&ot_tracklets, getData(), sizeof(ObjectTracker));
return ot_tracklets;
}

boost::optional<FrameMetadata> opt_metadata;
std::vector<unsigned char> data;
std::shared_ptr<std::vector<unsigned char>> data;
std::string stream_name;
std::vector<int> dimensions;
int elem_size;
Expand Down
55 changes: 0 additions & 55 deletions include/depthai/landmarks_parser.hpp

This file was deleted.

42 changes: 0 additions & 42 deletions include/depthai/mobilenet_metadata.hpp

This file was deleted.

53 changes: 37 additions & 16 deletions include/depthai/nnet/nnet_packet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,26 @@
#include <unordered_map>
#include <vector>

#include "tensor_entry.hpp"
#include "tensor_info.hpp"
#include "tensor_entry_container.hpp"
#include "depthai-shared/tensor_info.hpp"
#include "depthai-shared/cnn_info.hpp"
#include "../host_data_packet.hpp"


class NNetPacket
{
public:
NNetPacket(
std::vector<std::shared_ptr<HostDataPacket>> &tensors_raw_data,
const std::vector<TensorInfo> &tensors_info
std::shared_ptr<HostDataPacket> &tensors_raw_data,
const std::vector<dai::TensorInfo> &input_info,
const std::vector<dai::TensorInfo> &tensors_info
)
: _tensors_raw_data(tensors_raw_data)
, _tensors_info(&tensors_info)
, _tensor_entry_container(new TensorEntryContainer(
tensors_raw_data, tensors_info))
, _input_info(input_info)
, _tensors_info(tensors_info)
{
for (size_t i = 0; i < tensors_info.size(); ++i)
{
_tensor_name_to_index[ tensors_info.at(i).output_tensor_name ] = i;
_tensor_name_to_index[ tensors_info[i].name ] = i;
}

if (_tensor_name_to_index.size() != tensors_info.size())
Expand All @@ -35,22 +34,44 @@ class NNetPacket
}
}

std::shared_ptr<dai::Detections> getDetectedObjects()
{
std::shared_ptr<std::vector<unsigned char>> data = _tensors_raw_data->data;
//copy-less return, wrapped in shared_ptr
std::shared_ptr<dai::Detections> detections;
detections = std::shared_ptr<dai::Detections>(data, reinterpret_cast<dai::Detections *>(data->data()));
return detections;
}

std::shared_ptr<TensorEntryContainer> getTensorEntryContainer()
int getTensorsSize()
{
return _tensor_entry_container;
return _tensors_info.size();
}

boost::optional<FrameMetadata> getMetadata(){
// TODO
return _tensors_raw_data[0]->getMetadata();
return _tensors_raw_data->getMetadata();
}

const std::vector<dai::TensorInfo> getInputLayersInfo()
{
return _input_info;
}

const std::vector<dai::TensorInfo> getOutputLayersInfo()
{
return _tensors_info;
}

protected:
std::string getTensorName(int index)
{
return _tensors_info[index].name;
}

protected:
std::shared_ptr<TensorEntryContainer> _tensor_entry_container;

std::vector<std::shared_ptr<HostDataPacket>> _tensors_raw_data;
const std::vector<TensorInfo>* _tensors_info = nullptr;
std::shared_ptr<HostDataPacket> _tensors_raw_data;
const std::vector<dai::TensorInfo> _input_info, _tensors_info;

std::unordered_map<std::string, unsigned> _tensor_name_to_index;
};
64 changes: 0 additions & 64 deletions include/depthai/nnet/tensor_entry.hpp

This file was deleted.

Loading