Browse Source

2.0.7.71

master
ming.hong 1 year ago
parent
commit
9a6cfb7343
  1. BIN
      gynet
  2. BIN
      libdarknet.a
  3. BIN
      obj/block_to_send.o
  4. BIN
      obj/detector.o
  5. BIN
      obj/fflpr_plate_db.o
  6. BIN
      obj/nweb.o
  7. BIN
      obj/parser.o
  8. BIN
      obj/pns.o
  9. BIN
      obj/test_nnctrl_live.o
  10. BIN
      obj/websocket.o
  11. 611
      src/detector.c
  12. 43
      src/nweb.c
  13. 86
      src/pythonR.c
  14. 4
      src/setting.h
  15. 27
      src/test_nnctrl_live.c
  16. 2
      src/utility.h

BIN
gynet

Binary file not shown.

BIN
libdarknet.a

Binary file not shown.

BIN
obj/block_to_send.o

Binary file not shown.

BIN
obj/detector.o

Binary file not shown.

BIN
obj/fflpr_plate_db.o

Binary file not shown.

BIN
obj/nweb.o

Binary file not shown.

BIN
obj/parser.o

Binary file not shown.

BIN
obj/pns.o

Binary file not shown.

BIN
obj/test_nnctrl_live.o

Binary file not shown.

BIN
obj/websocket.o

Binary file not shown.

611
src/detector.c

