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 {
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
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
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,
167 const BitsPerChannel bpc,
168 const BitsPerPixel bpp,
169 const std::vector<std::byte> &pixels);
170
179 void
181 const;
182
187 uint8_t identifier{};
189 uint16_t width{};
191 uint16_t height{};
193 uint16_t ppi{};
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 std::strong_ordering
247 const Coordinate&)
248 const;
249 bool operator==(const Coordinate&) const;
250 };
251
253 using Segment = std::tuple<Coordinate, Coordinate>;
254
257 {
260 {
262 uint16_t owner{};
264 std::optional<uint16_t> algorithm{};
265
266 std::strong_ordering
268 const CBEFFIdentifier&)
269 const;
270 bool operator==(const CBEFFIdentifier&) const;
271 };
272
277 std::optional<std::string> marketing{};
285 std::optional<CBEFFIdentifier> cbeff{};
286
287 std::strong_ordering
289 const ProductIdentifier&)
290 const;
291 bool operator==(const ProductIdentifier&) const;
292 };
293
294 /*
295 * API versioning.
296 *
297 * NIST code will extern the version number symbols. Participant code
298 * shall compile them into their core library.
299 */
300 #ifdef NIST_EXTERN_FRIFTE_API_VERSION
302 extern uint16_t API_MAJOR_VERSION;
304 extern uint16_t API_MINOR_VERSION;
306 extern uint16_t API_PATCH_VERSION;
307 #else /* NIST_EXTERN_FRIFTE_API_VERSION */
309 uint16_t API_MAJOR_VERSION{1};
311 uint16_t API_MINOR_VERSION{3};
313 uint16_t API_PATCH_VERSION{0};
314 #endif /* NIST_EXTERN_FRIFTE_API_VERSION */
315
316 /*
317 * Ensure that std::byte is exactly 8 bits, such that reinterpret_casts
318 * may be safely used.
319 */
320 static_assert(std::is_same_v<std::underlying_type_t<std::byte>,
321 uint8_t>, "std::byte not represented as unsigned 8 bit type");
322}
323
324#endif /* FRIF_COMMON_H_ */
TE input/output types.
Definition common.h:26
uint16_t API_MINOR_VERSION
API minor version number.
Definition common.h:311
std::tuple< Coordinate, Coordinate > Segment
Line segment.
Definition common.h:253
uint16_t API_PATCH_VERSION
API patch version number.
Definition common.h:313
uint16_t API_MAJOR_VERSION
API major version number.
Definition common.h:309
Pixel location in an image.
Definition common.h:226
std::strong_ordering operator<=>(const Coordinate &) const
bool operator==(const Coordinate &) const
uint32_t x
X coordinate in pixels.
Definition common.h:228
uint32_t y
Y coordinate in pixels.
Definition common.h:230
Coordinate(const uint32_t x={}, const uint32_t y={})
Coordinate constructor.
uint16_t height
Height of the image.
Definition common.h:191
BitsPerPixel bpp
Number of bits comprising a single pixel.
Definition common.h:199
BitsPerPixel
Number of bits comprising a single image pixel.
Definition common.h:61
BitsPerPixel BPP
Definition common.h:67
uint16_t ppi
Resolution of the image in pixels per inch.
Definition common.h:193
std::vector< std::byte > pixels
Raw pixel data of image.
Definition common.h:221
uint16_t width
Width of the image.
Definition common.h:189
BitsPerChannel BPC
Definition common.h:95
void sanityCheck() const
Validate that the properties of this Image appear to correspond to valid image data.
static BitsPerPixel toBitsPerPixel(const std::underlying_type_t< BitsPerPixel > i)
Convert integer to enumerated type.
@ Grayscale
Single channel (shades of gray).
Definition common.h:117
Colorspace colorspace
Representation of color in each byte within pixels.
Definition common.h:195
BitsPerChannel
Number of bits comprising a single color channel of a single pixel.
Definition common.h:91
BitsPerChannel bpc
Number of bits used by each color component.
Definition common.h:197
static BitsPerChannel toBitsPerChannel(const std::underlying_type_t< BitsPerChannel > i)
Convert integer to enumerated type.
uint8_t identifier
An identifier for this image.
Definition common.h:187
CBEFF information registered with and assigned by IBIA.
Definition common.h:260
uint16_t owner
CBEFF Product Owner of the product.
Definition common.h:262
std::strong_ordering operator<=>(const CBEFFIdentifier &) const
std::optional< uint16_t > algorithm
CBEFF Algorithm Identifier of the product.
Definition common.h:264
bool operator==(const CBEFFIdentifier &) const
Identifying details about algorithm components for documentation.
Definition common.h:257
std::optional< CBEFFIdentifier > cbeff
CBEFF information about the product.
Definition common.h:285
std::optional< std::string > marketing
Non-infringing marketing name of the product.
Definition common.h:277
bool operator==(const ProductIdentifier &) const
std::strong_ordering 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.
Definition common.h:34
@ Failure
Failed to perform operation.
Definition common.h:36
std::optional< std::string > message
Information about the result.
Definition common.h:45