#ifndef _smartai_shm_struct_parser_h #define _smartai_shm_struct_parser_h #include #include "std_target.h" // struct image struct stimg{ uint64_t id; unsigned char* data; uint64_t data_size; uint32_t width; uint32_t height; char* timestamp; uint32_t timestamp_size; char* camera_id; uint32_t camera_id_size; char* camera_name; uint32_t camera_name_size; }; ////////////////////////////////////////////// // sdk result // struct rect struct strc{ int32_t left; int32_t top; int32_t right; int32_t bottom; }; // struct target from analysis struct sttgt{ uint64_t id; char* type; uint32_t type_size; int32_t confidence; struct strc rect; unsigned char* feature; uint32_t feature_size; unsigned char* attribute; uint32_t attribute_size; }; // struct sdk analysis run struct stsdk{ char* sdktype; uint32_t sdktype_size; char* sdkid; uint32_t sdkid_size; char* sdkname; uint32_t sdkname_size; char* timestamp; uint32_t timestamp_size; uint32_t tgt_count; // targets [struct sttgt] struct sttgt* tgt; }; // struct rule message for rule server struct strule{ char* handletrack; uint32_t handletrack_size; char* datatype; uint32_t datatype_size; uint32_t sdk_count; // struct stsdk struct stsdk* sdk; }; #ifdef __cplusplus extern "C"{ #endif /* 以下api提供将image放入shm和从shm取出的功能 make_image_ref 将 image 信息组装成 stimg 结构,不发生内存拷贝,参数生命周期由外部管理保证 image2shm 将 stimg 放入共享内存 shm 中,由外部保证 shm 足够大 也可以不使用 make_image_ref 自己组装 struct stimg shm2image 将共享内存 shm 的内容组装成 stimg 结构,不产生内存拷贝,仅移动指针 返回一个 struct stimg 结构的指针,需要调用 free_stimg 释放 free_stimg 释放 shm2image 返回的指针 */ struct stimg* make_image_ref(const uint64_t id, const unsigned char* data, const uint32_t size, const uint32_t width, const uint32_t height, const char* timestamp, const uint32_t ts_size, const char* camera_id, const uint32_t cid_size, const char* camera_name,const uint32_t cname_size); void image2shm(void* shm, struct stimg* img); struct stimg* shm2image(void* shm); void free_stimg(struct stimg* img); /* rule2shm 在 decoder 中调用,初始化一个 rulemsg 给后续 analysis 使用 add_result2rule_in_shm 将 tresult 加入到 shm 中保存的 rule 中使用的结构体中 shm2rule 获取 shm 中保存的 rule 结构体,不产生内存拷贝 返回一个 struct strule 结构的指针,需要调用 free_strule 释放 free_strule 释放 shm2rule 返回的指针 */ void rule2shm(void* shm, const char* handletrack, const uint32_t ht_size); void add_result2rule_in_shm(void* shm, const TResult* res, const char* sdktype, const uint32_t st_size, const char* timestamp, const uint32_t ts_size); struct strule* shm2rule(void* shm); void free_strule(struct strule* rule); /////////////////////////////////////////////////////////////// // go need function // go image void goImage2Shm(void* shm, void* img); void goImageGet(void* img, void** data, uint64_t* size, void** ts, uint32_t* tss, void** cid, uint32_t* cids, void** cname, uint32_t* cnames, uint64_t* id, uint32_t* w, uint32_t* h); // go rule/sdk/result void goTargetsDel(void* tgts); void* goTargetsNew(const uint32_t size); void goTargetAdd(void* tgts, int idx, uint64_t id, char* type, uint32_t tsize, int32_t confidence, int left, int top, int right, int bottom, unsigned char* feat, uint32_t featsize, unsigned char* attr, uint32_t attrsize); void goSdkPut(void* shm, void* tgts, uint32_t tgtcnt, char* type, uint32_t tsize, char* timestamp, uint32_t tmsize); // unserialize void goHandletrackGet(void* rule, void** data, uint32_t* size); void goDatatypeGet(void* rule, void** data, uint32_t* size); void goSdkArrayGet(void* rule, void** data, uint32_t* size); void goSdkGet(void* sdk, int idx, void** t, uint32_t* ts, void** i, uint32_t* is, void** n, uint32_t* ns, void** tm, uint32_t* tms, void** data, uint32_t* size); void goTargetGet(void* tgt, int idx, uint64_t* id, int32_t* c, int32_t* l,int32_t* t,int32_t* r,int32_t* b, void** tp, uint32_t* tps, void** feat, uint32_t* fs, void** attr, uint32_t* attrs); #ifdef __cplusplus } #endif #endif