JeVois  1.22
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
Utils.H File Reference
#include <map>
#include <string>
#include <opencv2/core/core.hpp>
#include <tensorflow/lite/c/common.h>
#include <ovxlib/vsi_nn_pub.h>
#include <hailo/hailort.h>
#include <onnxruntime_cxx_api.h>
#include <jevois/DNN/details/UtilsImpl.H>
Include dependency graph for Utils.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  jevois
 Main namespace for all JeVois classes and functions.
 
namespace  jevois::dnn
 Deep neural networks.
 

Functions

std::map< int, std::string > jevois::dnn::readLabelsFile (std::string const &fname)
 Read a label file.
 
std::string jevois::dnn::getLabel (std::map< int, std::string > const &labels, int id, bool namedonly=false)
 Get a label from an id.
 
int jevois::dnn::stringToRGBA (std::string const &label, unsigned char alpha=128)
 Compute a color from a label name.
 
void jevois::dnn::topK (float const *pfProb, float *pfMaxProb, uint32_t *pMaxClass, uint32_t outputCount, uint32_t topNum)
 Get top-k entries and their indices.
 
std::string jevois::dnn::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 jevois::dnn::shapestr (std::vector< size_t > dims, int typ)
 Get a string of the form: "nD AxBxC... TYPE" from an n-dimensional size vector and OpenCV data type TYPE.
 
std::string jevois::dnn::shapestr (std::vector< int > dims, int typ)
 Get a string of the form: "nD AxBxC... TYPE" from an n-dimensional size vector and OpenCV data type TYPE.
 
std::string jevois::dnn::shapestr (TfLiteTensor const *t)
 Get a string of the form: "nD AxBxC... TYPE" from an n-dimensional TfLiteTensor with data type TYPE.
 
std::string jevois::dnn::shapestr (vsi_nn_tensor_attr_t const &attr)
 Get a string of the form: "nD AxBxC... TYPE" from an n-dimensional NPU tensor with data type TYPE.
 
std::vector< size_t > jevois::dnn::strshape (std::string const &str)
 Get a vector of size_t from a string containing AxBxC...
 
int jevois::dnn::tf2cv (TfLiteType t)
 Convert from TensorFlow data type to OpenCV.
 
vsi_nn_type_e jevois::dnn::tf2vsi (TfLiteType t)
 Convert from TensorFlow data type to vsi_nn.
 
int jevois::dnn::vsi2cv (vsi_nn_type_e t)
 Convert from NPU data type to OpenCV.
 
void jevois::dnn::clamp (cv::Rect &r, int width, int height)
 Clamp a rectangle to within given image width and height.
 
void jevois::dnn::clamp (cv::Rect2f &r, float width, float height)
 Clamp a rectangle to within given image width and height.
 
std::vector< vsi_nn_tensor_attr_t > jevois::dnn::parseTensorSpecs (std::string const &specs)
 Parse tensor specification.
 
cv::Mat jevois::dnn::attrmat (vsi_nn_tensor_attr_t const &attr, void *dataptr=nullptr)
 Construct a cv::Mat from attr and possibly data pointer.
 
std::vector< int > jevois::dnn::attrdims (vsi_nn_tensor_attr_t const &attr)
 Get a tensor dims as a vector of int, useful to construct a matching cv::Mat.
 
cv::Size jevois::dnn::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 jevois::dnn::attrstr (vsi_nn_tensor_attr_t const &attr)
 Get a string describing the specs of a tensor, including quantification specs (not provided by shapestr())
 
bool jevois::dnn::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.
 
vsi_nn_tensor_attr_t jevois::dnn::tensorattr (TfLiteTensor const *t)
 Get tensor shape and type attributes for a TensorFlow Lite tensor.
 
float jevois::dnn::fastexp (float x)
 Compute fast exponential using approximation formula.
 
float jevois::dnn::sigmoid (float x)
 Compute sigmoid using fastexp.
 
void jevois::dnn::sigmoid (cv::Mat &m)
 Compute sigmoid using fastexp on every pixel of a Mat of type CV_32F, in-place.
 
size_t jevois::dnn::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.
 
float jevois::dnn::softmax_dfl (float const *src, float *dst, size_t const n, size_t const stride=1)
 Compute softmax and return DFL distance.
 
cv::Mat jevois::dnn::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.
 
cv::Mat jevois::dnn::dequantize (cv::Mat const &m, vsi_nn_tensor_attr_t const &attr)
 Dequantize an output to float32 according to the quantization spec in attr.
 
size_t jevois::dnn::effectiveDims (cv::Mat const &m)
 Returns the number of non-unit dims in a cv::Mat.
 
cv::Mat jevois::dnn::concatenate (std::vector< cv::Mat > const &tensors, int axis)
 Concatenate several tensors into one.
 
std::vector< cv::Mat > jevois::dnn::split (cv::Mat const &tensor, int axis, std::vector< int > const &sizes)
 Split a tensor into several, along a given axis.
 
std::string jevois::dnn::shapestr (hailo_vstream_info_t const &vi)
 Get a string of the form: "nD AxBxC... TYPE" from an n-dimensional Hailo tensor with data type TYPE.
 
vsi_nn_tensor_attr_t jevois::dnn::tensorattr (hailo_vstream_info_t const &vi)
 Get tensor shape and type attributes for a Hailo tensor.
 
vsi_nn_type_e jevois::dnn::hailo2vsi (hailo_format_type_t t)
 Convert from Hailo data type to vsi_nn.
 
vsi_nn_type_e jevois::dnn::onnx2vsi (ONNXTensorElementDataType t)
 Convert from ONNX-Runtime data type to vsi_nn.
 
std::string jevois::dnn::shapestr (Ort::ConstTensorTypeAndShapeInfo const &ti)
 Get a string of the form: "nD AxBxC... TYPE" from an n-dimensional ONNX tensor with data type TYPE.
 
vsi_nn_tensor_attr_t jevois::dnn::tensorattr (Ort::ConstTensorTypeAndShapeInfo const &ti)
 Get tensor shape and type attributes for an ONNX-runtime tensor.