Skip to content

File api.h

File List > api.h

Go to the documentation of this file

#pragma once

#ifdef DLL_EXPORT
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif

#include <string>

#include "utils.h"
#include "type.h"
#include "config.h"
#include "model.h"
#include "model_result.h"

using namespace inspection;


// for model setting
extern "C" DLL_API inspection::DomainConfig GetDomainConfig(inspection::CellType cellType, string configPath = string(""));

extern "C" DLL_API inspection::ModelConfig CreateModelConfig(string device, string weightPath, inspection::CellType cellType, string configPath = string(""), inspection::TaskType task = inspection::TaskType::SEMENTIC_SEGMENTATION);

// for inference
extern "C" DLL_API inspection::Model * CreateModel(const inspection::ModelConfig & mc);

extern "C" DLL_API inspection::ModelResult RunModel(inspection::Model * obj, Mat image);

extern "C" DLL_API inspection::ModelResult RunModelWithUCHAR(inspection::Model * obj, unsigned char* image, int rows, int cols, int channel);

extern "C" DLL_API void DeleteModel(inspection::Model * model);

extern "C" DLL_API int GetNumOfClasses(inspection::ModelResult & mr);

// for mask
extern "C" DLL_API Mat GetMaskByClassID(inspection::ModelResult & mr, int classID);

extern "C" DLL_API unsigned char* GetMaskByClassIDWithUCHAR(inspection::ModelResult & mr, int classID);

extern "C" DLL_API vector<Mat> GetMaskForAllClasses(inspection::ModelResult & mr);

extern "C" DLL_API Mat GetOneMaskForAllClasses(inspection::ModelResult & mr);

extern "C" DLL_API unsigned char* GetOneMaskForAllClassesWithUCHAR(inspection::ModelResult & mr);

// for skeleton
extern "C" DLL_API vector<vector<Point>> GetSkeletonByClassID(inspection::ModelResult & mr, int classID);

// for end point
extern "C" DLL_API vector<Point> GetEndPointByClassID(inspection::ModelResult & modelResult, int classID);

extern "C" DLL_API vector<vector<Point>> GetEndPointForAllClasses(inspection::ModelResult & mr);

// for visualize
extern "C" DLL_API Mat GetMaskVisualizationByClassID(inspection::ModelResult & mr, int classID);

extern "C" DLL_API unsigned char* GetMaskVisualizationByClassIDWithUCHAR(inspection::ModelResult & mr, int classID);

extern "C" DLL_API Mat GetMaskVisualizationForAllClasses(inspection::ModelResult & mr);

extern "C" DLL_API unsigned char* GetMaskVisualizationForAllClassesWithUCHAR(inspection::ModelResult & mr);

extern "C" DLL_API Mat GetSkeletonVisualizationByClassID(inspection::ModelResult & mr, int classID);

extern "C" DLL_API unsigned char* GetSkeletonVisualizationByClassIDWithUCHAR(inspection::ModelResult & mr, int classID);

extern "C" DLL_API Mat GetSkeletonVisualizationForAllClasses(inspection::ModelResult & mr);

extern "C" DLL_API unsigned char* GetSkeletonVisualizationForAllClassesWithUCHAR(inspection::ModelResult & mr);

extern "C" DLL_API Mat GetEndPointVisualizationByClassID(inspection::ModelResult & mr, int classID);

extern "C" DLL_API unsigned char* GetEndPointVisualizationByClassIDWithUCHAR(inspection::ModelResult & mr, int classID);

extern "C" DLL_API Mat GetEndPointVisualizationForAllClasses(inspection::ModelResult & mr);


extern "C" DLL_API unsigned char* GetEndPointVisualizationForAllClassesWithUCHAR(inspection::ModelResult & mr);


// for file
extern "C" DLL_API void SaveSkeletons(inspection::ModelResult & mr, string savePath);


extern "C" DLL_API void SaveEndPoints(inspection::ModelResult & modelResult, string savePath);


extern "C" DLL_API void SaveResultImage(Mat & image, string savePath);

extern "C" DLL_API void SaveResultImageWithUCHAR(unsigned char* image, int rows, int cols, int channels, string savePath);

// for format (in utils.h)
extern "C" DLL_API unsigned char* ConvertMatToUCHAR(Mat image);
extern "C" DLL_API Mat ConvertUCHARToMat(unsigned char* image, int rows, int cols, int channels);
extern "C" DLL_API nlohmann::json LoadJson(std::string filePath);
extern "C" DLL_API Scalar GetRandomColor();