@ -21,12 +21,15 @@ basicThread()
// validate() compares it with the database copy: must start defined
memset ( & m_sYOLOFilterData , 0 , sizeof ( YOLO_FILTER_DATA ) ) ;
m_pNET = NULL ;
m_nW = m_nH = m_nC = 0 ;
}
kernelEventFilterYOLO : : ~ kernelEventFilterYOLO ( )
{
waitThreadEnd ( true ) ;
if ( m_pNET ) {
free_network_ptr ( m_pNET ) ;
m_pNET = NULL ;
} ;
}
@ -54,8 +57,27 @@ bool kernelEventFilterYOLO::validateTarget(uint32_t DevID, TARGET_DATA * ptr){
}
bool kernelEventFilterYOLO : : initFilter ( ) {
if ( ! fileExist ( m_sYOLOFilterData . config_path ) ) return false ;
if ( ! fileExist ( m_sYOLOFilterData . weights_path ) ) return false ;
// The settings must be loaded first: m_sYOLOFilterData was still all zero here, so fileExist("")
// failed and initFilter() could never succeed
if ( ! validate ( ) ) {
LOG_ERROR ( " No YOLO filter settings (getYOLOFilterData returned nothing) " ) ;
return false ;
} ;
char tB [ 160 ] ; // LOG_ERROR formats into a 256-byte buffer (with file and function name): keep it short
if ( ! fileExist ( m_sYOLOFilterData . config_path ) ) {
snprintf ( tB , sizeof ( tB ) , " YOLO config not found: %.120s " , m_sYOLOFilterData . config_path ) ;
LOG_ERROR ( tB ) ;
return false ;
} ;
if ( ! fileExist ( m_sYOLOFilterData . weights_path ) ) {
snprintf ( tB , sizeof ( tB ) , " YOLO weights not found: %.120s " , m_sYOLOFilterData . weights_path ) ;
LOG_ERROR ( tB ) ;
return false ;
} ;
if ( m_pNET ) {
free_network_ptr ( m_pNET ) ; // initFilter() called again
m_pNET = NULL ;
} ;
if ( m_sYOLOFilterData . batch ) {
m_pNET = load_network_custom ( m_sYOLOFilterData . config_path , m_sYOLOFilterData . weights_path , m_sYOLOFilterData . clear , m_sYOLOFilterData . batch ) ;
} else {
@ -63,8 +85,11 @@ bool kernelEventFilterYOLO::initFilter(){
} ;
if ( m_pNET ) {
darknet_network_dimensions ( m_pNET , & m_nW , & m_nH , & m_nC ) ;
snprintf ( tB , sizeof ( tB ) , " YOLO network loaded: %dx%dx%d " , m_nW , m_nH , m_nC ) ;
LOG ( tB ) ;
return true ;
}
LOG_ERROR ( " Darknet could not load the YOLO network " ) ;
return false ;
}