From 9b21b25d1e891e2cda1d5b7ef6beb09fc308f6c5 Mon Sep 17 00:00:00 2001
From: cheliequan <liequanche@126.com>
Date: 星期二, 07 二月 2023 17:50:19 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/valib/c_shm
---
shmparser/shmparser.c | 67 ++++++++++++++++++---------------
1 files changed, 37 insertions(+), 30 deletions(-)
diff --git a/shmparser/shmparser.c b/shmparser/shmparser.c
index 1ad70dc..528744d 100644
--- a/shmparser/shmparser.c
+++ b/shmparser/shmparser.c
@@ -113,26 +113,25 @@
ptr[7] = (uint8_t) (u);
}
-struct stimg make_image_ref(const uint64_t id, const unsigned char* data, const uint32_t size,
+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)
{
- struct stimg img;
- memset(&img, 0, sizeof(img));
+ struct stimg* img = (struct stimg*)calloc(1, sizeof(struct stimg));
- img.data = (unsigned char*)data;
- img.data_size = size;
- img.width = width;
- img.height = height;
- img.id = id;
- img.timestamp = (char*)timestamp;
- img.timestamp_size = ts_size;
- img.camera_id = (char*)camera_id;
- img.camera_id_size = cid_size;
- img.camera_name = (char*)camera_name;
- img.camera_name_size = cname_size;
+ img->data = (unsigned char*)data;
+ img->data_size = size;
+ img->width = width;
+ img->height = height;
+ img->id = id;
+ img->timestamp = (char*)timestamp;
+ img->timestamp_size = ts_size;
+ img->camera_id = (char*)camera_id;
+ img->camera_id_size = cid_size;
+ img->camera_name = (char*)camera_name;
+ img->camera_name_size = cname_size;
return img;
}
@@ -475,8 +474,10 @@
// targets count
tmp = put_number(tmp, RULE_SDK_TGT_COUNT, res->count);
cursize += tmp - old;
+
// targets
- tmp = put_targets(tmp, res, &cursize);
+ if (res->count > 0)
+ tmp = put_targets(tmp, res, &cursize);
// 鏈�鍚庝慨鏀� psdksize 鍐呭
Put64(pheader, cursize);
@@ -530,8 +531,10 @@
tmp = get_string(tmp, &cmd, &sdk.timestamp, &sdk.timestamp_size);
tmp = get_number(tmp, &cmd, &sdk.tgt_count);
- sdk.tgt = (struct sttgt*)calloc(sdk.tgt_count, sizeof(struct sttgt));
- tmp = get_targets(tmp, sdk.tgt, sdk.tgt_count);
+ if (sdk.tgt_count > 0){
+ sdk.tgt = (struct sttgt*)calloc(sdk.tgt_count, sizeof(struct sttgt));
+ tmp = get_targets(tmp, sdk.tgt, sdk.tgt_count);
+ }
sdkarray[i] = sdk;
}
@@ -551,12 +554,12 @@
///////////////////////////////////////////////////////////////
// go need function
-void goimage2shm(void* shm, void* img){
+void goImage2Shm(void* shm, void* img){
struct stimg* cimg = (struct stimg*)img;
image2shm(shm, cimg);
}
-void goimageinfo(void* img, void** data, uint64_t* size,
+void goImageGet(void* img, void** data, uint64_t* size,
void** ts, uint32_t* tss,
void** cid, uint32_t* cids,
void** cname, uint32_t* cnames,
@@ -580,19 +583,19 @@
*h = cimg->height;
}
-void gotargetsdel(void* tgts){
+void goTargetsDel(void* tgts){
if (tgts) {
struct sttgt* t = (struct sttgt*)tgts;
free(t);
}
}
-void* gotargetsnew(const uint32_t size){
+void* goTargetsNew(const uint32_t size){
struct sttgt* t = (struct sttgt*)calloc(size, sizeof(struct sttgt));
return t;
}
-void gotargetsadd(void* tgts, int idx, uint64_t id, char* type, uint32_t tsize, int32_t confidence,
+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)
@@ -617,7 +620,7 @@
ts[idx] = t;
}
-void goruleaddsdk(void* shm, void* tgts, uint32_t tgtcnt,
+void goSdkPut(void* shm, void* tgts, uint32_t tgtcnt,
char* type, uint32_t tsize,
char* timestamp, uint32_t tmsize)
{
@@ -649,29 +652,31 @@
//////////////////// unserialize
-void gorulehandletrack(void* rule, void** data, uint32_t* size){
+void goHandletrackGet(void* rule, void** data, uint32_t* size){
struct strule* r = (struct strule*)rule;
*data = r->handletrack;
*size = r->handletrack_size;
}
-void goruledatatype(void* rule, void** data, uint32_t* size){
+void goDatatypeGet(void* rule, void** data, uint32_t* size){
struct strule* r = (struct strule*)rule;
*data = r->datatype;
*size = r->datatype_size;
}
-void gorulesdk(void* rule, void** data, uint32_t* size){
+void goSdkArrayGet(void* rule, void** data, uint32_t* size){
struct strule* r = (struct strule*)rule;
*data = r->sdk;
*size = r->sdk_count;
}
-void gorulesdkinfo(void* sdk, int idx, void** t, uint32_t* ts,
+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)
{
- struct stsdk* s = (struct stsdk*)sdk;
+ struct stsdk* ss = (struct stsdk*)sdk;
+ struct stsdk* s = &ss[idx];
+
*t = s->sdktype;
*ts = s->sdktype_size;
@@ -687,12 +692,14 @@
*size = s->tgt_count;
}
-void gorulesdktargetinfo(void* tgt, int idx, uint64_t* id, int32_t* c,
+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)
{
- struct sttgt* tt = (struct sttgt*)tgt;
+ struct sttgt* ta = (struct sttgt*)tgt;
+ struct sttgt* tt = &ta[idx];
+
*id = tt->id;
*c = tt->confidence;
*l = tt->rect.left;
--
Gitblit v1.8.0