Darknet/YOLO v4.0-11-gbfab9ec
Object Detection Framework
 
Loading...
Searching...
No Matches
utils.cpp File Reference
Include dependency graph for utils.cpp:

Macros

#define _CRT_RAND_S
 
#define MAX_STACK_FRAMES   50
 

Functions

int alphanum_to_int (char c)
 
const char * basecfg (const char *cfgfile)
 
void calloc_error (const size_t size, const char *const filename, const char *const funcname, const int line)
 
float constrain (float min, float max, float a)
 
char * copy_string (char *s)
 
int count_fields (char *line)
 
unsigned long custom_hash (char *str)
 
void darknet_fatal_error (const char *const filename, const char *const funcname, const int line, const char *const msg,...)
 Calling this function ends the application. This function will never return control back to the caller.
 
void del_arg (int argc, char **argv, int index)
 
float dist_array (float *a, float *b, int n, int sub)
 
char * fgetl (FILE *fp)
 
void file_error (const char *const s, const char *const filename, const char *const funcname, const int line)
 
int find_arg (int argc, char *argv[], const char *const arg)
 
const char * find_char_arg (int argc, char **argv, const char *arg, const char *def)
 
float find_float_arg (int argc, char **argv, const char *const arg, float def)
 
int find_int_arg (int argc, char **argv, const char *const arg, int def)
 
void find_replace (const char *str, char *orig, char *rep, char *output)
 
void free_ptrs (void **ptrs, int n)
 This is part of the original C API.
 
int int_index (int *a, int val, int n)
 
char int_to_alphanum (int i)
 
void log_backtrace ()
 
float mag_array (float *a, int n)
 
int make_directory (char *path, int mode)
 
void malloc_error (const size_t size, const char *const filename, const char *const funcname, const int line)
 
int max_index (float *a, int n)
 
float mean_array (float *a, int n)
 
void mean_arrays (float **a, int n, int els, float *avg)
 
float mse_array (float *a, int n)
 
void normalize_array (float *a, int n)
 
listparse_csv_line (char *line)
 
float * parse_fields (char *line, int n)
 
void print_statistics (float *a, int n)
 
int rand_int (int min, int max)
 
float rand_normal ()
 
float rand_precalc_random (float min, float max, float random_part)
 
float rand_scale (float s)
 
float rand_uniform (float min, float max)
 
float rand_uniform_strong (float min, float max)
 
float random_float ()
 
unsigned int random_gen (unsigned int min, unsigned int max)
 The "min" and "max" values are inclusive. For example, random_gen(1, 6) can return 6 possible values.
 
void read_all (int fd, char *buffer, size_t bytes)
 
int read_all_fail (int fd, char *buffer, size_t bytes)
 
int read_int (int fd)
 
int * read_map (const char *filename)
 
void realloc_error (const size_t size, const char *const filename, const char *const funcname, const int line)
 
void replace_image_to_label (const char *input_path, char *output_path)
 
void scale_array (float *a, int n, float s)
 
float sec (clock_t clocks)
 
void shuffle (void *arr, size_t n, size_t size)
 
const char * size_to_IEC_string (const size_t size)
 Convert the given size to a human-readable string. This uses 1024 as a divider, so 1 KiB == 1024 bytes.
 
void sorta_shuffle (void *arr, size_t n, size_t size, size_t sections)
 
listsplit_str (char *s, char delim)
 
void strip (char *s)
 
void strip_args (char *s)
 
void strip_char (char *s, char bad)
 
float sum_array (float *a, int n)
 
void top_k (float *a, int n, int k, int *index)
 
int top_max_index (float *a, int n, int k)
 
void translate_array (float *a, int n, float s)
 
float variance_array (float *a, int n)
 
double what_time_is_it_now ()
 Convert the current time – as seconds – into a double.
 
void write_all (int fd, char *buffer, size_t bytes)
 
int write_all_fail (int fd, char *buffer, size_t bytes)
 
void write_int (int fd, int n)
 
void * xcalloc_location (const size_t nmemb, const size_t size, const char *const filename, const char *const funcname, const int line)
 
