You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
4.7 KiB
156 lines
4.7 KiB
#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 + 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<bool(AIPVFrameHeader* imgHeader, uint8_t* imgData/*, void* userData*/)>;
|
|
typedef bool(*fcbBeforeUpload)(AIPVFrameHeader* imgHeader, uint8_t* imgData);
|
|
|
|
//using fcbAIPVResult = std::function<void(AIPVResult* result, AIPVStitchResultHeader* stitchresult, uint8_t* mStitchImgData)>;
|
|
typedef void(*fcbAIPVResult )(AIPVResult* result, AIPVStitchResultHeader* stitchresult, uint8_t* mStitchImgData);
|
|
//using fcbAIPVResult = std::function<void(AIPVResult* result, AIPVStitchResultHeader* stitchresult)>;
|
|
}
|
|
|
|
|
|
|