NNSequential
class NNSequential : public NNObject
{
public:
virtual int add(std::shared_ptr<NNModel> model) = 0;
virtual int clear() = 0;
public:
virtual int prepare() = 0;
virtual int prepare(std::shared_ptr<NNResultListener> listener) = 0;
virtual int destroy() = 0;
virtual std::string getGraphInfo() = 0;
public:
virtual int detect(
std::shared_ptr<NNData> input, uint32_t timeoutInMS) = 0;
public:
static std::shared_ptr<NNLogger> getLogger();
static std::shared_ptr<NNSequential> createSequential();
};
Introduction to the Class
A sequential neural network model container that allows adding, managing, and running models in a sequence.
This class inherits from NNObject and provides a framework for creating a sequential pipeline of neural network models. It defines a set of pure virtual methods that must be implemented by derived classes to handle model addition, preparation, destruction, detection, and logging.
Introduction to the Class's Methods
int add(std::shared_ptr<NNModel> model)
brief: Adds a neural network model to the sequential container.
param
model: The shared pointer to the neural network model to be added.
return int: An integer indicating the status of the operation. Typically, 0 indicates success, and non-zero values indicate errors.
int clear()
brief: Clears all models from the sequential container.
return int: An integer indicating the status of the operation. Typically, 0 indicates success, and non-zero values indicate errors.
int prepare()
brief: Prepares the sequential container for detection without a result listener. This method may involve allocating resources, compiling models, or performing other necessary setup tasks.
return int: An integer indicating the status of the operation. Typically, 0 indicates success, and non-zero values indicate errors.
int prepare(std::shared_ptr<NNResultListener> listener)
brief: Prepares the sequential container for detection with a result listener. This method is similar to prepare() but also registers a result listener to receive callbacks for detection results and errors.
param
listener: A shared pointer to an `NNResultListener` object.
return int: An integer indicating the status of the operation. Typically, 0 indicates success, and non-zero values indicate errors.
int destroy()
brief: Destroys the sequential container, releasing any allocated resources.
return int: An integer indicating the status of the operation. Typically, 0 indicates success, and non-zero values indicate errors.
std::string getGraphInfo()
brief: Retrieves a string containing information about the neural network graph.
return string: A string with graph information.
int detect(std::shared_ptr<NNData> input, uint32_t timeoutInMS)
brief: Runs detection using the input data and specified timeout.
param
input: A shared pointer to an `NNData` object containing the input data.
timeoutInMS: The maximum time to wait for the result, in milliseconds.
return int: An integer indicating the status of the operation. Typically, 0 indicates success, and non-zero values indicate errors.
static std::shared_ptr<NNLogger> getLogger()
brief: Retrieves the shared logger instance for this class.
return string: The shared pointer to the logger instance.
static std::shared_ptr<NNSequential> createSequential()
brief: Creates a new instance of the sequential container.
return string: The shared pointer to the newly created sequential container instance.