void * xmalloc_location (const size_t size, const char *const filename, const char *const funcname, const int line)
 
void * xrealloc_location (void *ptr, const size_t size, const char *const filename, const char *const funcname, const int line)
 

Macro Definition Documentation

◆ _CRT_RAND_S

#define _CRT_RAND_S

◆ MAX_STACK_FRAMES

#define MAX_STACK_FRAMES   50

Function Documentation

◆ alphanum_to_int()

int alphanum_to_int ( char  c)

◆ basecfg()

const char * basecfg ( const char *  cfgfile)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calloc_error()

void calloc_error ( const size_t  size,
const char *const  filename,
const char *const  funcname,
const int  line 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ constrain()

float constrain ( float  min,
float  max,
float  a 
)
Here is the caller graph for this function:

◆ copy_string()

char * copy_string ( char *  s)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ count_fields()

int count_fields ( char *  line)

◆ custom_hash()

unsigned long custom_hash ( char *  str)
Here is the caller graph for this function:

◆ darknet_fatal_error()

void darknet_fatal_error ( const char *const  filename,
const char *const  funcname,
const int  line,
const char *const  msg,
  ... 
)

Calling this function ends the application. This function will never return control back to the caller.

See also
DARKNET_LOC
Here is the call graph for this function:

◆ del_arg()

void del_arg ( int  argc,
char **  argv,
int  index 
)
Here is the caller graph for this function:

◆ dist_array()

float dist_array ( float *  a,
float *  b,
int  n,
int  sub 
)
Here is the caller graph for this function:

◆ fgetl()

char * fgetl ( FILE *  fp)
Here is the caller graph for this function:

◆ file_error()

void file_error ( const char *const  s,
const char *const  filename,
const char *const  funcname,
const int  line 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_arg()

int find_arg ( int  argc,
char *  argv[],
const char *const  arg 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_char_arg()

const char * find_char_arg ( int  argc,
char **  argv,
const char *  arg,
const char *  def 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_float_arg()

float find_float_arg ( int  argc,
char **  argv,
const char *const  arg,
float  def 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_int_arg()

int find_int_arg ( int  argc,
char **  argv,
const char *const  arg,
int  def 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_replace()

void find_replace ( const char *  str,
char *  orig,
char *  rep,
char *  output 
)

◆ free_ptrs()

void free_ptrs ( void **  ptrs,
int  n 
)

This is part of the original C API.

Here is the caller graph for this function:

◆ int_index()

int int_index ( int *  a,
int  val,
int  n 
)
Here is the caller graph for this function:

◆ int_to_alphanum()

char int_to_alphanum ( int  i)

◆ log_backtrace()

void log_backtrace ( )
Here is the caller graph for this function:

◆ mag_array()

float mag_array ( float *  a,
int  n 
)
Here is the caller graph for this function:

◆ make_directory()

int make_directory ( char *  path,
int  mode 
)
Here is the caller graph for this function:

◆ malloc_error()

void malloc_error ( const size_t  size,
const char *const  filename,
const char *const  funcname,
const int  line 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ max_index()

int max_index ( float *  a,
int  n 
)
Here is the caller graph for this function:

◆ mean_array()

float mean_array ( float *  a,
int  n 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mean_arrays()

void mean_arrays ( float **  a,
int  n,
int  els,
float *  avg 
)

◆ mse_array()

float mse_array ( float *  a,
int  n 
)
Here is the caller graph for this function:

◆ normalize_array()

void normalize_array ( float *  a,
int  n 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_csv_line()

list * parse_csv_line ( char *  line)
Here is the call graph for this function:

◆ parse_fields()

float * parse_fields ( char *  line,
int  n 
)

◆ print_statistics()

void print_statistics ( float *  a,
int  n 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rand_int()

int rand_int ( int  min,
int  max 
)
Todo:
Isn't this the same thing as random_gen()?
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rand_normal()

float rand_normal ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rand_precalc_random()

float rand_precalc_random ( float  min,
float  max,
float  random_part 
)
Here is the caller graph for this function:

◆ rand_scale()

float rand_scale ( float  s)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rand_uniform()

float rand_uniform ( float  min,
float  max 
)
Todo:
Re-write this using std::uniform_real_distribution
Here is the caller graph for this function:

◆ rand_uniform_strong()

float rand_uniform_strong ( float  min,
float  max 
)
Todo:
Re-write this using std::uniform_real_distribution
Here is the call graph for this function:
Here is the caller graph for this function:

◆ random_float()

float random_float ( )
Todo:
Re-write this using std::uniform_real_distribution
Here is the caller graph for this function:

◆ random_gen()

unsigned int random_gen ( unsigned int  min,
unsigned int  max 
)

The "min" and "max" values are inclusive. For example, random_gen(1, 6) can return 6 possible values.

Here is the caller graph for this function:

◆ read_all()

void read_all ( int  fd,
char *  buffer,
size_t  bytes 
)
Here is the call graph for this function:

◆ read_all_fail()

int read_all_fail ( int  fd,
char *  buffer,
size_t  bytes 
)

◆ read_int()

int read_int ( int  fd)

◆ read_map()

int * read_map ( const char *  filename)
Todo:
what is this "map" file that we're reading in?
Todo:
the while loop reallocs the array at every iteration, this needs to be refactored!
Here is the call graph for this function:
Here is the caller graph for this function:

◆ realloc_error()

void realloc_error ( const size_t  size,
const char *const  filename,
const char *const  funcname,
const int  line 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ replace_image_to_label()

void replace_image_to_label ( const char *  input_path,
char *  output_path 
)
Here is the caller graph for this function:

◆ scale_array()

void scale_array ( float *  a,
int  n,
float  s 
)

◆ sec()

float sec ( clock_t  clocks)

◆ shuffle()

void shuffle ( void *  arr,
size_t  n,
size_t  size 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ size_to_IEC_string()

const char * size_to_IEC_string ( const size_t  size)

Convert the given size to a human-readable string. This uses 1024 as a divider, so 1 KiB == 1024 bytes.

Todo:
not thread safe
Here is the caller graph for this function:

◆ sorta_shuffle()

void sorta_shuffle ( void *  arr,
size_t  n,
size_t  size,
size_t  sections 
)
Here is the call graph for this function:

◆ split_str()

list * split_str ( char *  s,
char  delim 
)
Here is the call graph for this function:

◆ strip()

void strip ( char *  s)
Here is the caller graph for this function:

◆ strip_args()

void strip_args ( char *  s)

◆ strip_char()

void strip_char ( char *  s,
char  bad 
)

◆ sum_array()

float sum_array ( float *  a,
int  n 
)
Here is the caller graph for this function:

◆ top_k()

void top_k ( float *  a,
int  n,
int  k,
int *  index 
)
Here is the caller graph for this function:

◆ top_max_index()

int top_max_index ( float *  a,
int  n,
int  k 
)
Here is the call graph for this function:

◆ translate_array()

void translate_array ( float *  a,
int  n,
float  s 
)

◆ variance_array()

float variance_array ( float *  a,
int  n 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ what_time_is_it_now()

double what_time_is_it_now ( )

Convert the current time – as seconds – into a double.

Precision is microseconds (10^-6). It takes 1000 microseconds to make 1 millisecond.

Here is the caller graph for this function:

◆ write_all()

void write_all ( int  fd,
char *  buffer,
size_t  bytes 
)
Here is the call graph for this function:

◆ write_all_fail()

int write_all_fail ( int  fd,
char *  buffer,
size_t  bytes 
)

◆ write_int()

void write_int ( int  fd,
int  n 
)
Here is the call graph for this function:

◆ xcalloc_location()

void * xcalloc_location ( const size_t  nmemb,
const size_t  size,
const char *const  filename,
const char *const  funcname,
const int  line 
)
Here is the call graph for this function:

◆ xmalloc_location()

void * xmalloc_location ( const size_t  size,
const char *const  filename,
const char *const  funcname,
const int  line 
)
Here is the call graph for this function:

◆ xrealloc_location()

void * xrealloc_location ( void *  ptr,
const size_t  size,
const char *const  filename,
const char *const  funcname,
const int  line 
)
Here is the call graph for this function: