Friction Ridge Image and Features
API for participating in NIST's Friction Ridge Image and Features Technology Evaluations.
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1/*
2 * This software was developed at the National Institute of Standards and
3 * Technology (NIST) by employees of the Federal Government in the course
4 * of their official duties. Pursuant to title 17 Section 105 of the
5 * United States Code, this software is not subject to copyright protection
6 * and is in the public domain. NIST assumes no responsibility whatsoever for
7 * its use by other parties, and makes no guarantees, expressed or implied,
8 * about its quality, reliability, or any other characteristic.
9 */
10
11#ifndef FRIF_COMMON_H_
12#define FRIF_COMMON_H_
13
14#include <compare>
15#include <cstddef>
16#include <cstdint>
17#include <filesystem>
18#include <memory>
19#include <optional>
20#include <string>
21#include <tuple>
22#include <type_traits>
23#include <vector>
24
25namespace FRIF
26{
29 {
31 enum class Result
32 {
34 Success = 0,
37 };
38
45 std::optional<std::string> message{};
46
51 explicit operator bool()
52 const
53 noexcept;
54 };
55
57 struct Image
58 {
60 enum class BitsPerPixel
61 {
62 Eight = 8,
63 Sixteen = 16,
64 TwentyFour = 24,
65 FortyEight = 48
66 };
68
73 enum class BitsPerChannel
74 {
75 Eight = 8,
76 Sixteen = 16
77 };
79
80 enum class Colorspace
81 {
83 Grayscale,
88 RGB
89 };
90
92
127 Image(
128 const uint8_t identifier,
129 const uint16_t width,
130 const uint16_t height,
131 const uint16_t ppi,
132 const Colorspace colorspace,
133 const BitsPerChannel bpc,
134 const BitsPerPixel bpp,
135 const std::vector<std::byte> &pixels);
136
145 void
146 sanityCheck()
147 const;
148
153 uint8_t identifier{};
155 uint16_t width{};
157 uint16_t height{};
159 uint16_t ppi{};
161 Colorspace colorspace{Colorspace::Grayscale};
163 BitsPerChannel bpc{BitsPerChannel::Eight};
165 BitsPerPixel bpp{BitsPerPixel::Eight};
187 std::vector<std::byte> pixels{};
188 };
189
192 {
194 uint32_t x{};
196 uint32_t y{};
197
208 const uint32_t x = {},
209 const uint32_t y = {});
210
211 auto operator<=>(const Coordinate&) const;
212 bool operator==(const Coordinate&) const;
213 };
214
216 using Segment = std::tuple<Coordinate, Coordinate>;
217
220 {
223 {
225 uint16_t owner{};
227 std::optional<uint16_t> algorithm{};
228 };
229
234 std::optional<std::string> marketing{};
242 std::optional<CBEFFIdentifier> cbeff{};
243 };
244
245 /*
246 * API versioning.
247 *
248 * NIST code will extern the version number symbols. Participant code
249 * shall compile them into their core library.
250 */
251 #ifdef NIST_EXTERN_FRIF_API_VERSION
253 extern uint16_t API_MAJOR_VERSION;
255 extern uint16_t API_MINOR_VERSION;
257 extern uint16_t API_PATCH_VERSION;
258 #else /* NIST_EXTERN_API_VERSION */
260 uint16_t API_MAJOR_VERSION{0};
262 uint16_t API_MINOR_VERSION{0};
264 uint16_t API_PATCH_VERSION{1};
265 #endif /* NIST_FRIF_EXTERN_API_VERSION */
266
267 /*
268 * Ensure that std::byte is exactly 8 bits, such that reinterpret_casts
269 * may be safely used.
270 */
271 static_assert(std::is_same_v<std::underlying_type_t<std::byte>,
272 uint8_t>, "std::byte not represented as unsigned 8 bit type");
273}
274
275#endif /* FRIF_COMMON_H_ */
TE input/output types.
Definition common.h:26
uint16_t API_MINOR_VERSION
API minor version number.
Definition common.h:262
std::tuple< Coordinate, Coordinate > Segment
Line segment.
Definition common.h:216
uint16_t API_PATCH_VERSION
API patch version number.
Definition common.h:264
uint16_t API_MAJOR_VERSION
API major version number.
Definition common.h:260
Pixel location in an image.
Definition common.h:192
bool operator==(const Coordinate &) const
auto operator<=>(const Coordinate &) const
Data and metadata for an image.
Definition common.h:58
BitsPerPixel
Number of bits comprising a single image pixel.
Definition common.h:61
BitsPerChannel
Number of bits comprising a single color channel of a single pixel.
Definition common.h:74
CBEFF information registered with and assigned by IBIA.
Definition common.h:223
Identifying details about algorithm components for documentation.
Definition common.h:220
Information about the result of calling a FRIF API function.
Definition common.h:29
Result result
The result of the operation.
Definition common.h:40
Result
Possible outcomes when performing operations.
Definition common.h:32
@ Success
Successfully performed operation.
@ Failure
Failed to perform operation.
std::optional< std::string > message
Information about the result.
Definition common.h:45