Skip to content

Commit b89598d

Browse files
Merge pull request #59 from luxonis/output_format_checks
NN output format checks
2 parents ad04e96 + 09142c2 commit b89598d

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/nnet_packet_bindings.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,13 @@ static py::array* _getTensorPythonNumpyArray(unsigned char *data, TensorInfo ti)
214214

215215
py::array* PyNNetPacket::getTensor(unsigned index)
216216
{
217+
if(_NN_config[index].contains("output_format"))
218+
{
219+
if(_NN_config[index]["output_format"] != std::string("raw"))
220+
{
221+
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");
222+
}
223+
}
217224
assert(index < _tensors_info.size());
218225
TensorInfo ti = _tensors_info[index];
219226
unsigned char * data = _tensors_raw_data->data->data();

src/nnet_packet_bindings.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ struct PyNNetPacket : public NNetPacket {
2020
public:
2121
using NNetPacket::_tensors_raw_data;
2222
using NNetPacket::_tensor_name_to_index;
23-
23+
using NNetPacket::_NN_config;
2424

2525
};

0 commit comments

Comments
 (0)