Friction Ridge Image and Features Technology Evaluations
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 : uint8_t
61 {
62 Eight = 8,
63 Sixteen = 16,
64 TwentyFour = 24,
65 FortyEight = 48
66 };
68
82 static BitsPerPixel
83 toBitsPerPixel(
84 const std::underlying_type_t<BitsPerPixel> i);
85
90 enum class BitsPerChannel : uint8_t
91 {
92 Eight = 8,
93 Sixteen = 16
94 };
96
110 static BitsPerChannel
111 toBitsPerChannel(
112 const std::underlying_type_t<BitsPerChannel> i);
113
114 enum class Colorspace
115 {
117 Grayscale,
122 RGB
123 };
124
126
161 Image(
162 const uint8_t identifier,
163 const uint16_t width,
164 const uint16_t height,
165 const uint16_t ppi,
166 const Colorspace colorspace,
167 const BitsPerChannel bpc,
168 const BitsPerPixel bpp,
169 const std::vector<std::byte> &pixels);
170
179 void
180 sanityCheck()
181 const;
182
187 uint8_t identifier{};
189 uint16_t width{};
191 uint16_t height{};
193 uint16_t ppi{};
195 Colorspace colorspace{Colorspace::Grayscale};
197 BitsPerChannel bpc{BitsPerChannel::Eight};
199 BitsPerPixel bpp{BitsPerPixel::Eight};
221 std::vector<std::byte> pixels{};
222 };
223
226 {
228 uint32_t x{};
230 uint32_t y{};
231
242 const uint32_t x = {},
243 const uint32_t y = {});
244
245 auto operator<=>(const Coordinate&) const;
246 bool operator==(const Coordinate&) const;
247 };
248
250 using Segment = std::tuple<Coordinate, Coordinate>;
251
254 {
257 {
259 uint16_t owner{};
261 std::optional<uint16_t> algorithm{};
262
263 auto operator<=>(const CBEFFIdentifier&) const;
264 bool operator==(const CBEFFIdentifier&) const;
265 };
266
271 std::optional<std::string> marketing{};
279 std::optional<CBEFFIdentifier> cbeff{};
280
281 auto operator<=>(const ProductIdentifier&) const;
282 bool operator==(const ProductIdentifier&) const;
283 };
284
285 /*
286 * API versioning.
287 *
288 * NIST code will extern the version number symbols. Participant code
289 * shall compile them into their core library.
290 */
291 #ifdef NIST_EXTERN_FRIFTE_API_VERSION
293 extern uint16_t API_MAJOR_VERSION;
295 extern uint16_t API_MINOR_VERSION;
297 extern uint16_t API_PATCH_VERSION;
298 #else /* NIST_EXTERN_FRIFTE_API_VERSION */
300 uint16_t API_MAJOR_VERSION{1};
302 uint16_t API_MINOR_VERSION{2};
304 uint16_t API_PATCH_VERSION{0};
305 #endif /* NIST_EXTERN_FRIFTE_API_VERSION */
306
307 /*
308 * Ensure that std::byte is exactly 8 bits, such that reinterpret_casts
309 * may be safely used.
310 */
311 static_assert(std::is_same_v<std::underlying_type_t<std::byte>,
312 uint8_t>, "std::byte not represented as unsigned 8 bit type");
313}
314
315#endif /* FRIF_COMMON_H_ */
TE input/output types.
Definition common.h:26
uint16_t API_MINOR_VERSION
API minor version number.
Definition common.h:302
std::tuple< Coordinate, Coordinate > Segment
Line segment.
Definition common.h:250
uint16_t API_PATCH_VERSION
API patch version number.
Definition common.h:304
uint16_t API_MAJOR_VERSION
API major version number.
Definition common.h:300
Pixel location in an image.
Definition common.h:226
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:91
CBEFF information registered with and assigned by IBIA.
Definition common.h:257
auto operator<=>(const CBEFFIdentifier &) const
bool operator==(const CBEFFIdentifier &) const
Identifying details about algorithm components for documentation.
Definition common.h:254
auto operator<=>(const ProductIdentifier &) const
bool operator==(const ProductIdentifier &) const
Information about the result of calling a FRIF TE 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