#pragma once #include #include #include #include #if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) || defined(_WINDOWS_) #ifdef KVS_EXPORTS #define KVS_API __declspec(dllexport) #else #define KVS_API __declspec(dllimport) #endif #define KVS_STDCALL __stdcall #else #define KVS_STDCALL #define KVS_API #endif namespace AIPV { static const uint32_t AIPVCommMagic = 0x0053564B; static const uint32_t AIPVCommVersion = 0x01000001; // 1.0.0.1 static const uint32_t AIPVServerPort = 12680; static const uint32_t AIPVFilePathSize = 128; static const uint32_t AIPVMaxImgFilePathSize = 128; static const uint32_t AIPVDetectItemCount = 144; enum class AIPVErrorCode { Success = 0, InvalidHandle, NoMem, InvalidParam, NetIOError, FileIOError, Refuse, InvalidState, OperationTimeout, OperationFailed, }; std::string toStr(AIPVErrorCode e); enum class AIPVCommand { Unknown = 0, UploadImage = 128, // C -> S, AIPVCommandHeader + AIPVFrame SubscribeAIResult, // C -> S, AIPVCommandHeader + AIPVSubscribeReq PushAIResult, // S -> C, AIPVCommandHeader + AIPVResult + AIPVStitchResult LoadModule, // C -> S, AIPVCommandHeader + AIPVLoadModuleReq ReleaseModule, // C -> S, AIPVCommandHeader + AIPVModuleIDReq SetModuleParam, // C -> S, AIPVCommandHeader + AIPVModuleIDReq + json string GetModuleParam, // C -> S, AIPVCommandHeader + AIPVModuleIDReq ModuleOperationRet, // S -> C, AIPVCommandHeader + AIPVModuleOperationRet + json string }; std::string toStr(AIPVCommand e); #pragma pack(push) #pragma pack(1) struct AIPVCommandHeader { uint32_t mMagic; // AIPVCommMagic uint32_t mVersion; // AIPVCommVersion AIPVCommand mCommand; uint32_t mDataLen; }; static const uint32_t AIPVCommandHeaderSize = sizeof(AIPVCommandHeader); AIPVCommandHeader* fillCommandHeader(AIPVCommandHeader* header, AIPVCommand cmd, uint32_t len); // Image frame enum AIPVMarkCode { KCVA_OK = 0, KCVA_NG_DEF, }; struct AIPVRect { uint16_t mOffsetX; uint16_t mOffsetY; uint16_t mWidth; uint16_t mHeight; uint8_t mMark; // is NG uint8_t mRes[3]; }; struct AIPVFrameHeader { uint16_t mWidth; uint16_t mHeight; char mFilePath[AIPVMaxImgFilePathSize]; uint32_t mFileSize; AIPVRect mDetect[AIPVDetectItemCount]; }; static const uint32_t AIPVFrameHeaderSize = sizeof(AIPVFrameHeader); struct AIPVFrame { AIPVFrameHeader* mHeader; uint8_t* mData; }; // AI begin // result struct AIPVSubscribeReq { uint8_t mEnable; uint8_t mRes[3]; }; static const uint32_t AIPVSubscribeReqSize = sizeof(AIPVSubscribeReq); using AIPVResult = AIPVFrameHeader; static const uint32_t AIPVResultSize = sizeof(AIPVResult); struct AIPVStitchResultHeader { uint16_t mWidth; //拼接之后图像宽 uint16_t mHeight; //拼接之后图像高 char mStitchImgName[AIPVMaxImgFilePathSize]; //拼接之后图像名称 uint32_t mStitchImgSize; //拼接之后图像大小 uint16_t mIsFinish; //是否拼接完成标志,为1 代表1张图拼接完成,为0 代表图还没有拼接完成,可以不用处理 uint8_t mRes[2]; //保留 //uint8_t* mStitchImgData; //拼接图像 }; static const uint32_t AIPVStitchResultHeaderSize = sizeof(AIPVStitchResultHeader); // module enum class AIModuleType { ModuleNone = 0, ModuleTest, ModulePV, }; std::string toStr(AIModuleType e); struct AIPVLoadModuleReq { AIModuleType mType; }; static const uint32_t AIPVLoadModuleReqSize = sizeof(AIPVLoadModuleReq); struct AIPVModuleIDReq { uint32_t mModuleID; }; static const uint32_t AIPVModuleIDReqSize = sizeof(AIPVModuleIDReq); struct AIPVModuleOperationRet { // for LoadModule: return mModuleID + mErrorCode, mJsonSize = 0; // for ReleaseModule: return mErrorCode, mJsonSize = 0; // for SetModuleParam: return mErrorCode, mJsonSize = 0; // for GetModuleParam: return mErrorCode + mJsonSize; uint32_t mModuleID; AIPVCommand mOperation; AIPVErrorCode mErrorCode; uint32_t mJsonSize; // if > 0, json str appended. }; static const uint32_t AIPVModuleOperationRetSize = sizeof(AIPVModuleOperationRet); // AI end #pragma pack(pop) #pragma endregion //using fcbBeforeUpload = std::function; typedef bool(*fcbBeforeUpload)(AIPVFrameHeader* imgHeader, uint8_t* imgData); //using fcbAIPVResult = std::function; typedef void(*fcbAIPVResult )(AIPVResult* result, AIPVStitchResultHeader* stitchresult, uint8_t* mStitchImgData); //using fcbAIPVResult = std::function; }