vivalib library
Concurrent C++11 OpenCV library for Computer Vision applications
utils.h
1 /**************************************************************************************************
2  **************************************************************************************************
3 
4  BSD 3-Clause License (https://www.tldrlegal.com/l/bsd3)
5 
6  Copyright (c) 2015 Andrés Solís Montero <http://www.solism.ca>, All rights reserved.
7 
8 
9  Redistribution and use in source and binary forms, with or without modification,
10  are permitted provided that the following conditions are met:
11 
12  1. Redistributions of source code must retain the above copyright notice,
13  this list of conditions and the following disclaimer.
14  2. Redistributions in binary form must reproduce the above copyright notice,
15  this list of conditions and the following disclaimer in the documentation
16  and/or other materials provided with the distribution.
17  3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30  OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32  **************************************************************************************************
33  **************************************************************************************************/
34 #ifndef __viva__utils__
35 #define __viva__utils__
36 
37 
38 #include "opencv2/highgui/highgui.hpp"
39 #include "opencv2/imgproc/imgproc.hpp"
40 #include <iostream>
41 #include <sstream>
42 #include <string>
43 #include <sys/stat.h>
44 #include <sys/types.h>
45 
46 #ifdef _MSC_VER
47  #include "direntVS.h"
48  #include <time.h>
49 #else
50  #include <dirent.h>
51 #endif
52 
53 using namespace std;
54 using namespace cv;
55 
56 namespace viva
57 {
63  struct Keys
64  {
65  const static int ESC;
66  const static int TAB;
67  const static int SPACE;
68  const static int NONE;
69  const static int c;
70  };
71 
72 
76  class Files
77  {
78  public:
79 
80  const static string PATH_SEPARATOR;
81 
85  static string tmpFilenameInFolder(const string &folder = "",
86  const string &ext = ".jpg");
87 
88  static Rect bestSquareFrom(Rect &rectangle);
89 
90  static void saveSquaredIn(const Mat &image,
91  string folder,
92  int side = 200);
93 
97  static void listdir(const string &dirname, vector<string> &files, bool returnPaths = true);
101  static void listImages(const string &dirname, vector<string> &files, bool returnPaths = true);
102 
106  static bool isDir(const string &fullpath);
110  static bool isFile(const string &fullpath);
114  static void makeDir(const string &fullpath);
118  static bool exists(const string &fullpath);
119 
123  static void getExtension(const string &filename, string &extension);
127  static void getFilename(const string &path, string &filename);
131  static void getBasename(const string &path, string &base);
132  };
133 
134 
135 
136 
137 }
138 
139 #endif /* defined(__viva__utils__) */
140 
Definition: utils.h:76
Definition: channel.h:45
Definition: utils.h:63