-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathutils.h
110 lines (97 loc) · 3.02 KB
/
utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**
* @file utils.h
*
* @section LICENSE
*
* The MIT License
*
* @copyright Copyright (c) 2024 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#pragma once
#include <time.h>
#include <cstdint>
#include <string>
#include <vector>
namespace VCL {
typedef std::vector<unsigned char> cv_buffer;
/* *********************** */
/* ENUMS */
/* *********************** */
/**
* Determines what kind of compression to use
*/
enum class CompressionType {
NOCOMPRESSION = 0,
GZIP = 1,
ZSTD = 2,
LZ4 = 3,
BLOSC = 4,
BLZ4 = 5,
BLZ4HC = 6,
BSNAPPY = 7,
BZLIB = 8,
BZSTD = 9,
RLE = 10
};
/* *********************** */
/* ENUMS */
/* *********************** */
/**
* Determines what kind of format to use
*/
enum class Format { NONE_IMAGE = 0, JPG = 1, PNG = 2, TDB = 3, BIN = 4 };
static const struct init_rand_t {
init_rand_t() { srand(time(NULL)); }
} init_rand;
uint64_t rdrand();
bool supports_rdrand();
uint64_t get_uint64();
/* a util function to covert the enum format value to string*/
std::string format_to_string(VCL::Format format);
/**
* Save the image directly as a blob file without the need to re-encoding it
* with cv::imwrite
*/
void save_image(const std::string &_fullpath, const std::string &blob);
/**
* Gets the extension of a filename
*
* @param filename The path to the file
* @return The string containing the extension
*/
std::string get_extension(const std::string &filename);
/**
* Checks to see if the file name is unique by attempting
* to open the file
*
* @param name Full path to the theoretically unique ID
* @return True if the file does not exist, false if it does
*/
bool exists(const std::string &name);
std::string create_unique(const std::string &path,
const std::string &extension);
/**
* Determines what is the format of the input blob image using the signature
* value of PNG and JPG format
*/
Format read_image_format(void *buffer, long size);
}; // namespace VCL