王厅
7 months ago
commit
b1c01dca6c
6 changed files with 162 additions and 0 deletions
Binary file not shown.
Binary file not shown.
@ -0,0 +1,30 @@ |
|||
#pragma once |
|||
#include "AIPVProtocol.h" |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
bool KVS_API AIPV_Init(); |
|||
bool KVS_API AIPV_Clear(); |
|||
AIPV::AIPVErrorCode KVS_API AIPV_GetLastError(); |
|||
|
|||
bool KVS_API AIPV_IsConnected(uint32_t handle); |
|||
|
|||
uint32_t KVS_API AIPV_Connect(const char* serverIP); |
|||
bool KVS_API AIPV_Stop(uint32_t handle); |
|||
|
|||
bool KVS_API AIPV_UploadImage(uint32_t handle, AIPV::AIPVFrameHeader* imgHeader, uint8_t* imgData); |
|||
bool KVS_API AIPV_MonitorDir(uint32_t handle, const wchar_t* dirPath, AIPV::fcbBeforeUpload callback, void* userData); |
|||
bool KVS_API AIPV_SubscribeAIResult(uint32_t handle, bool enable, AIPV::fcbAIPVResult callback, void* userData); |
|||
|
|||
// module settings
|
|||
bool KVS_API AIPV_SetModuleOperationTimeout(uint32_t handle, uint32_t milliseconds); |
|||
uint32_t KVS_API AIPV_LoadAIModule(uint32_t handle, const wchar_t* modulePath); |
|||
bool KVS_API AIPV_SetAIModuleParam(uint32_t handle, uint32_t moduleID, const char* jsonSettings, uint32_t jsonLen); |
|||
bool KVS_API AIPV_GetAIModuleParam(uint32_t handle, uint32_t moduleID, char* jsonSettings, uint32_t& jsonLen); |
|||
|
|||
// debug interface
|
|||
bool KVS_API AIPV_SimulateDir(uint32_t handle, const wchar_t* dirPath, uint32_t milliseconds, AIPV::fcbBeforeUpload callback, void* userData); |
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
@ -0,0 +1,132 @@ |
|||
#pragma once |
|||
#include <stdint.h> |
|||
#include <functional> |
|||
#include <list> |
|||
#include <vector> |
|||
|
|||
#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
|
|||
|
|||
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); |
|||
|
|||
// module
|
|||
struct AIPVLoadModuleReq { |
|||
char mPath[AIPVFilePathSize]; |
|||
}; |
|||
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<bool(AIPVFrameHeader* imgHeader, uint8_t* imgData, void* userData)>; |
|||
using fcbAIPVResult = std::function<void(AIPVResult* result, void* userData)>; |
|||
} |
|||
|
|||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue