123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- #pragma once
- #include <opencv2/core/core.hpp>
- 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<SegResult> &result, CutParam param) = 0;
- virtual void Evaluate(const char* imgPath, std::vector<SegResult> &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<cv::Point> 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<cv::Mat> imgList, vector<int> & rstClassList, vector<float> & 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<OCRChar> Evaluate(cv::Mat srcImg) = 0;
- //virtual std::vector<OCRChar> Evaluate(const char* imgPath) = 0;
- virtual char* Evaluate(cv::Mat srcImg, std::vector<OCRChar>& resultOcrBox) = 0;
- virtual char* Evaluate(const char* imgPath, std::vector<OCRChar>& 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<Bbox> Evaluate(cv::Mat srcImg) = 0;
- virtual std::vector<Bbox> 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);
|