@ -32,9 +32,7 @@
# include <errno.h>
# include <time.h>
# include "net_curl.h"
# ifdef GY_OS_AMBA
# include <pythonR.h>
# endif
# include "structures.h"
# if defined GY_OS_AMBA
@ -158,12 +156,11 @@ pthread_mutex_t mutex_write_pcd_data_L;
pthread_mutex_t mutex_write_pcd_data_M ;
pthread_mutex_t mutex_write_pcd_data_S ;
pthread_mutex_t buffer_mutex ;
pthread_mutex_t mutex_remotesnap_image ; // Ken 2022-09-26
pthread_mutex_t mutex_radar_json ; // Ken 2022-09-22
pthread_mutex_t mutex_tof_json ; // Ken 2022-12-13
pthread_mutex_t mutex_buffer ; // Ming 2022-08-28
pthread_mutex_t mutex_run_osd ;
# endif
@ -301,7 +298,7 @@ int g_check_current_resolution = 1;
# if defined GY_OS_AMBA || defined GY_OS_NOVA
cJSON * g_config_root = NULL ;
char * get_enable_python_file_value ( const char * filename ) ;
# endif
/*typedef struct {
@ -386,9 +383,7 @@ pthread_t http_thread_parse_json_data;
pthread_t http_thread_pre_image_receive ;
# endif
pthread_t post_notification_thread ;
# ifdef GY_OS_AMBA
pthread_t runpython_thread ;
# endif
pthread_t getalarmmotion_thread ;
pthread_t delete_jpg_in_seven_days_detector_thread_id ;
@ -989,8 +984,6 @@ void *run_event_counter_thread(void *ptr)
set_counter_zone ( ) ;
loadCounters ( ) ;
while ( bHttpServerThreadStart )
{
//printf("\n-----run event counter thread start\n");
@ -1198,9 +1191,6 @@ void *run_post_notification_thread(void *ptr)
int count_ptz = 0 ;
# endif
struct timeval currtime_pns_check ;
long last_s_pns_check = 0 ;
while ( bHttpServerThreadStart )
{
//printf("\n-----run post notification start\n");
@ -1319,54 +1309,6 @@ void *run_post_notification_thread(void *ptr)
# endif
}
if ( strcmp ( SystemSetting . cloud_enable_notification , " Yes " ) = = 0 ) {
if ( strlen ( SystemSetting . cloud_account ) > = 1 & & strlen ( SystemSetting . cloud_password ) > = 1 & & strcmp ( SystemSetting . cloud_account , " myaccount@mail.com " ) ! = 0 ) {
if ( g_check_ping_OK = = 1 ) {
gettimeofday ( & currtime_pns_check , NULL ) ;
long current_s_pns_check = currtime_pns_check . tv_sec ;
if ( last_s_pns_check = = 0 | |
( ( current_s_pns_check - last_s_pns_check ) > = 3600 & & get_g_check_wrong_pass_or_email ( ) = = 0 ) | |
( ( current_s_pns_check - last_s_pns_check ) > = 900 & & get_g_check_wrong_pass_or_email ( ) = = 1 ) ) {
char returned_msg_temp [ MEMORY_SIZE ] = { 0 } ;
PNS_check_if_to_post_image ( SystemSetting . cloud_account , SystemSetting . cloud_password , returned_msg_temp , " https://cloud.ddnsipcam.com/pns/ " ) ;
if ( strstr ( returned_msg_temp , " \" msg \" : \" oaA= \" " ) ! = NULL ) {
set_g_pns_account_OK ( 1 ) ;
if ( strstr ( returned_msg_temp , " \" eid \" : \" Yg== \" " ) ! = NULL ) {
set_g_pns_access_level ( 0 ) ;
}
else if ( strstr ( returned_msg_temp , " \" eid \" : \" Yw== \" " ) ! = NULL ) {
set_g_pns_access_level ( 1 ) ;
set_g_check_invalidpass ( 0 ) ;
set_g_check_emailnotvalid ( 0 ) ;
}
else if ( strstr ( returned_msg_temp , " \" eid \" : \" ZQ== \" " ) ! = NULL ) {
set_g_pns_access_level ( 3 ) ;
set_g_check_invalidpass ( 0 ) ;
set_g_check_emailnotvalid ( 0 ) ;
}
else if ( strstr ( returned_msg_temp , " \" eid \" :{ \" err \" : \" Yw== \" , \" msg \" : \" p6PFmpaZoZqU \" } " ) ! = NULL ) {
set_g_pns_access_level ( - 2 ) ;
}
}
last_s_pns_check = current_s_pns_check ;
}
}
}
else {
set_g_pns_account_OK ( 1 ) ;
set_g_pns_access_level ( 0 ) ;
last_s_pns_check = 0 ;
}
}
else {
last_s_pns_check = 0 ;
}
# ifdef GY_OS_AMBA
if ( g_IsPTZDevice = = 1 & & get_try_once_ptz ( ) = = 1 ) {
if ( IsTracking ( ) = = 1 ) {
@ -5550,7 +5492,7 @@ void PlateFilterForParkingPlot(detection_pos* PosInfo, int total_element_size, i
g_PostRecorderList [ k ] . box_h = 0 ;
g_PostRecorderList [ k ] . object_id = 0 ;
g_PostRecorderList [ k ] . zone_idx = - 1 ;
g_PostRecorderList [ k ] . zone_idx = 0 ;
strcpy ( g_PostRecorderList [ k ] . sPlateNumber , " " ) ;
g_PostRecorderList [ k ] . count_trigger = 0 ;
@ -5583,7 +5525,7 @@ void PlateFilterForParkingPlot(detection_pos* PosInfo, int total_element_size, i
g_longterm_PostRecorderList [ k ] . box_h = 0 ;
g_longterm_PostRecorderList [ k ] . object_id = 0 ;
g_longterm_PostRecorderList [ k ] . zone_idx = - 1 ;
g_longterm_PostRecorderList [ k ] . zone_idx = 0 ;
strcpy ( g_longterm_PostRecorderList [ k ] . sPlateNumber , " " ) ;
g_longterm_PostRecorderList [ k ] . count_trigger = 0 ;
@ -11281,7 +11223,7 @@ void initial_g_PostRecorderList() {
g_PostRecorderList [ i ] . box_h = 0.0 ;
g_PostRecorderList [ i ] . object_id = 0.0 ;
g_PostRecorderList [ i ] . zone_idx = - 1 ;
g_PostRecorderList [ i ] . zone_idx = 0.0 ;
strcpy ( g_PostRecorderList [ i ] . sPlateNumber , " " ) ;
strcpy ( g_PostRecorderList [ i ] . name , " " ) ;
@ -11311,7 +11253,7 @@ void initial_g_PostRecorderList() {
g_longterm_PostRecorderList [ i ] . box_h = 0.0 ;
g_longterm_PostRecorderList [ i ] . object_id = 0.0 ;
g_longterm_PostRecorderList [ i ] . zone_idx = - 1 ;
g_longterm_PostRecorderList [ i ] . zone_idx = 0.0 ;
strcpy ( g_longterm_PostRecorderList [ i ] . sPlateNumber , " " ) ;
strcpy ( g_longterm_PostRecorderList [ i ] . name , " " ) ;
@ -11400,17 +11342,11 @@ void CheckPostEventCondition(detection_pos* pNext, int tracking_channel_idx, int
temp_A . height = g_PostRecorderList [ i ] . box_h ;
strcpy ( temp_A . name , g_PostRecorderList [ i ] . name ) ;
float temp_A_iou = detection_overlap_ratio ( & temp_A , pNext ) ;
float temp_A_iou = detection_overlap_ratio_union ( & temp_A , pNext ) ;
//float compare_ratio = (temp_A.height / temp_A.width) / (pNext->height / pNext->width);
float compare_height_ratio = pNext - > height / temp_A . height ;
float compare_width_ratio = pNext - > width / temp_A . width ;
float temp_A_center_x = temp_A . left_x + temp_A . width / 2.0 ;
float temp_A_center_y = temp_A . top_y + temp_A . height / 2.0 ;
float p_center_x = pNext - > left_x + pNext - > width / 2.0 ;
float p_center_y = pNext - > top_y + pNext - > height / 2.0 ;
float temp_distance = ( temp_A_center_x - p_center_x ) * ( temp_A_center_x - p_center_x ) + ( temp_A_center_y - p_center_y ) * ( temp_A_center_y - p_center_y ) ;
if ( strlen ( g_PostRecorderList [ i ] . sPlateNumber ) > = 1 | | IsANPRCategory_L_Plate ( pNext - > name ) )
{
if ( strlen ( g_PostRecorderList [ i ] . sPlateNumber ) > = 1 & & IsANPRCategory_L_Plate ( pNext - > name ) & & LevenshteinDistance ( g_PostRecorderList [ i ] . sPlateNumber , pNext - > properties . plate , atoi ( viewChannelData [ tracking_channel_idx ] . levenshtein_distance ) ) > 0 )
@ -11455,16 +11391,14 @@ void CheckPostEventCondition(detection_pos* pNext, int tracking_channel_idx, int
}
}
else {
/*if ((strcmp(pNext->name, "car") != 0 && compare_height_ratio >= 2.0 && compare_height_ratio <= 4.0
& & compare_width_ratio > = 2.0 & & compare_width_ratio < = 4.0 ) | |
( strcmp ( pNext - > name , " car " ) = = 0 & & compare_height_ratio > = 5.0 & & compare_height_ratio < = 9.0
& & compare_width_ratio > = 5.0 & & compare_width_ratio < = 9.0 ) ) */
if ( compare_height_ratio > = 2.0 & & compare_height_ratio < = 4.0
& & compare_width_ratio > = 2.0 & & compare_width_ratio < = 4.0 )
{
if ( strcmp ( g_PostRecorderList [ i ] . name , pNext - > name ) = = 0 ) {
if ( strcmp ( pNext - > name , " person " ) = = 0 ) {
//if (compare_ratio <= 1.1 && compare_ratio >= 0.9)
{
if ( /*g_PostRecorderList[i].object_id == pNext->obj_tracking_id || */ temp_A_iou > 0.7 ) {
if ( /*g_PostRecorderList[i].object_id == pNext->obj_tracking_id || */ temp_A_iou > 0.35 ) {
double temp_dTime = difftime ( now_time , g_PostRecorderList [ i ] . t_FirstGetTime_total ) ;
if ( temp_dTime > max_dwell_short ) {
max_dwell_short = temp_dTime ;
@ -11485,7 +11419,7 @@ void CheckPostEventCondition(detection_pos* pNext, int tracking_channel_idx, int
}
}
else {
if ( /*g_PostRecorderList[i].object_id == pNext->obj_tracking_id || */ temp_A_iou > 0.7 /*|| temp_distance <= 225.0*/ ) {
if ( /*g_PostRecorderList[i].object_id == pNext->obj_tracking_id || */ temp_A_iou > 0.35 ) {
double temp_dTime = difftime ( now_time , g_PostRecorderList [ i ] . t_FirstGetTime_total ) ;
if ( temp_dTime > max_dwell_short ) {
max_dwell_short = temp_dTime ;
@ -11520,17 +11454,11 @@ void CheckPostEventCondition(detection_pos* pNext, int tracking_channel_idx, int
temp_A . height = g_longterm_PostRecorderList [ i ] . box_h ;
strcpy ( temp_A . name , g_longterm_PostRecorderList [ i ] . name ) ;
float temp_A_iou = detection_overlap_ratio ( & temp_A , pNext ) ;
float temp_A_iou = detection_overlap_ratio_union ( & temp_A , pNext ) ;
//float compare_ratio = (temp_A.height / temp_A.width) / (pNext->height / pNext->width);
float compare_height_ratio = pNext - > height / temp_A . height ;
float compare_width_ratio = pNext - > width / temp_A . width ;
float temp_A_center_x = temp_A . left_x + temp_A . width / 2.0 ;
float temp_A_center_y = temp_A . top_y + temp_A . height / 2.0 ;
float p_center_x = pNext - > left_x + pNext - > width / 2.0 ;
float p_center_y = pNext - > top_y + pNext - > height / 2.0 ;
float temp_distance = ( temp_A_center_x - p_center_x ) * ( temp_A_center_x - p_center_x ) + ( temp_A_center_y - p_center_y ) * ( temp_A_center_y - p_center_y ) ;
if ( strlen ( g_longterm_PostRecorderList [ i ] . sPlateNumber ) > = 1 | | IsANPRCategory_L_Plate ( pNext - > name ) )
{
if ( strlen ( g_longterm_PostRecorderList [ i ] . sPlateNumber ) > = 1 & & IsANPRCategory_L_Plate ( pNext - > name ) & & LevenshteinDistance ( g_longterm_PostRecorderList [ i ] . sPlateNumber , pNext - > properties . plate , atoi ( viewChannelData [ tracking_channel_idx ] . levenshtein_distance ) ) > 0 )
@ -11565,16 +11493,14 @@ void CheckPostEventCondition(detection_pos* pNext, int tracking_channel_idx, int
}
}
else {
/*if ((strcmp(pNext->name, "car") != 0 && compare_height_ratio >= 2.0 && compare_height_ratio <= 4.0
& & compare_width_ratio > = 2.0 & & compare_width_ratio < = 4.0 ) | |
( strcmp ( pNext - > name , " car " ) = = 0 & & compare_height_ratio > = 5.0 & & compare_height_ratio < = 9.0
& & compare_width_ratio > = 5.0 & & compare_width_ratio < = 9.0 ) ) */
if ( compare_height_ratio > = 2.0 & & compare_height_ratio < = 4.0
& & compare_width_ratio > = 2.0 & & compare_width_ratio < = 4.0 )
{
if ( strcmp ( g_longterm_PostRecorderList [ i ] . name , pNext - > name ) = = 0 ) {
if ( strcmp ( pNext - > name , " person " ) = = 0 ) {
//if (compare_ratio <= 1.1 && compare_ratio >= 0.9)
{
if ( /*g_longterm_PostRecorderList[i].object_id == pNext->obj_tracking_id || */ temp_A_iou > 0.7 ) {
if ( /*g_longterm_PostRecorderList[i].object_id == pNext->obj_tracking_id || */ temp_A_iou > 0.35 ) {
iFindMatchPost_longterm = 1 ;
//g_longterm_PostRecorderList[i].t_UpdateTime = now_time;
//g_longterm_PostRecorderList[i].object_id = pNext->obj_tracking_id;
@ -11590,7 +11516,7 @@ void CheckPostEventCondition(detection_pos* pNext, int tracking_channel_idx, int
}
}
else {
if ( /*g_longterm_PostRecorderList[i].object_id == pNext->obj_tracking_id || */ temp_A_iou > 0.7 /*|| temp_distance <= 225.0*/ ) {
if ( /*g_longterm_PostRecorderList[i].object_id == pNext->obj_tracking_id || */ temp_A_iou > 0.35 ) {
iFindMatchPost_longterm = 1 ;
//g_longterm_PostRecorderList[i].t_UpdateTime = now_time;
//g_longterm_PostRecorderList[i].object_id = pNext->obj_tracking_id;
@ -11611,7 +11537,7 @@ void CheckPostEventCondition(detection_pos* pNext, int tracking_channel_idx, int
}
}
#if 0
# if 1
if ( strcmp ( pNext - > name , " object " ) ! = 0 & & strcmp ( pNext - > name , " person " ) ! = 0 ) {
if ( iFindMatchPost_longterm = = 0 )
{
@ -11692,18 +11618,10 @@ void CheckPostEventCondition(detection_pos* pNext, int tracking_channel_idx, int
g_PostRecorderList [ i ] . check_if_ftp = 0 ;
g_PostRecorderList [ i ] . check_if_getalarmmotion = 0 ;
if ( strcmp ( pNext - > name , " car " ) = = 0 ) {
g_PostRecorderList [ i ] . box_x = pNext - > left_x + pNext - > width * 2.0 / 5.0 ;
g_PostRecorderList [ i ] . box_y = pNext - > top_y + pNext - > height * 2.0 / 5.0 ;
g_PostRecorderList [ i ] . box_w = pNext - > width / 5.0 ;
g_PostRecorderList [ i ] . box_h = pNext - > height / 5.0 ;
}
else {
g_PostRecorderList [ i ] . box_x = pNext - > left_x + pNext - > width / 3.0 ;
g_PostRecorderList [ i ] . box_y = pNext - > top_y + pNext - > height / 3.0 ;
g_PostRecorderList [ i ] . box_w = pNext - > width / 3.0 ;
g_PostRecorderList [ i ] . box_h = pNext - > height / 3.0 ;
}
g_PostRecorderList [ i ] . box_x = pNext - > left_x + pNext - > width / 3.0 ;
g_PostRecorderList [ i ] . box_y = pNext - > top_y + pNext - > height / 3.0 ;
g_PostRecorderList [ i ] . box_w = pNext - > width / 3.0 ;
g_PostRecorderList [ i ] . box_h = pNext - > height / 3.0 ;
g_PostRecorderList [ i ] . object_id = pNext - > obj_tracking_id ;
g_PostRecorderList [ i ] . zone_idx = detection_zone_idx ;
@ -12658,11 +12576,13 @@ void CheckPostEventCondition(detection_pos* pNext, int tracking_channel_idx, int
if ( ( ( trigger_event_type = = TRIGGER_MISSING_OBJECT_DETECTION | | trigger_event_type = = TRIGGER_LACK_OF_ANY_OBJECT | | trigger_event_type = = TRIGGER_ALL_OBJECTS ) & & pNext = = NULL ) | | strcmp ( heartbeatData . enable_location_once_to_post , " Yes " ) ! = 0 | |
( size_g_PostRecorderList > = 1 & & g_PostRecorderList [ index_g_PostRecorderList [ 0 ] ] . check_if_email = = 0 & &
( size_g_PostRecorderList_longterm = = 0 | | ( size_g_PostRecorderList_longterm > = 1 & & g_longterm_PostRecorderList [ index_g_PostRecorderList_longterm [ 0 ] ] . check_if_email = = 0 ) ) ) ) {
if ( Get_mail_post_interval ( ) ! = - 1 & & strcmp ( SystemSetting . send_counter_at_specific_hour , " NULL " ) = = 0 & &
( last_ms_CheckPostEventCondition_email = = 0 | |
( current_ms_CheckPostEventCondition_email - last_ms_CheckPostEventCondition_email ) > Get_mail_post_interval ( ) * 1000 ) )
{
if ( QueueSize ( _POST_NOTIFICATION ) < MAX_QUEUE_SIZE & & QueueSize ( _POST_NOTIFICATION ) > = 0 )
if ( last_ms_CheckPostEventCondition_email = = 0 | |
( Get_mail_post_interval ( ) = = - 1 & & strcmp ( SystemSetting . send_counter_at_specific_hour , " NULL " ) = = 0 & &
( current_ms_CheckPostEventCondition_email - last_ms_CheckPostEventCondition_email ) > d_no_parking_time * 1000 ) | |
( Get_mail_post_interval ( ) ! = - 1 & & strcmp ( SystemSetting . send_counter_at_specific_hour , " NULL " ) = = 0 & &
( current_ms_CheckPostEventCondition_email - last_ms_CheckPostEventCondition_email ) > Get_mail_post_interval ( ) * 1000 ) | |
force_to_push = = 1 ) {
if ( ( QueueSize ( _POST_NOTIFICATION ) < MAX_QUEUE_SIZE & & QueueSize ( _POST_NOTIFICATION ) > = 0 ) | | force_to_push = = 1 )
{
QueueInfo q_info = { 0 } ;
@ -13418,8 +13338,7 @@ void Record_Point_Touch_and_IsInsideZone(detection_pos* pNext, int tracking_chan
//printf("\n----------count_four_points_touch:%d\n", count_four_points_touch);
//printf("\n----------count_touch:%d\n", count_touch);
//int threahold_div = g_sensors_type == 0 ? 1 : 5;
int threahold_div = 2 ;
int threahold_div = g_sensors_type = = 0 ? 1 : 7 ;
if ( count_four_points_touch > = 45 / threahold_div ) {
g_TrackingRecords [ tracking_channel_idx ] [ tracking_obj_idx ] . IsInsideZone_four_points [ zone_index ] [ det_count_idx ] = 1 ;
@ -13853,7 +13772,7 @@ void UpdateZoneStatus(detection_pos* pNext, int tracking_channel_idx, int tracki
int last_count_touch = 0 ;
float threshold_for_count_touch = 0.77 ;
int threshold_for_last_count_touch = 55 ;
int threahold_div = g_sensors_type = = 0 ? 1 : 5 ; //1 7
int threahold_div = g_sensors_type = = 0 ? 1 : 7 ; //1 7
if ( ratio_area_zone_polygon > = 0.75 ) {
threshold_for_count_touch = 0.67 ;
@ -13951,7 +13870,7 @@ void UpdateZoneStatus(detection_pos* pNext, int tracking_channel_idx, int tracki
}
}
if ( strcmp ( pNext - > name , " person " ) ! = 0 | | f abs( g_TrackingRecords [ tracking_channel_idx ] [ tracking_obj_idx ] . prev_detections [ det_count_idx - 1 ] . left_x - pNext - > left_x ) < = pNext - > width * 5 )
if ( strcmp ( pNext - > name , " person " ) ! = 0 | | abs ( g_TrackingRecords [ tracking_channel_idx ] [ tracking_obj_idx ] . prev_detections [ det_count_idx - 1 ] . left_x - pNext - > left_x ) < = pNext - > width * 5 )
{
int m = 0 ;
int array_zone_count [ 4 ] = { 0 } ;
@ -14090,7 +14009,7 @@ void UpdateZoneStatus(detection_pos* pNext, int tracking_channel_idx, int tracki
}
if ( strcmp ( pNext - > name , " person " ) ! = 0 | | f abs( g_TrackingRecords [ tracking_channel_idx ] [ tracking_obj_idx ] . prev_detections [ det_count_idx - 1 ] . left_x - pNext - > left_x ) < = pNext - > width * 5 ) {
if ( strcmp ( pNext - > name , " person " ) ! = 0 | | abs ( g_TrackingRecords [ tracking_channel_idx ] [ tracking_obj_idx ] . prev_detections [ det_count_idx - 1 ] . left_x - pNext - > left_x ) < = pNext - > width * 5 ) {
if ( ( p1 [ 4 ] . x = = q1 [ 4 ] . x & & p1 [ 4 ] . y = = q1 [ 4 ] . y ) | |
( p1 [ 7 ] . x = = q1 [ 7 ] . x & & p1 [ 7 ] . y = = q1 [ 7 ] . y ) ) {
@ -14751,7 +14670,7 @@ void UpdateZoneStatus(detection_pos* pNext, int tracking_channel_idx, int tracki
int last_count_touch = 0 ;
float threshold_for_count_touch = 0.77 ;
int threshold_for_last_count_touch = 55 ;
int threahold_div = g_sensors_type = = 0 ? 1 : 5 ; //1 7
int threahold_div = g_sensors_type = = 0 ? 1 : 7 ; //1 7
if ( ratio_area_zone_polygon > = 0.75 ) {
threshold_for_count_touch = 0.67 ;
@ -14849,8 +14768,7 @@ void UpdateZoneStatus(detection_pos* pNext, int tracking_channel_idx, int tracki
}
}
if ( ( strcmp ( pNext - > name , " person " ) ! = 0 & & fabs ( g_TrackingRecords [ tracking_channel_idx ] [ tracking_obj_idx ] . prev_detections [ det_count_idx - 1 ] . left_x - pNext - > left_x ) < = pNext - > width * 1.5 ) | |
( strcmp ( pNext - > name , " person " ) = = 0 & & fabs ( g_TrackingRecords [ tracking_channel_idx ] [ tracking_obj_idx ] . prev_detections [ det_count_idx - 1 ] . left_x - pNext - > left_x ) < = pNext - > width * 5 ) )
if ( strcmp ( pNext - > name , " person " ) ! = 0 | | abs ( g_TrackingRecords [ tracking_channel_idx ] [ tracking_obj_idx ] . prev_detections [ det_count_idx - 1 ] . left_x - pNext - > left_x ) < = pNext - > width * 5 )
{
int m = 0 ;
int array_zone_count [ 4 ] = { 0 } ;
@ -14990,8 +14908,7 @@ void UpdateZoneStatus(detection_pos* pNext, int tracking_channel_idx, int tracki
}
}
if ( ( strcmp ( pNext - > name , " person " ) ! = 0 & & fabs ( g_TrackingRecords [ tracking_channel_idx ] [ tracking_obj_idx ] . prev_detections [ det_count_idx - 1 ] . left_x - pNext - > left_x ) < = pNext - > width * 1.5 ) | |
( strcmp ( pNext - > name , " person " ) = = 0 & & fabs ( g_TrackingRecords [ tracking_channel_idx ] [ tracking_obj_idx ] . prev_detections [ det_count_idx - 1 ] . left_x - pNext - > left_x ) < = pNext - > width * 5 ) ) {
if ( strcmp ( pNext - > name , " person " ) ! = 0 | | abs ( g_TrackingRecords [ tracking_channel_idx ] [ tracking_obj_idx ] . prev_detections [ det_count_idx - 1 ] . left_x - pNext - > left_x ) < = pNext - > width * 5 ) {
if ( ( p1 [ 4 ] . x = = q1 [ 4 ] . x & & p1 [ 4 ] . y = = q1 [ 4 ] . y ) | |
( p1 [ 7 ] . x = = q1 [ 7 ] . x & & p1 [ 7 ] . y = = q1 [ 7 ] . y ) ) {
@ -16228,10 +16145,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 +16172,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 +16632,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 ;
@ -17479,7 +17396,7 @@ void GetObjectTrackingIDNew(detection_pos* PosInfo, int * total_element_size_tem
if ( pNext - > obj_tracking_id > = 1 & & pNext - > obj_tracking_id_idx > = 0 & & pNext - > obj_dwell_time > = 1 & & strcmp ( pNext - > name , " object " ) = = 0 & & pNext - > number_row = = 1 & &
pNext - > height > = 1 & & pNext - > width > = 1 )
{
int checkisInside = check_if_object_in_zone ( pNext - > center_x , pNext - > center_y , pNext - > width + pNext - > height , pNext - > width + pNext - > height , g_ori_yuv_width , g_ori_yuv_height , 0 ) ;
int checkisInside = check_if_object_in_zone ( pNext - > center_x , pNext - > center_y , pNext - > width * 1.5 , pNext - > height * 1.5 , g_ori_yuv_width , g_ori_yuv_height , 0 ) ;
if ( checkisInside = = 1 & & ( pNext - > width * pNext - > height ) / ( ( float ) g_ori_yuv_width * ( float ) g_ori_yuv_height ) < 0.2
& & pNext - > width / ( float ) g_ori_yuv_width < 0.2 & & pNext - > height / ( float ) g_ori_yuv_height < 0.2 ) {
@ -20969,7 +20886,6 @@ int reload_dataset_from_jsonfile(void)
snprintf ( temp_msg , sizeof ( temp_msg ) , " free:%d,%s " , get_free_mem_data ( ) , " getnetwork_buffer_id change " ) ;
write_to_logs_html ( temp_msg , " reload dataset " , " CGI_REBOOT " , " Yes " ) ;
write_to_log_if_error ( temp_msg , " reload dataset " , " CGI_REBOOT " ) ;
saveCounters ( ) ;
pthread_t auto_reboot_thread_id ;
if ( pthread_create ( & auto_reboot_thread_id , 0 , auto_reboot , NULL ) )
@ -21309,9 +21225,11 @@ int reload_dataset_from_jsonfile(void)
strcpy ( SystemSetting . enable_python , enable_python - > valuestring ) ;
enable_python_file = cJSON_GetObjectItem ( system_setting , " enable_python_file " ) ;
if ( enable_python_file ) {
if ( enable_python_file )
{
strcpy ( SystemSetting . enable_python_file , enable_python_file - > valuestring ) ;
}
enable_low_cpu_usage = cJSON_GetObjectItem ( system_setting , " enable_low_cpu_usage " ) ;
strcpy ( SystemSetting . enable_low_cpu_usage , enable_low_cpu_usage - > valuestring ) ;
@ -21966,7 +21884,7 @@ void test_detector_mem(char *image_buff, CNNType cnn_type, char *cfg_files, floa
# if 1
//329個Memory not freed 正常背景值洩漏
if ( pthread_create ( & http_thread , 0 , run_http_server_thread , 0 ) )
printf ( " HTTP server thread creation failed \n " ) ;
error ( " HTTP server thread creation failed \n " ) ;
# endif
@ -21981,7 +21899,7 @@ void test_detector_mem(char *image_buff, CNNType cnn_type, char *cfg_files, floa
long data_size = sizeof ( frameimage ) + sizeof ( rbuf_t ) ;
tof_depth_shmid = Initial_ShareMemory ( data_size , 888 ) ;
if ( tof_depth_shmid = = - 1 ) {
printf ( " Create shared memory failed ! \n " ) ;
perror ( " Create shared memory failed ! \n " ) ;
}
else {
// 初始化緩衝區
@ -21990,7 +21908,7 @@ void test_detector_mem(char *image_buff, CNNType cnn_type, char *cfg_files, floa
bTofDataStart = 1 ;
if ( pthread_create ( & gettofdata_thread , 0 , thread_getTofData , 0 ) )
printf ( " thread gettofdata creation failed \n " ) ;
error ( " thread gettofdata creation failed \n " ) ;
}
}
# endif
@ -22063,17 +21981,17 @@ void test_detector_mem(char *image_buff, CNNType cnn_type, char *cfg_files, floa
bHttpServerThreadStart = 1 ;
if ( pthread_create ( & post_notification_thread , 0 , run_post_notification_thread , NULL ) )
printf ( " Post notification thread creation failed \n " ) ;
error ( " Post notification thread creation failed \n " ) ;
# endif
# ifdef GY_OS_NOVA
if ( pthread_create ( & resolution_changed_thread , 0 , auto_resolution_changed , NULL ) )
printf ( " resolution changed thread failed \n " ) ;
error ( " resolution changed thread failed \n " ) ;
# else
if ( get_run_check_current_resolution ( ) = = - 1 ) {
set_run_check_current_resolution ( 0 ) ;
if ( pthread_create ( & resolution_changed_thread , 0 , check_current_resolution , NULL ) )
printf ( " check current resolution thread failed \n " ) ;
error ( " check current resolution thread failed \n " ) ;
}
# endif
@ -22092,10 +22010,10 @@ void test_detector_mem(char *image_buff, CNNType cnn_type, char *cfg_files, floa
{
printf ( " \n [gynet] g_IsRadarDevice || g_IsToFDevice \n " ) ;
if ( pthread_create ( & getimage_thread , 0 , thread_getimage , 0 ) )
printf ( " thread getimage creation failed \n " ) ;
error ( " thread getimage creation failed \n " ) ;
# ifdef GY_OS_AMBA
if ( pthread_create ( & getimage_hd_thread , 0 , thread_getimage_hd , 0 ) )
printf ( " thread getimage creation failed \n " ) ;
error ( " thread getimage creation failed \n " ) ;
# endif
}
@ -22105,20 +22023,20 @@ void test_detector_mem(char *image_buff, CNNType cnn_type, char *cfg_files, floa
if ( g_IsRadarDevice = = 1 )
{
if ( pthread_create ( & render_radar_thread , 0 , thread_render_radar_img , 0 ) )
printf ( " thread render_radar creation failed \n " ) ;
error ( " thread render_radar creation failed \n " ) ;
if ( g_IsRadarFake = = 1 )
{
if ( pthread_create ( & radar_reciever_id , NULL , RADAR_recieve , ( void * ) & radar_json_data ) < 0 )
printf ( " RADAR_recieve creation failed \n " ) ;
error ( " RADAR_recieve creation failed \n " ) ;
}
else
{
if ( pthread_create ( & getstream_thread , 0 , thread_getstream , 0 ) )
printf ( " thread getimage creation failed \n " ) ;
error ( " thread getimage creation failed \n " ) ;
if ( pthread_create ( & radar_parser_thread , 0 , thread_parse_radar , 0 ) )
printf ( " thread radar parser creation failed \n " ) ;
error ( " thread radar parser creation failed \n " ) ;
}
}
# endif
@ -22136,9 +22054,9 @@ void test_detector_mem(char *image_buff, CNNType cnn_type, char *cfg_files, floa
if ( unlockingKeyInnoFR_success = = 1 ) {
# ifdef GY_OS_AMBA
if ( pthread_create ( & get_face_websocket_thread , 0 , thread_get_face_websocket , 0 ) )
printf ( " thread get_face_websocket creation failed \n " ) ;
error ( " thread get_face_websocket creation failed \n " ) ;
if ( pthread_create ( & parse_face_thread , 0 , thread_parse_face , 0 ) )
printf ( " thread parse_face creation failed \n " ) ;
error ( " thread parse_face creation failed \n " ) ;
# endif
}
# endif
@ -22150,7 +22068,7 @@ void test_detector_mem(char *image_buff, CNNType cnn_type, char *cfg_files, floa
# if 1
//test_nn_main & run_send_udp_thread & run_getalarmmotion_thread output.log 8,532,480byte -> 產生1167個記憶體洩漏 大約1167-1072=95個記憶體洩漏是run_getalarmmotion_thread造成的
if ( pthread_create ( & getalarmmotion_thread , 0 , run_getalarmmotion_thread , NULL ) )
printf ( " Getalarmmotion thread creation failed \n " ) ;
error ( " Getalarmmotion thread creation failed \n " ) ;
# endif
# ifdef GY_OS_V_SERIES
@ -22169,7 +22087,7 @@ void test_detector_mem(char *image_buff, CNNType cnn_type, char *cfg_files, floa
# if 1
////原本名稱是check_http_socket_thread,現在改成run_event_counter_thread
if ( pthread_create ( & counter_thread , 0 , run_event_counter_thread , NULL ) )
printf ( " check http socket thread creation failed \n " ) ;
error ( " check http socket thread creation failed \n " ) ;
# endif
}
# endif
@ -22190,7 +22108,7 @@ void test_detector_mem(char *image_buff, CNNType cnn_type, char *cfg_files, floa
# if 1
//test_nn_main & run_send_udp_thread output.log 8,579,969byte -> 產生1072個記憶體洩漏 大約1072-875=197個記憶體洩漏是run_send_udp_thread造成的
if ( pthread_create ( & send_udp_thread , 0 , run_send_udp_thread , NULL ) )
printf ( " check http socket thread creation failed \n " ) ;
error ( " check http socket thread creation failed \n " ) ;
# endif
# ifdef GY_OS_AMBA
@ -22202,21 +22120,21 @@ void test_detector_mem(char *image_buff, CNNType cnn_type, char *cfg_files, floa
{
# if 1
if ( pthread_create ( & test_nnctrl_live_thread , 0 , test_nn_main , & stAMBAcontent ) )
printf ( " Test nnctrl live thread creation failed \n " ) ;
error ( " Test nnctrl live thread creation failed \n " ) ;
# endif
}
# endif
# ifdef GY_OS_NOVA
if ( pthread_create ( & test_nnctrl_live_thread , 0 , nnctrl_main , & stAMBAcontent ) )
printf ( " Test nnctrl live thread creation failed \n " ) ;
error ( " Test nnctrl live thread creation failed \n " ) ;
# endif
# if 1
//329個Memory not freed 正常背景值洩漏
//Get CPU/VPU loading & AI FPS
if ( pthread_create ( & fps_loading_thread , 0 , run_fps_loading_thread , NULL ) )
printf ( " fps loading thread creation failed \n " ) ;
error ( " fps loading thread creation failed \n " ) ;
# endif
# ifdef GY_OS_AMBA
# if 1
@ -22229,23 +22147,13 @@ void test_detector_mem(char *image_buff, CNNType cnn_type, char *cfg_files, floa
# ifdef GY_OS_NOVA
if ( pthread_create ( & thread_id_get_nova_driver , 0 , thread_get_nova_driver , 0 ) )
printf ( " thread get nova driver creation failed \n " ) ;
error ( " thread get nova driver creation failed \n " ) ;
# endif
//System time sync
//if (pthread_create(&thread_id_run_system_time_sync, 0, run_osd_time_sync_thread, NULL)) {
//printf("\nrun osd server thread creation failed\n");
//}
# ifdef GY_OS_AMBA
if ( strcmp ( SystemSetting . enable_cloud , " Yes " ) = = 0 & & strstr ( SystemSetting . enable_python_file , " .py " ) ! = NULL )
{
if ( pthread_create ( & runpython_thread , NULL , start_run_python_thread , NULL ) )
{
printf ( " thread start run python failed \n " ) ;
}
}
# endif
}
else
bHttpServerThreadStart = 1 ;
@ -22441,6 +22349,7 @@ void stop_server()
pthread_mutex_destroy ( & mutex_remotesnap_image ) ; // Ken 2022-09-26
pthread_mutex_destroy ( & mutex_radar_json ) ;
pthread_mutex_destroy ( & mutex_tof_json ) ;
pthread_mutex_destroy ( & mutex_buffer ) ;
# endif
pthread_mutex_destroy ( & mutex_get_image ) ;
pthread_mutex_destroy ( & mutex_get_image_HD ) ;
@ -22497,8 +22406,6 @@ void stop_server()
pthread_mutex_destroy ( & mutex_write_pcd_data_L ) ;
pthread_mutex_destroy ( & mutex_write_pcd_data_M ) ;
pthread_mutex_destroy ( & mutex_write_pcd_data_S ) ;
pthread_mutex_destroy ( & buffer_mutex ) ;
# endif
# ifdef GY_OS_NOVA
pthread_mutex_destroy ( & mutex_pre_bbox_receive ) ;
@ -22566,7 +22473,6 @@ void write_to_enable_tracking(char *enable_tracking) {
cJSON_ReplaceItemInObject ( camera01 , " ptz_enable_tracking " , cJSON_CreateString ( enable_tracking ) ) ;
char * JsonString = cJSON_Print ( root ) ;
FILE * fp ;
@ -22734,33 +22640,88 @@ void move_file() {
}
}
# ifdef GY_OS_AMBA
void * start_run_python_thread ( void * pythonpath ) {
pthread_detach ( pthread_self ( ) ) ;
setPthreadName ( " run_python " ) ;
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 ;
}
else if ( strstr ( SystemSetting . enable_python_file , " .py " ) = = NULL ) {
break ;
}
usSleep ( 1000000 ) ;
char * value = get_enable_python_file_value ( ( const char * ) pythonpath ) ;
while ( python_check_webstatus = = 0 )
{
// python_check_webstatus = 0 Web close
// python_check_webstatus = 1 Web open
printf ( " [start_run_python_thread] Wait Web server run... %d \n " , python_check_webstatus ) ;
continue ;
}
// printf("[start_run_python_thread] Wait Web server run... %d \n", python_check_webstatus);
sleep ( 15 ) ; // sleep 15 sec,wait Web thread open
if ( value = = NULL ) {
printf ( " Failed to retrieve enable_python_file value \n " ) ;
pthread_exit ( NULL ) ;
}
// 抓取 python 檔案
if ( strstr ( value , " .py " ) ! = NULL ) {
// printf("enable_python_file is a Python file: %s\n", value);
const char * prefix = " lifile_liname= " ;
char pythonfile [ 256 ] ;
snprintf ( pythonfile , sizeof ( pythonfile ) , " %s%s " , prefix , value ) ;
runPython ( pythonfile ) ;
} else {
printf ( " enable_python_file is not a Python file: %s \n " , value ) ;
}
pthread_exit ( NULL ) ;
}
# endif
char * get_enable_python_file_value ( const char * filename ) {
FILE * file = fopen ( filename , " r " ) ;
if ( file = = NULL ) {
printf ( " Could not open file %s \n " , filename ) ;
return NULL ;
}
// 獲取文件大小
fseek ( file , 0 , SEEK_END ) ;
long file_size = ftell ( file ) ;
fseek ( file , 0 , SEEK_SET ) ;
// 讀取文件內容到內存中
char * file_content = ( char * ) malloc ( file_size + 1 ) ;
if ( file_content = = NULL ) {
printf ( " Memory allocation failed \n " ) ;
fclose ( file ) ;
return NULL ;
}
fread ( file_content , 1 , file_size , file ) ;
file_content [ file_size ] = ' \0 ' ;
fclose ( file ) ;
// 解析 JSON
cJSON * json = cJSON_Parse ( file_content ) ;
free ( file_content ) ;
if ( json = = NULL ) {
printf ( " Error parsing JSON file \n " ) ;
return NULL ;
}
// 獲取 system_setting 的值
cJSON * system_setting = cJSON_GetObjectItem ( json , " system_setting " ) ;
if ( system_setting = = NULL ) {
printf ( " system_setting not found in JSON \n " ) ;
cJSON_Delete ( json ) ;
return NULL ;
}
// 獲取 enable_python_file 的值
cJSON * enable_python_file = cJSON_GetObjectItem ( system_setting , " enable_python_file " ) ;
char * result = NULL ;
if ( enable_python_file ! = NULL & & cJSON_IsString ( enable_python_file ) ) {
result = strdup ( enable_python_file - > valuestring ) ; // 複製字符串值
}
// 清理 cJSON 對象
cJSON_Delete ( json ) ;
printf ( " [get_enable_python_file_value] result : %s \n " , result ) ;
// 返回結果
return result ;
}
void run_server ( int argc , char * * argv )
{
//以下沒有記憶體洩漏------------------------20210803
@ -22953,7 +22914,9 @@ void run_server(int argc, char **argv)
# ifdef GY_OS_AMBA
pthread_mutex_init ( & mutex_remotesnap_image , NULL ) ; // Ken 2022-09-26
pthread_mutex_init ( & mutex_radar_json , NULL ) ;
pthread_mutex_init ( & mutex_tof_json , NULL ) ;
pthread_mutex_init ( & mutex_tof_json , NULL ) ;
pthread_mutex_init ( & mutex_buffer , NULL ) ;
# endif
pthread_mutex_init ( & mutex_get_image , NULL ) ;
pthread_mutex_init ( & mutex_get_image_HD , NULL ) ;
@ -23006,8 +22969,6 @@ void run_server(int argc, char **argv)
pthread_mutex_init ( & mutex_write_pcd_data_L , NULL ) ;
pthread_mutex_init ( & mutex_write_pcd_data_M , NULL ) ;
pthread_mutex_init ( & mutex_write_pcd_data_S , NULL ) ;
pthread_mutex_init ( & buffer_mutex , NULL ) ;
# endif
# ifdef GY_OS_NOVA
pthread_mutex_init ( & mutex_pre_bbox_receive , NULL ) ;
@ -23063,7 +23024,7 @@ void run_server(int argc, char **argv)
pthread_t preload_http_thread ;
if ( pthread_create ( & preload_http_thread , 0 , run_preload_http_server_thread , 0 ) )
printf ( " preload http server thread creation failed \n " ) ;
error ( " preload http server thread creation failed \n " ) ;
}
@ -25968,11 +25929,22 @@ void run_server(int argc, char **argv)
strcpy ( SystemSetting . enable_python , " No " ) ;
new_data_write_to_config_file_flag = 1 ;
}
if ( enable_python_file )
if ( enable_python_file )
{
strcpy ( SystemSetting . enable_python_file , enable_python_file - > valuestring ) ;
// check 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 ) ;
if ( pthread_create ( & runpython_thread , NULL , start_run_python_thread , ( void * ) configPATH ) ! = 0 ) {
printf ( " check current runpython thread failed \n " ) ;
}
} else {
printf ( " File is not a Python file. \n " ) ;
}
}
else {
strcpy ( SystemSetting . enable_python_file , " No python running. " ) ;
new_data_write_to_config_file_flag = 1 ;
@ -27411,7 +27383,7 @@ void run_server(int argc, char **argv)
else {
cJSON_AddItemToObject ( system_setting , " enable_python " , cJSON_CreateString ( " No " ) ) ;
}
if ( enable_python_file ) {
cJSON_AddItemToObject ( system_setting , " enable_python_file " , cJSON_CreateString ( enable_python_file - > valuestring ) ) ;
}
@ -31803,104 +31775,6 @@ void file_management() {
# endif
}
# define COUNTER_FILE " / emmc / plugin / Aida_data / counters.dat"
int protected_counters = 0 ;
int g_last_counters [ MAX_EVENT_COUNTERS ] = { 0 } ;
void loadCounters ( ) {
# ifdef GY_OS_V_SERIES
# 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 ) | |
( ( featureType & FEATURE_HUM_DET ) = = FEATURE_HUM_DET & & ( featureType2 & FEATURE_AIAML ) = = FEATURE_AIAML & & strcmp ( WeightFileModeName , " mod003 " ) = = 0 ) | |
( ( featureType & FEATURE_HUM_DET ) = = FEATURE_HUM_DET & & ( featureType2 & FEATURE_AIMASK ) = = FEATURE_AIMASK & & ( strcmp ( WeightFileModeName , " mod001 " ) = = 0 | | strcmp ( WeightFileModeName , " mod002 " ) = = 0 ) ) | |
# 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 ( " \n COUNTER FILE error.#2 \n " ) ;
}
}
protected_counters = 0 ;
}
}
# endif
}
void saveCounters ( ) {
# ifdef GY_OS_V_SERIES
# 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 ) | |
( ( featureType & FEATURE_HUM_DET ) = = FEATURE_HUM_DET & & ( featureType2 & FEATURE_AIAML ) = = FEATURE_AIAML & & strcmp ( WeightFileModeName , " mod003 " ) = = 0 ) | |
( ( featureType & FEATURE_HUM_DET ) = = FEATURE_HUM_DET & & ( featureType2 & FEATURE_AIMASK ) = = FEATURE_AIMASK & & ( strcmp ( WeightFileModeName , " mod001 " ) = = 0 | | strcmp ( WeightFileModeName , " mod002 " ) = = 0 ) ) | |
# 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 ( " \n COUNTER FILE error. \n " ) ;
}
}
protected_counters = 0 ;
}
}
# endif
}
# ifdef GY_OS_NOVA
int get_pid_nova_driver ( ) {
char * temp = NULL ;
@ -31955,7 +31829,6 @@ void *RUN_NOVA_DETECTION(void *ptr) { //A11en
snprintf ( temp_msg , sizeof ( temp_msg ) , " free:%d,%s " , get_free_mem_data ( ) , " get_pid_nova_driver() == -1 " ) ;
write_to_logs_html ( temp_msg , " RUN NOVA DETECTION " , " CGI_REBOOT " , " Yes " ) ;
write_to_log_if_error ( temp_msg , " RUN NOVA DETECTION " , " CGI_REBOOT " ) ;
saveCounters ( ) ;
pthread_t auto_reboot_thread_id ;
if ( pthread_create ( & auto_reboot_thread_id , 0 , auto_reboot , NULL ) )