p2_ort_base

namespace Ort
class P2OrtBase : public Ort::OrtBase
#include <p2_ort_base.hpp>

An Precision-Level 2 (P2) ONNXRuntime (Ort) Base class object. This class object instantiates a Precision Level 2 Ort Session which takes a typical ONNX model used for solely object detection and runs an inference engine.

Public Functions

P2OrtBase(float ratio, int newW, int newH, int paddedW, int paddedH, const uint16_t numClasses, const std::string &modelPath, const boost::optional<size_t> &gpuIdx = boost::none, const boost::optional<std::vector<std::vector<int64_t>>> &inputShapes = boost::none)

A Constructor function.

~P2OrtBase()

A Destructor function.

EPD::EPDObjectDetection infer(const cv::Mat &inputImg)

A auxillary Mutator function that calls the internal overloading infer function.

inline uint16_t getNumClasses() const

A Getter function that gets the number of object names used for an ongoing session.

inline const std::vector<std::string> &getClassNames() const

A Getter function that gets the list of object text labels which will be used for outputting visualized inference result or for specific use-case filters.

void initClassNames(const std::vector<std::string> &classNames)

A Mutator function that sets the list of object text labels to be used for the P1 Ort Session.

Public Static Attributes

static constexpr int64_t MIN_IMAGE_SIZE = 800

A fixed minimal image size needed for a lower bound requirement for image classification of adequate result.

Private Functions

void preprocess(float *dst, const cv::Mat &imgSrc, const int64_t targetImgWidth, const int64_t targetImgHeight, const int numChannels) const

A Mutator function that converts a 3-layered 2D RGB input image into a 1D input data tensor to be passed to the Ort

Session for processing.

This variant takes a generic input image represented by a conventional opencv Matrix.

EPD::EPDObjectDetection infer(const cv::Mat &inputImg, int newW, int newH, int paddedW, int paddedH, float ratio, float *dst, float confThresh, const cv::Scalar &meanVal)

A Mutator function that runs a P2 Ort Session and gets P2 inference result for use by external agents.

Private Members

const uint16_t m_numClasses

The number of object text labels given an input label list.

float m_ratio

The aspect ratio calculated from the dimension of an input image frame, which is provided when the first input image is received by EasyPerceptionDeployment.

int m_newW

The new padded frame dimensions of an input image. This is used for P2 and P3 object detection.

int m_newH
int m_paddedW
int m_paddedH
std::vector<std::string> m_classNames

A vector of object text labels given an input label list.