utils.hh File Reference

Generic utilities for scene generation example. More...

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <iostream>
#include <boost/filesystem.hpp>
#include <random>
#include "debug.hh"

Go to the source code of this file.

Macros

#define ARG_SCENES_DEFAULT   10
 Default number of scenes. More...
 
#define ARG_START_DEFAULT   0
 Default index of the first scene. More...
 
#define ARG_IMGS_DIR_DEFAULT   "imgs"
 Default image directory. More...
 
#define ARG_DATASET_DIR_DEFAULT   "dataset"
 Default dataset directory. More...
 

Functions

const std::string getUsage (const char *argv_0)
 Returns string with program usage information. More...
 
void parseArgs (int argc, char **argv, unsigned int &scenes, unsigned int &start, std::string &imgs_dir, std::string &dataset_dir)
 Parses command-line arguments. More...
 
bool createDirectory (std::string &path)
 Creates the directory given its path. More...
 
int getRandomInt (int min, int max)
 Get a random integer in a given interval. More...
 
double getRandomDouble (double min, double max)
 Get a random double in a given interval. More...
 
void shuffleIntVector (std::vector< int > &vector)
 Randomly shuffles an integer vector. More...
 

Detailed Description

Generic utilities for scene generation example.

Author
João Borrego : jsbruglie
Rui Figueiredo : ruipimentelfigueiredo

Macro Definition Documentation

#define ARG_DATASET_DIR_DEFAULT   "dataset"

Default dataset directory.

#define ARG_IMGS_DIR_DEFAULT   "imgs"

Default image directory.

#define ARG_SCENES_DEFAULT   10

Default number of scenes.

#define ARG_START_DEFAULT   0

Default index of the first scene.

Function Documentation

bool createDirectory ( std::string &  path)

Creates the directory given its path.

Parameters
pathThe path string
Returns
true on success
double getRandomDouble ( double  min,
double  max 
)

Get a random double in a given interval.

Value is sampled from uniform distribution

Parameters
minInterval lower bound
maxInterval upper bound
Returns
Random double
int getRandomInt ( int  min,
int  max 
)

Get a random integer in a given interval.

Value is sampled from uniform distribution

Parameters
minInterval lower bound
maxInterval upper bound
Returns
Random integer
const std::string getUsage ( const char *  argv_0)

Returns string with program usage information.

Returns
Program usage
void parseArgs ( int  argc,
char **  argv,
unsigned int &  scenes,
unsigned int &  start,
std::string &  imgs_dir,
std::string &  dataset_dir 
)

Parses command-line arguments.

Parameters
argcArgument count
argvArgument values
scenesNumber of scenes to generate
startIndex of the first scene
imgs_dirImage output directory
dataset_dirDataset annotations output directory
void shuffleIntVector ( std::vector< int > &  vector)

Randomly shuffles an integer vector.