#pragma once #include enum ClsStatus { Cls_Undifne = -1, Cls_Success, Cls_NG1, Cls_NG2, Cls_NG3 }; enum SegStatus { Seg_Undifne = -1, Seg_Success, Seg_NG1, Seg_NG2, Seg_NG3 }; enum OCRStatus { OCR_Undifne = -1, OCR_Success, OCR_NG1, OCR_NG2, OCR_NG3 }; enum DetStatus { Det_Undifne = -1, Det_Success, Det_NG1, Det_NG2, Det_NG3 }; typedef struct { float x; float y; float w; float h; float score; int classes; }Bbox; typedef struct { float x; float y; float w; float h; float score; cv::String rstChar; }OCRChar; typedef struct { int x; int y; int w; int h; int classes; cv::Mat resultMask; }SegResult; enum CutType { RegularRect = 0, SlantRect = 1, Contour = 2, Default = 3 }; //cutType: Default:按照中心点与固定大小切,其他按照轮廓边缘切 //DstW:目标图片宽 //DstH:目标图片高 //fillorresize: cutType为Default时:指示超出原图区域时是否填充像素,false为不填充,自动移入原图区域内; cutType为其他时:True直接resize到目标大小,False保持宽高比填充 //Color:若填充,则使用给定像素值进行填充,若不填充则无效 typedef struct { CutType cutType; int DstW; int DstH; bool fillorresize; int color; }CutParam; using namespace std; class pSegmentation { public: virtual void Release() = 0; virtual cv::Mat Evaluate(cv::Mat srcImg) = 0; virtual cv::Mat Evaluate(const char* imgPath) = 0; virtual void Evaluate(cv::Mat srcImg, std::vector &result, CutParam param) = 0; virtual void Evaluate(const char* imgPath, std::vector &result, CutParam param) = 0; virtual SegStatus getStatus() = 0; virtual void setStride(float stride) = 0; const int patchSizeNet = 0; const int batchSizeNet = 0; const int maxbatchSizeNet = 0; const float strideNet = 0.9; const int m_classes = 0; const int m_gpuID = 0; }; extern "C" __declspec(dllexport) pSegmentation* _stdcall CreateSegObj(char* modelPath, int batchSize = 256, float stride = 0.9, int patchSize = 256, int deviceId = 0, int classes = 2); extern "C" __declspec(dllexport) pSegmentation* _stdcall CreateSegObjS(char* modelPath, int batchSize = 256, int deviceId = 0); extern "C" __declspec(dllexport) pSegmentation* _stdcall CreateSegObjF(char* modelPath, char* calib,int batchSize = 256, int deviceId = 0); extern "C" __declspec(dllexport) void _stdcall DestroySegObj(pSegmentation* pExport); extern "C" __declspec(dllexport) int _stdcall GetMaxBatchsize(int gpuId, int width,int height); extern "C" __declspec(dllexport) char* _stdcall GetCurrentVersion(); //extern "C" __declspec(dllexport) cv::Mat _stdcall CutImage(cv::Mat src, int CenterX, int CenterY, int &DstW, int &DstH, bool Fill = false, int Color = 0); //extern "C" __declspec(dllexport) cv::Mat _stdcall CutImageByContour(cv::Mat src, int DstW, int DstH, vector ContourPt, CutType CutType = CutType::RegularRect, bool Resize = false, int color = 0); extern "C" __declspec(dllexport) bool IDecode(const char* orifolder, const char* rstfolder); class pClassification { public: virtual int Evaluate(cv::Mat srcImg) = 0; //virtual int EvaluateTest(cv::Mat srcImg) = 0; virtual int Evaluate(const char* imgPath) = 0; virtual int Evaluate(vector imgList, vector & rstClassList, vector & rstProbList) = 0; virtual float getProbability() = 0; virtual float* getProbabilityList () = 0; virtual ClsStatus getStatus() = 0; virtual void Release() = 0; const int m_imageWidth = 0; const int m_imageHeight = 0; const int m_classNum = 0; const int m_inGpuID = 0; }; extern "C" __declspec(dllexport) pClassification* _stdcall CreateClsObj(char* inputModelPath, char* inputJsonPath, int in_gpuID, int in_width, int in_height, int classNum, int batchsize=1); extern "C" __declspec(dllexport) pClassification* _stdcall CreateClsObjS(char* inputModelPath, char* inputJsonPath, int in_gpuID, int batchsize = 1); extern "C" __declspec(dllexport) pClassification* _stdcall CreateClsObjV3(char* inputModelPath, int in_gpuID, int batchsize); extern "C" __declspec(dllexport) pClassification* _stdcall CreateClsObjF(char* inputModelPath, char* calib, int in_gpuID, int batchsize); extern "C" __declspec(dllexport) void _stdcall DestroyClsObj(pClassification* pExport); class pOCREvaluator { public: //virtual std::vector Evaluate(cv::Mat srcImg) = 0; //virtual std::vector Evaluate(const char* imgPath) = 0; virtual char* Evaluate(cv::Mat srcImg, std::vector& resultOcrBox) = 0; virtual char* Evaluate(const char* imgPath, std::vector& resultOcrBox)=0; virtual OCRStatus getStatus() = 0; virtual void Release() = 0; const int m_imageWidth = 0; const int m_imageHeight = 0; const int m_classNum = 0; const int m_inGpuID = 0; }; //extern "C" __declspec(dllexport) pOCREvaluator* _stdcall CreateOCRObj(char* inputModelPath, char* inputJsonPath, int in_gpuID, int in_width, int in_height, int classNum); //extern "C" __declspec(dllexport) pOCREvaluator* _stdcall CreateOCRObjS(char* inputModelPath, char* inputJsonPath, int in_gpuID); extern "C" __declspec(dllexport) pOCREvaluator* _stdcall CreateOCRObjV3(char* inputModelPath, int in_gpuID); extern "C" __declspec(dllexport) pOCREvaluator* _stdcall CreateOCRObjF(char* inputModelPath,char* calib, int in_gpuID); extern "C" __declspec(dllexport) void _stdcall DestroyOCRObj(pOCREvaluator* pExport); class pDetection { public: virtual std::vector Evaluate(cv::Mat srcImg) = 0; virtual std::vector Evaluate(const char* imgPath) = 0; virtual DetStatus getStatus() = 0; virtual void setStride(float stride) = 0; virtual void setScore(float score) = 0; virtual void setNms(float nms) = 0; virtual void Release() = 0; const int m_gpuID = 0; const int batchSizeNet = 0; const float m_score = 0; const float m_nms = 0; const int patchSizeNet = 0; const float strideNet = 0; }; extern "C" __declspec(dllexport) pDetection* _stdcall CreateDetObj(char* modelPath, int batchSize = 32, float stride = 0.9, float score = 0.5, float nms = 0.5, int deviceId = 0); extern "C" __declspec(dllexport) pDetection* _stdcall CreateDetObjS(char* modelPath, int batchSize = 32, int deviceId = 0); extern "C" __declspec(dllexport) void _stdcall DestroyDetObj(pDetection* pExport);