From a5f477647fbdc998519f9f9a63ba4c389137201e Mon Sep 17 00:00:00 2001 From: asxalex Date: Thu, 25 Sep 2025 16:15:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=8F=8D=E5=90=91=E7=9A=84?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=EF=BC=8C=E9=A6=96=E5=85=88=EF=BC=8C=E5=86=8D?= =?UTF-8?q?model.txt=E9=87=8C=E9=9D=A2=E7=B1=BB=E5=88=AB=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=B8=BA!mouse=E7=AD=89=EF=BC=88=E5=9C=A8=E7=B1=BB=E5=88=AB?= =?UTF-8?q?=E5=89=8D=E9=9D=A2=E5=8A=A0=E4=B8=80=E4=B8=AA=E8=8B=B1=E6=96=87?= =?UTF-8?q?=E7=9A=84=E6=84=9F=E5=8F=B9=E5=8F=B7=EF=BC=8C=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E9=9D=9E=EF=BC=89=EF=BC=8C=E7=84=B6=E5=90=8Eyolov5=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E4=B8=8A=E6=8A=A5=EF=BC=8C=E6=95=B0=E5=AD=97=EF=BC=88?= =?UTF-8?q?=E6=AF=94=E5=A6=82=EF=BC=8C=E7=8E=B0=E5=9C=A8=E4=B8=8A=E6=8A=A5?= =?UTF-8?q?=E7=9A=84=E6=98=AF0=E4=B8=AA=EF=BC=89=EF=BC=8Crk1808-tool?= =?UTF-8?q?=E5=9C=A8=E6=94=B6=E5=88=B0=E6=B6=88=E6=81=AF=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E4=BC=9A=E6=9F=A5=E7=9C=8B=E5=89=8D=E9=9D=A2=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E6=9C=89=E6=84=9F=E5=8F=B9=E5=8F=B7=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E6=9C=89=EF=BC=8C=E8=A1=A8=E7=A4=BA=E5=9C=A8=E4=B8=AA?= =?UTF-8?q?=E6=95=B0=E4=B8=BA0=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C?= =?UTF-8?q?=E6=8C=81=E7=BB=AD10=E7=A7=92=E9=92=9F=EF=BC=8C=E5=B0=B1?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=EF=BC=9B=E5=90=A6=E5=88=99=EF=BC=8C=E5=B0=B1?= =?UTF-8?q?=E6=98=AF=E5=9C=A8=E4=B8=AA=E6=95=B0=E4=B8=8D=E4=B8=BA0?= =?UTF-8?q?=EF=BC=8C=E4=B8=94=E6=8C=81=E7=BB=AD10=E7=A7=92=E9=92=9F?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E4=B8=8A=E6=8A=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MppDecode.cpp | 11 +++++++++++ postprocess.cc | 8 +++++++- postprocess.h | 3 +++ rknn.cpp | 9 +++++++-- rknn.h | 5 +++++ vertix.cpp | 2 +- 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/MppDecode.cpp b/MppDecode.cpp index 5d7c059..245e30e 100755 --- a/MppDecode.cpp +++ b/MppDecode.cpp @@ -94,9 +94,20 @@ void convert_a_frame(MppFrame frame) // lock acquired, should create thread and use pose_body if (!should_do_judge_according_time()) { + if (inited_after_out_of_time_gap == 0) { + inited_after_out_of_time_gap = 1; + for (int i = 0; i < OBJ_CLASS_MAX; i++) { + pre_change_objects[i] = -1; + pre_change_frames[i] = 0; + } + } pthread_mutex_unlock(&frame_mutex); free(out); return; + } else { + if (inited_after_out_of_time_gap == 1) { + inited_after_out_of_time_gap = 0; + } } pthread_t pose_body_handler; pthread_create(&pose_body_handler, NULL, pose_body_thread, (void *)out); diff --git a/postprocess.cc b/postprocess.cc index e0c3258..fbf1773 100644 --- a/postprocess.cc +++ b/postprocess.cc @@ -33,6 +33,8 @@ int codes[OBJ_MAX_CLASS_NUM]; int OBJ_CLASS_REAL_NUM = 0; int PROP_BOX_SIZE = 0; +int inited_after_out_of_time_gap = 0; + const int anchor[3][6] = {{10, 13, 16, 30, 33, 23}, {30, 61, 62, 45, 59, 119}, {116, 90, 156, 198, 373, 326}}; @@ -610,10 +612,14 @@ int post_process(rknn_app_context_t *app_ctx, void *outputs, letterbox_t *letter int init_post_process() { - char txt_path[128]; snprintf(txt_path, 127, "%s/%s.txt", MODELDIR, global_model); + for (int i = 0; i < OBJ_CLASS_MAX; i++) { + pre_change_objects[i] = -1; + pre_change_frames[i] = 0; + } + int ret = 0; ret = loadLabelName(txt_path, labels); if (ret < 0) diff --git a/postprocess.h b/postprocess.h index 1ecc139..5591dfc 100644 --- a/postprocess.h +++ b/postprocess.h @@ -14,6 +14,9 @@ extern int OBJ_CLASS_REAL_NUM; extern int PROP_BOX_SIZE; +// 当刚从time_gap离开,需要重置一下帧数等信息,从而再下次进入区间,表现正常 +extern int inited_after_out_of_time_gap; + extern char *labels[OBJ_MAX_CLASS_NUM]; extern int codes[OBJ_MAX_CLASS_NUM]; diff --git a/rknn.cpp b/rknn.cpp index 88d14c6..ec0aa6a 100644 --- a/rknn.cpp +++ b/rknn.cpp @@ -20,9 +20,9 @@ void *upload_info(void *arg); // #define LABEL_NALE_TXT_PATH "./model/coco_80_labels_list.txt" -static int pre_change_frames[OBJ_CLASS_MAX] = {0}; +int pre_change_frames[OBJ_CLASS_MAX]; // static int last_objects[OBJ_NUMB_MAX_SIZE] = {0}; -static int pre_change_objects[OBJ_CLASS_MAX] = {0}; +int pre_change_objects[OBJ_CLASS_MAX]; static int size_of_last_objects = 0; static int size_of_pre_changed = 0; @@ -32,6 +32,7 @@ int UploadPort = 0; static char is_uploading = 0; + pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; // rknn_t *rk = NULL; char *global_model = NULL; @@ -110,6 +111,10 @@ int print_object_detect_result(rknn_app_context_t *rknn, object_detect_result_li int current_objects[OBJ_CLASS_MAX] = {0}; char need_upload = 0; + for (int i = 0; i < OBJ_CLASS_REAL_NUM; i++) { + need_upload_info[i] = -1; + current_objects[i] = 0; + } for (int i = 0; i < group->count; i++) { diff --git a/rknn.h b/rknn.h index e37a2f9..46885b4 100644 --- a/rknn.h +++ b/rknn.h @@ -15,6 +15,11 @@ extern char *CameraID; extern int TypeID; extern int UploadPort; + +extern int pre_change_frames[OBJ_CLASS_MAX]; +// static int last_objects[OBJ_NUMB_MAX_SIZE] = {0}; +extern int pre_change_objects[OBJ_CLASS_MAX]; + /* typedef struct _BOX_RECT { diff --git a/vertix.cpp b/vertix.cpp index e3ea332..919b1f9 100644 --- a/vertix.cpp +++ b/vertix.cpp @@ -225,7 +225,7 @@ time_period_t* get_time_period_from_string(char *str) { } printf("rest = \"%s\"", rest); if (strlen(rest) == 0) { - token = "23:59:59"; + token = (char*)"23:59:59"; } else { token = rest; }