utils.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 João Borrego
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
25 // C libraries
26 #include <ctype.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <unistd.h>
30 
31 // C++ libraries
32 
33 // I/O streams
34 #include <iostream>
35 // File system
36 #include <boost/filesystem.hpp>
37 // Random
38 #include <random>
39 
40 // Custom debug utilities
41 #include "debug.hh"
42 
43 // Definitions
44 
45 // Default arg values
46 
48 #define ARG_SCENES_DEFAULT 10
49 #define ARG_START_DEFAULT 0
51 #define ARG_IMGS_DIR_DEFAULT "imgs"
53 #define ARG_DATASET_DIR_DEFAULT "dataset"
55 
56 // Function headers
57 
60 const std::string getUsage(const char* argv_0);
61 
69 void parseArgs(
70  int argc,
71  char** argv,
72  unsigned int & scenes,
73  unsigned int & start,
74  std::string & imgs_dir,
75  std::string & dataset_dir);
76 
80 bool createDirectory(std::string & path);
81 
89 int getRandomInt(int min, int max);
90 
98 double getRandomDouble(double min, double max);
99 
101 void shuffleIntVector(std::vector<int> & vector);
int getRandomInt(int min, int max)
Get a random integer in a given interval.
Definition: dr_example.cc:86
const std::string getUsage(const char *argv_0)
Returns string with program usage information.
Definition: utils.cc:27
double getRandomDouble(double min, double max)
Get a random double in a given interval.
Definition: dr_example.cc:93
Debug utilities.
bool createDirectory(std::string &path)
Creates the directory given its path.
Definition: utils.cc:83
void parseArgs(int argc, char **argv, unsigned int &scenes, unsigned int &start, std::string &imgs_dir, std::string &dataset_dir)
Parses command-line arguments.
Definition: utils.cc:38
void shuffleIntVector(std::vector< int > &vector)
Randomly shuffles an integer vector.
Definition: utils.cc:125