NNModelPluginDef
#if defined(__WINDOWS__)
#if defined(__PLUGIN_EXPORT__)
#define NN_MODEL_PLUGIN_API __declspec(dllexport)
#else
#define NN_MODEL_PLUGIN_API __declspec(dllimport)
#endif
#else
#define NN_MODEL_PLUGIN_API
#endif
#define NN_PLUGIN_CREATE_MODEL "nn_plugin_create_model"
#define NN_PLUGIN_CREATE_MODEL_WITH_LOG "nn_plugin_create_model_with_log"
#define NN_PLUGIN_CREATE_MODEL_WITH_LOG_AND_ARGS "nn_plugin_create_model_with_log_and_args"
/* plugin info related func(the suffix) */
#define NN_MODEL_PLUGIN_INFO_GET_MODEL_NAMES "nn_model_plugin_info_get_model_names"
#define NN_MODEL_PLUGIN_INFO_GET_TEST_IMAGE_NAME "nn_model_plugin_info_get_test_image_name"
#define NN_MODEL_PLUGIN_INFO_GET_TEST_IMAGE_ROI "nn_model_plugin_info_get_test_image_roi"
/* plugin&plugin info related entry library name */
#if defined(__WINDOWS__)
#define NN_MODEL_PLUGIN_LIBRARY_SUFFIX ".dll"
#else
#define NN_MODEL_PLUGIN_LIBRARY_SUFFIX ".so"
#endif
std::string nn_model_plugin_generate_library_name(std::string pluginName);
std::string nn_model_plugin_string_list_to_json(std::vector<std::string> modelNames);
std::vector<std::string> nn_model_plugin_json_to_string_list(std::string modelNamesJson);
#ifdef __cplusplus
extern "C" {
#endif
/* nn plugin func */
typedef int (*nn_module_plugin_get_model_names_func)(char* buffer, int bufferSize);
typedef int (*nn_module_plugin_get_string_func)(const char* modelName, char* buffer, int bufferSize);
typedef int (*nn_module_plugin_get_image_roi_func)(const char* modelName, int* x, int* y, int* width, int* height);
NN_MODEL_PLUGIN_API void* nn_plugin_create_model(const char* modelName);
NN_MODEL_PLUGIN_API void* nn_plugin_create_model_with_log(const char* modelName, uint64_t logHandle, uint64_t logPoolHandle);
NN_MODEL_PLUGIN_API int nn_model_plugin_info_get_model_names(char* buffer, int bufferSize);
NN_MODEL_PLUGIN_API int nn_model_plugin_info_get_test_image_name(const char* modelName, char* buffer, int bufferSize);
NN_MODEL_PLUGIN_API int nn_model_plugin_info_get_test_image_roi(const char* modelName, int* x, int* y, int* width, int* height);
Introduction to the Macros
NN_PLUGIN_CREATE_MODEL
brief: Method name for creating a neural network model.
NN_PLUGIN_CREATE_MODEL_WITH_LOG
brief: Method name for creating a neural network model with logging.
NN_PLUGIN_CREATE_MODEL_WITH_LOG_AND_ARGS
brief: Method name for creating a neural network model with logging and arguments.
NN_MODEL_PLUGIN_INFO_GET_MODEL_NAMES
brief: Method name for retrieving the names of all models supported by a plugin.
NN_MODEL_PLUGIN_INFO_GET_TEST_IMAGE_NAME
brief: Method name for retrieving the name of the test image associated with a specific model.
NN_MODEL_PLUGIN_INFO_GET_TEST_IMAGE_ROI
brief: Method name for retrieving the region of interest (ROI) of the test image for a specific model.
NN_MODEL_PLUGIN_LIBRARY_SUFFIX
brief: Suffix for dynamic-link libraries (DLLs) on Windows or Unix-like systems.
Introduction to the Methods
std::string nn_model_plugin_generate_library_name(std::string pluginName)
brief: Generates the full library name for a given plugin, appending the appropriate library suffix.
param
modelNames: The name of the plugin without the library suffix.
return string: The full library name with the appropriate suffix.
std::string nn_model_plugin_string_list_to_json(std::vector<std::string> modelNames)
brief: Converts a vector of model names to a JSON string.
param
modelNames: A vector containing the names of the models.
return int: A JSON string representing the vector of model names
std::vector<std::string> nn_model_plugin_json_to_string_list(std::string modelNamesJson)
brief: Converts a JSON string representing a list of model names back to a vector of strings.
param
modelNamesJson: A JSON string containing the names of the models.
return std::vector<std::string>: A vector containing the names of the models.
typedef int (*nn_module_plugin_get_model_names_func)(char* buffer, int bufferSize)
brief: Function pointer type for retrieving the names of all models supported by a plugin.
param
buffer: A buffer to store the model names.
bufferSize: The size of the buffer.
return int: A status code indicating the success or failure of the operation.
typedef int (*nn_module_plugin_get_string_func)(const char* modelName, char* buffer, int bufferSize)
brief: Function pointer type for retrieving a string associated with a specific model, such as a test image name.
Param
modelName: The name of the model.
buffer: A buffer to store the string.
bufferSize: The size of the buffer.
return int: A status code indicating the success or failure of the operation.
typedef int (*nn_module_plugin_get_image_roi_func)(const char* modelName, int* x, int* y, int* width, int* height)
brief: Function pointer type for retrieving the region of interest (ROI) of a test image for a specific model.
Param
modelName: The name of the model.
x: A pointer to store the x-coordinate of the ROI.
y: A pointer to store the y-coordinate of the ROI.
width: A pointer to store the width of the ROI.
height: A pointer to store the height of the ROI.
return int: A status code indicating the success or failure of the operation.
void* nn_plugin_create_model(const char* modelName)
brief: Creates a neural network model without logging.
Param
modelName: The name of the model to create.
return int: A pointer to the created model, or nullptr if the creation failed.
void* nn_plugin_create_model_with_log(const char* modelName, uint64_t logHandle, uint64_t logPoolHandle)
brief: Retrieves the shared logger instance for this class.
Param
modelName: The name of the model to create.
logHandle: A handle for logging.
logPoolHandle: A handle for the logging pool.
return int: A pointer to the created model, or nullptr if the creation failed.
int nn_model_plugin_info_get_model_names(char* buffer, int bufferSize)
brief: Retrieves the names of all models supported by a plugin.
param
buffer: A buffer to store the model names.
bufferSize: The size of the buffer.
return int: A status code indicating the success or failure of the operation.
int nn_model_plugin_info_get_test_image_name(const char* modelName, char* buffer, int bufferSize)
brief: Retrieves the name of the test image associated with a specific model.
Param
modelName: The name of the model.
buffer: A buffer to store the string.
bufferSize: The size of the buffer.
return int: A status code indicating the success or failure of the operation.
int nn_model_plugin_info_get_test_image_roi(const char* modelName, int* x, int* y, int* width, int* height)
brief: Retrieves the region of interest (ROI) of the test image for a specific model.
Param
modelName: The name of the model.
x: A pointer to store the x-coordinate of the ROI.
y: A pointer to store the y-coordinate of the ROI.
width: A pointer to store the width of the ROI.
height: A pointer to store the height of the ROI.
return int: A status code indicating the success or failure of the operation.