@ -900,8 +900,8 @@ void set_counter_zone() {
}
int g_last_hour_for_counter_mail = -1;
void run_counter_mail(char * mail_content,int mail_content_size) {
if (strcmp(SystemSetting.send_counter_at_specific_hour, "NULL") != 0 && strlen(SystemSetting.send_counter_at_specific_hour) >= 1)
void run_counter_mail(char * mail_content,int mail_content_size, char* image_buff_base64, int image_buff_size_base64) {
if (strcmp(SystemSetting.send_counter_at_specific_hour, "NULL") != 0 && strlen(SystemSetting.send_counter_at_specific_hour) >= 1 && mail_content_size >= 1)
{
time_t now_time = g_osdSysTimeStamp;
if (now_time < 1000000000) {
@ -918,10 +918,18 @@ void run_counter_mail(char * mail_content,int mail_content_size) {
if ((QueueSize(_POST_NOTIFICATION) < MAX_QUEUE_SIZE && QueueSize(_POST_NOTIFICATION) >= 0))
{
QueueInfo q_info = { 0 };
q_info.image_buff_size = 0;
if (image_buff_size_base64 >= 1) {
memcpy(q_info.image_buff, image_buff_base64, image_buff_size_base64);
q_info.image_buff_size = image_buff_size_base64;
}
else {
q_info.image_buff_size = 0;
}
memcpy(q_info.content, mail_content, mail_content_size);
q_info.content[mail_content_size] = '\0';
//printf("\n------q_info.content:%s\n", q_info.content);
strcpy(q_info.post_url, "post_to_mail");
@ -9830,6 +9838,14 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|name|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
if (detection_zone_idx >= 0 && trigger_idx >= 0 && pNext != NULL) {
@ -9854,6 +9870,14 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|confidence|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
@ -9884,7 +9908,15 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
replacement = NULL;
}
replacement = replacement_t;
}
}
else {
replacement_t = StrReplace(replacement, "<|left_x|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
if (detection_zone_idx >= 0 && trigger_idx >= 0 && pNext != NULL) {
@ -9915,6 +9947,14 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|top_y|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
if (detection_zone_idx >= 0 && trigger_idx >= 0 && pNext != NULL) {
@ -9944,7 +9984,15 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
replacement = NULL;
}
replacement = replacement_t;
}
}
else {
replacement_t = StrReplace(replacement, "<|width|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
if (detection_zone_idx >= 0 && trigger_idx >= 0 && pNext != NULL) {
@ -9975,6 +10023,14 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|height|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
if (detection_zone_idx >= 0 && trigger_idx >= 0 && pNext != NULL) {
@ -9999,6 +10055,14 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|center_x|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
if (detection_zone_idx >= 0 && trigger_idx >= 0 && pNext != NULL) {
@ -10023,6 +10087,14 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|center_y|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
char msg_center_speed[35] = { 0 };
@ -10060,6 +10132,14 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|center_speed|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
if (detection_zone_idx >= 0 && trigger_idx >= 0 && pNext != NULL) {
@ -10090,6 +10170,14 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|center_direction|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
if (detection_zone_idx >= 0 && trigger_idx >= 0 && pNext != NULL) {
@ -10120,6 +10208,14 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|center_stability|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
if (detection_zone_idx >= 0 && trigger_idx >= 0 && pNext != NULL) {
@ -10144,6 +10240,14 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|obj_tracking_id|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
if (detection_zone_idx >= 0 && trigger_idx >= 0 && pNext != NULL) {
@ -10168,6 +10272,14 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|obj_dwell_time|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
if (detection_zone_idx >= 0 && trigger_idx >= 0 && pNext != NULL) {
@ -10192,6 +10304,14 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|class_id|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
#ifdef GY_OS_AMBA
@ -10250,7 +10370,15 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
replacement = NULL;
}
replacement = replacement_t;
}
}
else {
replacement_t = StrReplace(replacement, "<|color|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
@ -10270,6 +10398,15 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
if (strcmp(SystemSetting.enable_display_OSD, "Yes") == 0 /*&& strcmp(SystemSetting.enable_cloud, "Yes") == 0*/) {
replacement_t = StrReplace(replacement, "<|plate|>", g_last_token_plate);
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|plate|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
@ -10292,6 +10429,15 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
if (strcmp(SystemSetting.enable_display_OSD, "Yes") == 0 /*&& strcmp(SystemSetting.enable_cloud, "Yes") == 0*/) {
replacement_t = StrReplace(replacement, "<|country|>", g_last_token_country);
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|country|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
@ -10314,6 +10460,15 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
if (strcmp(SystemSetting.enable_display_OSD, "Yes") == 0 /*&& strcmp(SystemSetting.enable_cloud, "Yes") == 0*/) {
replacement_t = StrReplace(replacement, "<|area|>", g_last_token_area);
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|area|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
@ -10336,6 +10491,15 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
if (strcmp(SystemSetting.enable_display_OSD, "Yes") == 0 /*&& strcmp(SystemSetting.enable_cloud, "Yes") == 0*/) {
replacement_t = StrReplace(replacement, "<|plate_list|>", g_last_token_plate_list);
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|plate_list|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
@ -10358,6 +10522,15 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
if (strcmp(SystemSetting.enable_display_OSD, "Yes") == 0 /*&& strcmp(SystemSetting.enable_cloud, "Yes") == 0*/) {
replacement_t = StrReplace(replacement, "<|logo|>", g_last_token_logo);
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|logo|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
@ -10408,6 +10581,15 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
if (strcmp(SystemSetting.enable_display_OSD, "Yes") == 0 /*&& strcmp(SystemSetting.enable_cloud, "Yes") == 0*/) {
replacement_t = StrReplace(replacement, "<|behavior_id|>", g_last_token_behavior_id);
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|behavior_id|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
@ -10431,6 +10613,15 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
if (strcmp(SystemSetting.enable_display_OSD, "Yes") == 0 /*&& strcmp(SystemSetting.enable_cloud, "Yes") == 0*/) {
replacement_t = StrReplace(replacement, "<|zone_id|>", g_last_token_zone_id);
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|zone_id|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
@ -10526,7 +10717,16 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
replacement = NULL;
}
replacement = replacement_t;
}
}
else {
replacement_t = StrReplace(replacement, "<|behavior_name|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
if (detection_zone_idx >= 0 && trigger_idx >= 0 && pNext != NULL && pNext->obj_tracking_id_idx >= 0) {
@ -10543,6 +10743,15 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
if (strcmp(SystemSetting.enable_display_OSD, "Yes") == 0 /*&& strcmp(SystemSetting.enable_cloud, "Yes") == 0*/) {
replacement_t = StrReplace(replacement, "<|linked_plate|>", g_last_token_linked_plate);
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|linked_plate|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
@ -10641,7 +10850,38 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
replacement = replacement_t;
#ifdef GY_OS_V_SERIES
for (int index_counter = 0; index_counter < MAX_EVENT_COUNTERS; index_counter++)
{
char temp_label[30] = { 0 };
sprintf(temp_label, "<|counter%02d_count|>", index_counter + 1);
replacement_t = StrReplace(replacement, temp_label, "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
char temp_label_dwell[30] = { 0 };
sprintf(temp_label_dwell, "<|counter%02d_dwell|>", index_counter + 1);
replacement_t = StrReplace(replacement, temp_label_dwell, "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
char temp_label_dwell_unit[50] = { 0 };
sprintf(temp_label_dwell_unit, "<|counter%02d_dwell_unit|>", index_counter + 1);
replacement_t = StrReplace(replacement, temp_label_dwell_unit, "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
#else
for (int index_counter = 0; index_counter < MAX_EVENT_COUNTERS; index_counter++)
{
@ -10873,6 +11113,92 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|space_id|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|space_zone|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|space_status|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|space_time_t|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|space_YYYY|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|space_MM|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|space_DD|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|space_GMThh|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|space_hh|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|space_mm|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|space_ss|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|difftime|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
if (enable_base64_image == 1) {
@ -10911,8 +11237,68 @@ size_t ReplaceKeyWords(detection_pos* pNext, int space_zone,int space_id,char* I
}
replacement = replacement_t;
}
else {
replacement_t = StrReplace(replacement, "<|cropped_size|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|cropped_image|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
else {
replacement_t = StrReplace(replacement, "<|cropped_size|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|cropped_image|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
}
else {
replacement_t = StrReplace(replacement, "<|snap_size|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|snap_image|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|cropped_size|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
replacement_t = StrReplace(replacement, "<|cropped_image|>", "");
if (replacement != NULL) {
free(replacement);
replacement = NULL;
}
replacement = replacement_t;
}
strcpy(OutputString, replacement);
if (replacement != NULL) {
@ -16228,10 +16614,10 @@ void update_iou_table(detection_pos* PosInfo, int total_element_size, int tracki
}
else {
if (!(strcmp(pNext->name, "object") == 0 && pNext->number_row == 1)) {
int deltaX = abs((pNext->left_x + pNext->width / 2) - (g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].left_x + g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].width / 2));
int deltaY = abs((pNext->top_y + pNext->height / 2) - (g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].top_y + g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].height / 2));
int deltaX = abs((pNext->left_x + pNext->width / 2) - (g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].left_x + g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].width / 2));
int deltaY = abs((pNext->top_y + pNext->height / 2) - (g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].top_y + g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].height / 2));
int deltaWidth = abs(pNext->width - g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].width);
int deltaWidth = abs(pNext->width - g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].width);
int deltaHeight = abs(pNext->height - g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].height);
int threshold_3 = 25;
@ -16255,10 +16641,10 @@ void update_iou_table(detection_pos* PosInfo, int total_element_size, int tracki
}
else {
if (!(strcmp(pNext->name, "object") == 0 && pNext->number_row == 1)) {
int deltaX = abs((pNext->left_x + pNext->width / 2) - (g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].left_x + g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].width / 2));
int deltaY = abs((pNext->top_y + pNext->height / 2) - (g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].top_y + g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].height / 2));
int deltaX = abs((pNext->left_x + pNext->width / 2) - (g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].left_x + g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].width / 2));
int deltaY = abs((pNext->top_y + pNext->height / 2) - (g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].top_y + g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].height / 2));
int deltaWidth = abs(pNext->width - g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].width);
int deltaWidth = abs(pNext->width - g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].width);
int deltaHeight = abs(pNext->height - g_TrackingRecords[tracking_channel_idx][i].prev_detections[det_count - 1].height);
int threshold_3 = 25;
@ -16715,11 +17101,11 @@ void update_vote_table(detection_pos* PosInfo, int total_element_size, int track
}
if (det_count >= 1) {
int deltaX = abs((pNext->left_x + pNext->width / 2) - (g_TrackingRecords[tracking_channel_idx][k].prev_detections[det_count - 1].left_x + g_TrackingRecords[tracking_channel_idx][k].prev_detections[det_count - 1].width / 2));
int deltaY = abs((pNext->top_y + pNext->height / 2) - (g_TrackingRecords[tracking_channel_idx][k].prev_detections[det_count - 1].top_y + g_TrackingRecords[tracking_channel_idx][k].prev_detections[det_count - 1].height / 2));
//檢查長度和寬度是否在一定範圍內
int deltaWidth = abs(pNext->width - g_TrackingRecords[tracking_channel_idx][k].prev_detections[det_count - 1].width);
int deltaX = abs((pNext->left_x + pNext->width / 2) - (g_TrackingRecords[tracking_channel_idx][k].prev_detections[det_count - 1].left_x + g_TrackingRecords[tracking_channel_idx][k].prev_detections[det_count - 1].width / 2));
int deltaY = abs((pNext->top_y + pNext->height / 2) - (g_TrackingRecords[tracking_channel_idx][k].prev_detections[det_count - 1].top_y + g_TrackingRecords[tracking_channel_idx][k].prev_detections[det_count - 1].height / 2));
//檢查長度和寬度是否在一定範圍內
int deltaWidth = abs(pNext->width - g_TrackingRecords[tracking_channel_idx][k].prev_detections[det_count - 1].width);
int deltaHeight = abs(pNext->height - g_TrackingRecords[tracking_channel_idx][k].prev_detections[det_count - 1].height);
int threshold = 5;
@ -22739,28 +23125,25 @@ void move_file() {
void *start_run_python_thread(void* pythonpath) {
pthread_detach(pthread_self());
setPthreadName("run_python");
while (1)
while (bHttpServerThreadStart)
{
if (AI_fps >= 1)
{
// 抓取 python 檔案
if (strstr(SystemSetting.enable_python_file, ".py") != NULL)
{
const char *prefix = "lifile_liname=";
char pythonfile[256] = { 0 };
snprintf(pythonfile, sizeof(pythonfile), "%s%s", prefix, SystemSetting.enable_python_file);
runPython(pythonfile);
break;
}
if (AI_fps >= 1) {
const char *prefix = "lifile_liname=";
char pythonfile[256] = { 0 };
snprintf(pythonfile, sizeof(pythonfile), "%s%s", prefix, SystemSetting.enable_python_file);
runPython(pythonfile);
break;
}
else
{
printf("Wait AI_fps...");
sleep(1);
//printf("Wait AI_fps...");
}
usSleep(1000000);
}
pthread_exit(NULL);
pthread_exit(NULL);
}
#endif
@ -23075,17 +23458,9 @@ void run_server(int argc, char **argv)
//PNS_Query_Service_Status(returned_msg);
#endif
//**半OK記憶體洩漏
//output.log 138,240byte ->產生330個記憶體洩漏 output.log增長幅度顯著變比較慢
//get_current_events_json_data 會記憶體洩漏,但是不常進去。
g_IsPTZDevice = 0;
#endif
//init CGI CMD time
@ -25973,14 +26348,8 @@ void run_server(int argc, char **argv)
}
if (enable_python_file)
{
if (strstr(enable_python_file->valuestring, ".py") ==
enable_python_file->valuestring + strlen(enable_python_file->valuestring) - 3) {
strcpy(SystemSetting.enable_python_file, enable_python_file->valuestring);
pthread_create(&runpython_thread, NULL, start_run_python_thread, (void*)configPATH);
} else {
printf("File is not a Python file.\n");
}
strcpy(SystemSetting.enable_python_file, enable_python_file->valuestring);
}
else {
strcpy(SystemSetting.enable_python_file, "No python running.");
@ -31815,10 +32184,10 @@ void file_management() {
#define COUNTER_FILE "/emmc/plugin/Aida_data/counters.dat"
int protected_counters = 0;
int g_last_counters[MAX_EVENT_COUNTERS] = { 0 };
void loadCounters() {
void loadCounters() {
#ifdef GY_OS_V_SERIES
#else
#else
if (((featureType & FEATURE_TRAF_DET) == FEATURE_TRAF_DET && (featureType2 & FEATURE_AICAP) == FEATURE_AICAP) ||
((featureType & FEATURE_TRAF_DET) == FEATURE_TRAF_DET && (featureType2 & FEATURE_AISPORTS) == FEATURE_AISPORTS && strcmp(WeightFileModeName, "mod002") == 0) ||
((featureType & FEATURE_HUM_DET) == FEATURE_HUM_DET && (featureType2 & FEATURE_AIHELM) == FEATURE_AIHELM) ||
@ -31827,49 +32196,49 @@ void loadCounters() {
#ifdef GY_OS_NOVA
IsANPRCategory(featureType) ||
#endif
g_IsCustomWeight == 1)
{
if (protected_counters == 0) {
protected_counters = 1;
FILE *file = fopen(COUNTER_FILE, "r+"); // 以二進位讀取方式開啟檔案
int counters[MAX_EVENT_COUNTERS] = { 0 };
if (file) {
fread(counters, sizeof(int), MAX_EVENT_COUNTERS, file); // 從檔案中讀取計數器值
fclose(file);
for (int index_counter = 0; index_counter < MAX_EVENT_COUNTERS; index_counter++)
{
eventCounterList[index_counter].counter_count = counters[index_counter];
g_last_counters[index_counter] = counters[index_counter];
}
}
else {
for (int index_counter = 0; index_counter < MAX_EVENT_COUNTERS; index_counter++)
{
counters[index_counter] = eventCounterList[index_counter].counter_count;
g_last_counters[index_counter] = counters[index_counter];
}
file = fopen(COUNTER_FILE, "w+"); // 以二進位寫入方式開啟檔案
if (file) {
fwrite(counters, sizeof(int), MAX_EVENT_COUNTERS, file); // 將計數器值寫入檔案
fclose(file);
}
else {
printf("\nCOUNTER FILE error.#2\n");
}
}
protected_counters = 0;
}
}
#endif
g_IsCustomWeight == 1)
{
if (protected_counters == 0) {
protected_counters = 1;
FILE *file = fopen(COUNTER_FILE, "r+"); // 以二進位讀取方式開啟檔案
int counters[MAX_EVENT_COUNTERS] = { 0 };
if (file) {
fread(counters, sizeof(int), MAX_EVENT_COUNTERS, file); // 從檔案中讀取計數器值
fclose(file);
for (int index_counter = 0; index_counter < MAX_EVENT_COUNTERS; index_counter++)
{
eventCounterList[index_counter].counter_count = counters[index_counter];
g_last_counters[index_counter] = counters[index_counter];
}
}
else {
for (int index_counter = 0; index_counter < MAX_EVENT_COUNTERS; index_counter++)
{
counters[index_counter] = eventCounterList[index_counter].counter_count;
g_last_counters[index_counter] = counters[index_counter];
}
file = fopen(COUNTER_FILE, "w+"); // 以二進位寫入方式開啟檔案
if (file) {
fwrite(counters, sizeof(int), MAX_EVENT_COUNTERS, file); // 將計數器值寫入檔案
fclose(file);
}
else {
printf("\nCOUNTER FILE error.#2\n");
}
}
protected_counters = 0;
}
}
#endif
}
void saveCounters() {
void saveCounters() {
#ifdef GY_OS_V_SERIES
#else
#else
if (((featureType & FEATURE_TRAF_DET) == FEATURE_TRAF_DET && (featureType2 & FEATURE_AICAP) == FEATURE_AICAP) ||
((featureType & FEATURE_TRAF_DET) == FEATURE_TRAF_DET && (featureType2 & FEATURE_AISPORTS) == FEATURE_AISPORTS && strcmp(WeightFileModeName, "mod002") == 0) ||
((featureType & FEATURE_HUM_DET) == FEATURE_HUM_DET && (featureType2 & FEATURE_AIHELM) == FEATURE_AIHELM) ||
@ -31878,36 +32247,36 @@ void saveCounters() {
#ifdef GY_OS_NOVA
IsANPRCategory(featureType) ||
#endif
g_IsCustomWeight == 1)
{
if (protected_counters == 0) {
protected_counters = 1;
int counters[MAX_EVENT_COUNTERS] = { 0 };
int check_if_difference = 0;
for (int index_counter = 0; index_counter < MAX_EVENT_COUNTERS; index_counter++)
{
counters[index_counter] = eventCounterList[index_counter].counter_count;
if (counters[index_counter] != g_last_counters[index_counter]) {
check_if_difference = 1;
}
g_last_counters[index_counter] = counters[index_counter];
}
if (check_if_difference == 1) {
FILE *file = fopen(COUNTER_FILE, "wb"); // 以二進位寫入方式開啟檔案
if (file) {
fwrite(counters, sizeof(int), MAX_EVENT_COUNTERS, file); // 將計數器值寫入檔案
fclose(file);
}
else {
printf("\nCOUNTER FILE error.\n");
}
}
protected_counters = 0;
}
}
#endif
g_IsCustomWeight == 1)
{
if (protected_counters == 0) {
protected_counters = 1;
int counters[MAX_EVENT_COUNTERS] = { 0 };
int check_if_difference = 0;
for (int index_counter = 0; index_counter < MAX_EVENT_COUNTERS; index_counter++)
{
counters[index_counter] = eventCounterList[index_counter].counter_count;
if (counters[index_counter] != g_last_counters[index_counter]) {
check_if_difference = 1;
}
g_last_counters[index_counter] = counters[index_counter];
}
if (check_if_difference == 1) {
FILE *file = fopen(COUNTER_FILE, "wb"); // 以二進位寫入方式開啟檔案
if (file) {
fwrite(counters, sizeof(int), MAX_EVENT_COUNTERS, file); // 將計數器值寫入檔案
fclose(file);
}
else {
printf("\nCOUNTER FILE error.\n");
}
}
protected_counters = 0;
}
}
#endif
}
#ifdef GY_OS_NOVA

43
src/nweb.c

@ -10108,7 +10108,7 @@ void web_process(SOCKET* client_socket, char* recvBuffer, int recv_buff_size, ch
char convert_tojson7[256] = "\"IPCAM_ROTATE\":\"";*/
char convert_tojson8[256] = "\"}";
strcat(contentBuffer, convert_tojson1);
strcpy(contentBuffer, convert_tojson1);
strcat(contentBuffer, g_account_port_protected);
/*
strcat(contentBuffer, convert_tojson2);
@ -11429,47 +11429,23 @@ void web_process(SOCKET* client_socket, char* recvBuffer, int recv_buff_size, ch
#endif
else if (strcmp(urlBuffer, "/get_enable_ptz") == 0)
{
char convert_tojson1[256] = "{\"enable_PTZ\":\"";
char convert_tojson2[256] = "\"}";
strcat(contentBuffer, convert_tojson1);
char enable_PTZ_off[256] = "No";
strcpy(contentBuffer, "{\"enable_PTZ\":\"");
//printf("\n------g_IsPTZDevice:%d\n", g_IsPTZDevice);
#ifdef GY_OS_AMBA
char enable_PTZ_on[256] = "Yes";
//Check PTZ device
//char ptz_curl_url[512] = { 0 };
//char ptz_curl_sendbuf[1] = { 0 };
//char ptz_curl_username[128] = { 0 };
//char ptz_curl_password[128] = { 0 };
//char *method = "GET";
//int ptz_port = atoi(accountData[0].account_port);
//strcpy(ptz_curl_username, accountData[0].account_username);
//strcpy(ptz_curl_password, accountData[0].account_password);
//strcpy(ptz_curl_url, "http://");
//strcat(ptz_curl_url, "127.0.0.1:");
//strcat(ptz_curl_url, accountData[0].account_port);
//strcat(ptz_curl_url, "/server");
//if (check_ptz(ptz_curl_url, ptz_curl_sendbuf, ptz_curl_username, ptz_curl_password, method, ptz_port))
if(g_IsPTZDevice == 1)
{
strcat(contentBuffer, enable_PTZ_on);
strcat(contentBuffer, "Yes");
//strcat(contentBuffer, enable_PTZ_off);
//write_to_enable_PTZ("Yes"); //enable_PTZ 不會用到
}
else
#endif
{
strcat(contentBuffer, enable_PTZ_off);
strcat(contentBuffer, "No");
//write_to_enable_PTZ("No"); //enable_PTZ 不會用到
}
strcat(contentBuffer, convert_tojson2);
strcat(contentBuffer, "\"}");
//printf("\n[set_bypass_login]return contentBuffer = %s \n", contentBuffer);
strcpy(beforeSendBuffer, contentBuffer);
@ -16403,6 +16379,7 @@ void web_process(SOCKET* client_socket, char* recvBuffer, int recv_buff_size, ch
closesocket(cli_socket);
}
#endif
#ifdef GY_OS_AMBA
else if (strncmp(urlBuffer, "/stoppython", strlen("/stoppython")) == 0) //ming add 2024/08/26
{
char response[256];
@ -16509,8 +16486,9 @@ void web_process(SOCKET* client_socket, char* recvBuffer, int recv_buff_size, ch
char sPythonBufferTemp[MAX_GET_PYTHON_BUFFER_ROW_SIZE * 8] = { 0 }; // 單行 512,最多拿 8 行,最大尺寸即為 4096
char beforeSendBuffer[BUFSIZE * 8] = {0};
if (strcmp(SystemSetting.enable_python, "Yes") == 0)
if (strcmp(SystemSetting.enable_python, "Yes") == 0 /*&& g_cWebPythonBufferSignal == 0*/)
{
//g_cWebPythonBufferSignal = 1;
char *buffersize_ptr = strstr(urlBuffer, "buffersize=");
if (buffersize_ptr != NULL)
{
@ -16571,7 +16549,7 @@ void web_process(SOCKET* client_socket, char* recvBuffer, int recv_buff_size, ch
}
g_cWebPythonBufferSignal = 0;
//g_cWebPythonBufferSignal = 0;
}
else
{
@ -16593,6 +16571,7 @@ void web_process(SOCKET* client_socket, char* recvBuffer, int recv_buff_size, ch
}
// ========================================================================================
#endif
#endif
#if 1
else if ((strncmp(urlBuffer, "/getevents?", 11) == 0) || (strncmp(urlBuffer, "/setevents?", 11) == 0))
{

86
src/pythonR.c

@ -10,31 +10,31 @@
void IfFolderExist()
{
int check_count = 0;
int check_if_ok = 0;
while (check_count < 10) {
if (access(PYTHON_FOLDER, F_OK) == 0) {
//printf("FOLDER EXISTS.\n");
check_if_ok = 1;
break;
}
else {
//printf("FOLDER DOESN'T EXIST! Attempting to create it...\n");
if (mkdir(PYTHON_FOLDER, S_IRWXU | S_IRWXG | S_IRWXO) == 0) {
//printf("FOLDER CREATED SUCCESSFULLY.\n");
}
else {
//printf("Failed to create python folder\n");
}
}
check_count++;
usSleep(100);
}
if(check_if_ok == 0)
int check_count = 0;
int check_if_ok = 0;
while (check_count < 10) {
if (access(PYTHON_FOLDER, F_OK) == 0) {
//printf("FOLDER EXISTS.\n");
check_if_ok = 1;
break;
}
else {
//printf("FOLDER DOESN'T EXIST! Attempting to create it...\n");
if (mkdir(PYTHON_FOLDER, S_IRWXU | S_IRWXG | S_IRWXO) == 0) {
//printf("FOLDER CREATED SUCCESSFULLY.\n");
}
else {
//printf("Failed to create python folder\n");
}
}
check_count++;
usSleep(100);
}
if(check_if_ok == 0)
printf("FAILED TO CREATE FOLDER AFTER %d ATTEMPTS.\n", check_count);
}
@ -73,24 +73,24 @@ void readPythonFile(char *sINFileName, char *sOutput)
// 確認資料夾存在
int ensureFolderExists(const char *folderPath) {
struct stat st = { 0 };
int ret = 0;
// 檢查資料夾是否已存在
if (stat(folderPath, &st) == -1) {
// 嘗試創建資料夾
if (mkdir(folderPath, 0777) == -1) {
// 如果創建失敗,記錄原因
printf("\nFailed to create directory\n");
ret = -1; // 創建失敗
}
}
else if (!S_ISDIR(st.st_mode)) {
// 如果同名的檔案存在但不是資料夾
printf("\nError: A file with the same name as the folder exists.\n");
ret = -1;
}
struct stat st = { 0 };
int ret = 0;
// 檢查資料夾是否已存在
if (stat(folderPath, &st) == -1) {
// 嘗試創建資料夾
if (mkdir(folderPath, 0777) == -1) {
// 如果創建失敗,記錄原因
printf("\nFailed to create directory\n");
ret = -1; // 創建失敗
}
}
else if (!S_ISDIR(st.st_mode)) {
// 如果同名的檔案存在但不是資料夾
printf("\nError: A file with the same name as the folder exists.\n");
ret = -1;
}
return ret;
}

4
src/setting.h

@ -11,9 +11,9 @@
//general difinition
#ifdef GY_OS_AMBA
#define APP_VERSION "2.0.7.69" //跟AMBA的LPKG.json要一致
#define APP_VERSION "2.0.7.71" //跟AMBA的LPKG.json要一致
#else
#define APP_VERSION "1.4.3.4" //跟NOVA的LPKG.json要一致
#define APP_VERSION "1.4.3.5" //跟NOVA的LPKG.json要一致
#endif
#ifdef GY_OS_AMBA

27
src/test_nnctrl_live.c

@ -15078,26 +15078,15 @@ int start_all_nets(struct nnctrl_param *pctrl, struct amba_content *stAMBAconten
#endif
g_IsCustomWeight == 1)
{
char mail_content[256] = { 0 };
for (int index_counter = 0; index_counter < MAX_EVENT_COUNTERS; index_counter++)
{
char temp_msg[256] = { 0 };
if (index_counter == 0) {
snprintf(temp_msg, sizeof(temp_msg), "[%d,", eventCounterList[index_counter].counter_count);
strcpy(mail_content, temp_msg);
}
else if (index_counter < MAX_EVENT_COUNTERS - 1) {
snprintf(temp_msg, sizeof(temp_msg), "%d,", eventCounterList[index_counter].counter_count);
strcat(mail_content, temp_msg);
}
else {
snprintf(temp_msg, sizeof(temp_msg), "%d]", eventCounterList[index_counter].counter_count);
strcat(mail_content, temp_msg);
}
//printf("\n-----emailData.email_content:%s\n", emailData.email_content);
if (strlen(emailData.email_content) >= 1) {
char mail_content[8192] = { 0 };
size_t mail_size = ReplaceKeyWords(NULL, -1, -1, emailData.email_content, mail_content, 0, 0, 0, NULL, 0, 0, NULL, 0, 0);
mail_content[mail_size] = '\0';
//printf("\n-----mail_content:%s\n", mail_content);
run_counter_mail(mail_content, mail_size, g_current_snapshot_addr_base64, g_current_snapshot_size_base64);
}
run_counter_mail(mail_content,strlen(mail_content));
}
#endif

2
src/utility.h

@ -783,7 +783,7 @@ extern "C" {
#else
void reset_counter(int index_counter, time_t now_time);
void set_counter_zone();
void run_counter_mail(char * mail_content, int mail_content_size);
void run_counter_mail(char * mail_content, int mail_content_size, char* image_buff_base64, int image_buff_size_base64);
#endif
#ifdef __cplusplus

Loading…
Cancel
Save