JeVois
1.20
JeVois Smart Embedded Machine Vision Toolkit
|
Share this page: |
|
|
|
 |
 |
|
Go to the documentation of this file.
22 #include <opencv2/core/core.hpp>
23 #include <tensorflow/lite/c/common.h>
24 #include <ovxlib/vsi_nn_pub.h>
27 #include <hailo/hailort.h>
28 #include <onnxruntime_cxx_api.h>
45 std::map<int, std::string>
readLabelsFile(std::string
const & fname);
49 std::string
getLabel(std::map<int, std::string>
const & labels,
int id);
52 int stringToRGBA(std::string
const & label,
unsigned char alpha = 128);
55 void topK(
float const * pfProb,
float * pfMaxProb, uint32_t * pMaxClass, uint32_t outputCount, uint32_t topNum);
58 std::string
shapestr(cv::Mat
const & m);
61 std::string
shapestr(TfLiteTensor
const * t);
64 std::string
shapestr(vsi_nn_tensor_attr_t
const & attr);
67 std::vector<size_t>
strshape(std::string
const & str);
70 int tf2cv(TfLiteType t);
73 vsi_nn_type_e
tf2vsi(TfLiteType t);
76 int vsi2cv(vsi_nn_type_e t);
79 void clamp(cv::Rect & r,
int width,
int height);
82 void clamp(cv::Rect2f & r,
float width,
float height);
86 std::vector<vsi_nn_tensor_attr_t>
parseTensorSpecs(std::string
const & specs);
93 cv::Mat
attrmat(vsi_nn_tensor_attr_t
const & attr,
void * dataptr =
nullptr);
96 std::vector<int>
attrdims(vsi_nn_tensor_attr_t
const & attr);
99 cv::Size
attrsize(vsi_nn_tensor_attr_t
const & attr);
102 std::string
attrstr(vsi_nn_tensor_attr_t
const & attr);
105 bool attrmatch(vsi_nn_tensor_attr_t
const & attr, cv::Mat
const & blob);
108 vsi_nn_tensor_attr_t
tensorattr(TfLiteTensor
const * t);
114 size_t softmax(
float const * input,
size_t const n,
size_t const stride,
float const fac,
float * output,
120 cv::Mat
quantize(cv::Mat
const & m, vsi_nn_tensor_attr_t
const & attr);
124 cv::Mat
dequantize(cv::Mat
const & m, vsi_nn_tensor_attr_t
const & attr);
132 std::string
shapestr(hailo_vstream_info_t
const & vi);
135 vsi_nn_tensor_attr_t
tensorattr(hailo_vstream_info_t
const & vi);
138 vsi_nn_type_e
hailo2vsi(hailo_format_type_t t);
141 vsi_nn_type_e
onnx2vsi(ONNXTensorElementDataType t);
144 std::string
shapestr(Ort::ConstTensorTypeAndShapeInfo
const & ti);
147 vsi_nn_tensor_attr_t
tensorattr(Ort::ConstTensorTypeAndShapeInfo
const & ti);
void clamp(cv::Rect &r, int width, int height)
Clamp a rectangle to within given image width and height.
int tf2cv(TfLiteType t)
Convert from TensorFlow data type to OpenCV.
size_t softmax(float const *input, size_t const n, size_t const stride, float const fac, float *output, bool maxonly)
Apply softmax to a float vector.
cv::Mat dequantize(cv::Mat const &m, vsi_nn_tensor_attr_t const &attr)
Dequantize an output to float32 according to the quantization spec in attr.
int vsi2cv(vsi_nn_type_e t)
Convert from NPU data type to OpenCV.
vsi_nn_tensor_attr_t tensorattr(TfLiteTensor const *t)
Get tensor shape and type attributes for a TensorFlow Lite tensor.
int stringToRGBA(std::string const &label, unsigned char alpha=128)
Compute a color from a label name.
std::map< int, std::string > readLabelsFile(std::string const &fname)
Read a label file.
size_t effectiveDims(cv::Mat const &m)
Returns the number of non-unit dims in a cv::Mat.
std::vector< vsi_nn_tensor_attr_t > parseTensorSpecs(std::string const &specs)
Parse tensor specification.
bool attrmatch(vsi_nn_tensor_attr_t const &attr, cv::Mat const &blob)
Check that a cv::Mat blob matches exactly the spec of an attr.
std::string shapestr(cv::Mat const &m)
Get a string of the form: "nD AxBxC... TYPE" from an n-dimensional cv::Mat with data type TYPE.
std::string getLabel(std::map< int, std::string > const &labels, int id)
Get a label from an id.
vsi_nn_type_e onnx2vsi(ONNXTensorElementDataType t)
Convert from ONNX-Runtime data type to vsi_nn.
std::vector< int > attrdims(vsi_nn_tensor_attr_t const &attr)
Get a tensor dims as a vector of int, useful to construct a matching cv::Mat.
std::vector< size_t > strshape(std::string const &str)
Get a vector of size_t from a string containing AxBxC...
vsi_nn_type_e hailo2vsi(hailo_format_type_t t)
Convert from Hailo data type to vsi_nn.
cv::Size attrsize(vsi_nn_tensor_attr_t const &attr)
Get a tensor's (width, height) size in cv::Size format, skipping over other dimensions.
std::string attrstr(vsi_nn_tensor_attr_t const &attr)
Get a string describing the specs of a tensor, including quantification specs (not provided by shapes...
cv::Mat attrmat(vsi_nn_tensor_attr_t const &attr, void *dataptr=nullptr)
Construct a cv::Mat from attr and possibly data pointer.
vsi_nn_type_e tf2vsi(TfLiteType t)
Convert from TensorFlow data type to vsi_nn.
cv::Mat quantize(cv::Mat const &m, vsi_nn_tensor_attr_t const &attr)
Quantize from float32 to fixed-point according to the quantization spec in attr.
void topK(float const *pfProb, float *pfMaxProb, uint32_t *pMaxClass, uint32_t outputCount, uint32_t topNum)
Get top-k entries and their indices.