Darknet/YOLO v3.0-177-gfa2353b
Object Detection Framework
 
Loading...
Searching...
No Matches
utils.hpp File Reference
Include dependency graph for utils.hpp:
This graph shows which files directly or indirectly include this file:

Macros

#define DARKNET_LOC   __FILE__, __func__, __LINE__
 
#define max_val_cmp(a, b)   (((a) > (b)) ? (a) : (b))
 
#define min_val_cmp(a, b)   (((a) < (b)) ? (a) : (b))
 
#define xcalloc(m, s)   xcalloc_location(m, s, DARKNET_LOC)
 
#define xmalloc(s)   xmalloc_location(s, DARKNET_LOC)
 
#define xrealloc(p, s)   xrealloc_location(p, s, DARKNET_LOC)
 

Functions

int alphanum_to_int (char c)
 
const char * basecfg (const char *cfgfile)
 
boxabs box_to_boxabs (const Darknet::Box *b, const int img_w, const int img_h, const int bounds_check)
 
void calloc_error (const size_t size, const char *const filename, const char *const funcname, const int line)
 
int check_array_is_inf (float *arr, int size)
 
int check_array_is_nan (float *arr, int size)
 
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.
 
float dist_array (float *a, float *b, int n, int sub)
 
double double_rand (void)
 
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)
 
bool is_live_stream (const char *path)
 
float mag_array (float *a, int n)
 
float mag_array_skip (float *a, int n, int *indices_to_skip)
 
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)
 
int max_int_index (int *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)
 
float ** one_hot_encode (float *a, int n, int k)
 
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)
 
int rand_int_fast (int min, int max)
 
float rand_normal ()
 
float rand_precalc_random (float min, float max, float random_part)
 
float rand_scale (float s)
 
size_t rand_size_t ()
 
float rand_uniform (float min, float max)
 
float rand_uniform_strong (float min, float max)
 
float random_float ()
 
float random_float_fast ()
 
unsigned int random_gen (unsigned int min=0, unsigned int max=std::numeric_limits< unsigned int >::max())
 
unsigned int random_gen_fast (void)
 
int * random_index_order (int min, int max)
 
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)
 
int sample_array (float *a, int n)
 
int sample_array_custom (float *a, int n)
 
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)
 
unsigned int uint_rand (unsigned int less_than)
 
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

◆ DARKNET_LOC

#define DARKNET_LOC   __FILE__, __func__, __LINE__

◆ max_val_cmp

#define max_val_cmp (   a,
 
)    (((a) > (b)) ? (a) : (b))

◆ min_val_cmp

#define min_val_cmp (   a,
 
)    (((a) < (b)) ? (a) : (b))

◆ xcalloc

#define xcalloc (   m,
 
)    xcalloc_location(m, s, DARKNET_LOC)

◆ xmalloc

#define xmalloc (   s)    xmalloc_location(s, DARKNET_LOC)

◆ xrealloc

#define xrealloc (   p,
 
)    xrealloc_location(p, s, DARKNET_LOC)

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:

◆ box_to_boxabs()

boxabs box_to_boxabs ( const Darknet::Box b,
const int  img_w,
const int  img_h,
const int  bounds_check 
)

◆ 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:

◆ check_array_is_inf()

int check_array_is_inf ( float *  arr,
int  size 
)

◆ check_array_is_nan()

int check_array_is_nan ( float *  arr,
int  size 
)

◆ 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:

◆ dist_array()

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

◆ double_rand()

double double_rand ( void  )
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.

◆ 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)

◆ is_live_stream()

bool is_live_stream ( const char *  path)

◆ mag_array()

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

◆ mag_array_skip()

float mag_array_skip ( float *  a,
int  n,
int *  indices_to_skip 
)

◆ 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:

◆ max_int_index()

int max_int_index ( int *  a,
int  n 
)

◆ 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:

◆ one_hot_encode()

float ** one_hot_encode ( float *  a,
int  n,
int  k 
)

◆ 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 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rand_int_fast()

int rand_int_fast ( int  min,
int  max 
)
Here is the call 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_size_t()

size_t rand_size_t ( )
Here is the call graph for this function:

◆ rand_uniform()

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

◆ rand_uniform_strong()

float rand_uniform_strong ( float  min,
float  max 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ random_float()

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

◆ random_float_fast()

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

◆ random_gen()

unsigned int random_gen ( unsigned int  min = 0,
unsigned int  max = std::numeric_limits< unsigned int >::max() 
)
Here is the caller graph for this function:

◆ random_gen_fast()

unsigned int random_gen_fast ( void  )
Todo:
Is this really faster than using the C++11 rng? Do we gain something by keeping this?
Here is the caller graph for this function:

◆ random_index_order()

int * random_index_order ( int  min,
int  max 
)

◆ 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:

◆ sample_array()

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

◆ sample_array_custom()

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

◆ scale_array()

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

◆ sec()

float sec ( clock_t  clocks)
Here is the caller graph for this function:

◆ 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 
)

◆ 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 
)

◆ uint_rand()

unsigned int uint_rand ( unsigned int  less_than)
Here is the call graph for this function:

◆ 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: