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; }