Zivid C++ API 2.18.0+1b44dbef-1
BarcodeFormats.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of the Zivid API
3 *
4 * Copyright 2015-2026 (C) Zivid AS
5 * All rights reserved.
6 *
7 * Zivid Software License, v1.0
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, 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 *
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * 3. Neither the name of Zivid AS nor the names of its contributors may be used
20 * to endorse or promote products derived from this software without specific
21 * prior written permission.
22 *
23 * 4. This software, with or without modification, must not be used with any
24 * other 3D camera than from Zivid AS.
25 *
26 * 5. Any software provided in binary form under this license must not be
27 * reverse engineered, decompiled, modified and/or disassembled.
28 *
29 * THIS SOFTWARE IS PROVIDED BY ZIVID AS "AS IS" AND ANY EXPRESS OR IMPLIED
30 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31 * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
32 * DISCLAIMED. IN NO EVENT SHALL ZIVID AS OR CONTRIBUTORS BE LIABLE FOR ANY
33 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * Contact: Zivid Customer Success Team <customersuccess@zivid.com>
41 * Info: http://www.zivid.com
42 ******************************************************************************/
43
44#pragma once
45
46#include <cstdint>
47#include <type_traits>
48
49namespace Zivid
50{
51 namespace Experimental
52 {
53 namespace Toolbox
54 {
61 enum class LinearBarcodeFormat : uint32_t
62 {
63 code128 = (1 << 0),
64 code93 = (1 << 1),
65 code39 = (1 << 2),
66 ean13 = (1 << 3),
67 ean8 = (1 << 4),
68 upcA = (1 << 5),
69 upcE = (1 << 6),
70 itf = (1 << 7),
71 };
72
79 enum class MatrixBarcodeFormat : uint32_t
80 {
81 qrcode = (1 << 0),
82 dataMatrix = (1 << 1),
83 };
84
89 template<typename FormatEnum>
91 {
92 public:
93 static_assert(
94 std::is_same_v<FormatEnum, LinearBarcodeFormat> || std::is_same_v<FormatEnum, MatrixBarcodeFormat>);
95
96 using Enum = FormatEnum;
97 using UnderlyingInt = std::underlying_type_t<FormatEnum>;
98
100 static constexpr BarcodeFormatFilter all()
101 {
102 return BarcodeFormatFilter{ ~UnderlyingInt{ 0 } };
103 }
104
106 constexpr bool has(FormatEnum enumVal) const
107 {
108 return (m_value & static_cast<UnderlyingInt>(enumVal)) != 0;
109 }
110
111 constexpr BarcodeFormatFilter(FormatEnum enumVal)
112 : m_value{ static_cast<UnderlyingInt>(enumVal) }
113 {}
114
115 constexpr BarcodeFormatFilter operator|(FormatEnum other) const
116 {
117 return BarcodeFormatFilter{ m_value | static_cast<UnderlyingInt>(other) };
118 }
119
121 {
122 return BarcodeFormatFilter{ m_value | other.m_value };
123 }
124
125 private:
126 constexpr BarcodeFormatFilter() = default;
127
128 constexpr explicit BarcodeFormatFilter(UnderlyingInt value)
129 : m_value{ value }
130 {}
131
132 UnderlyingInt m_value{ 0 };
133 };
134
138 {
140 }
141
145 {
146 return rhs | lhs;
147 }
148
152 {
154 }
155
159 {
160 return rhs | lhs;
161 }
162
173
184
185 } // namespace Toolbox
186 } // namespace Experimental
187} // namespace Zivid
Filter type for defining which barcode formats to look for when reading barcodes.
Definition BarcodeFormats.h:91
constexpr bool has(FormatEnum enumVal) const
Check if a filter includes a given format.
Definition BarcodeFormats.h:106
static constexpr BarcodeFormatFilter all()
Get a filter that includes all supported formats.
Definition BarcodeFormats.h:100
std::underlying_type_t< FormatEnum > UnderlyingInt
Definition BarcodeFormats.h:97
constexpr BarcodeFormatFilter operator|(FormatEnum other) const
Definition BarcodeFormats.h:115
FormatEnum Enum
Definition BarcodeFormats.h:96
constexpr BarcodeFormatFilter operator|(BarcodeFormatFilter other) const
Definition BarcodeFormats.h:120
constexpr BarcodeFormatFilter(FormatEnum enumVal)
Definition BarcodeFormats.h:111
Definition Barcode.h:64
LinearBarcodeFormat
Enum describing the supported linear (1D) barcode formats.
Definition BarcodeFormats.h:62
@ code93
Definition BarcodeFormats.h:64
@ code128
Definition BarcodeFormats.h:63
@ code39
Definition BarcodeFormats.h:65
MatrixBarcodeFormat
Enum describing the supported matrix (2D) barcode formats.
Definition BarcodeFormats.h:80
@ qrcode
Definition BarcodeFormats.h:81
@ dataMatrix
Definition BarcodeFormats.h:82
BarcodeFormatFilter< LinearBarcodeFormat > LinearBarcodeFormatFilter
Filter type for defining which linear (1D) barcode formats to look for when reading barcodes.
Definition BarcodeFormats.h:172
BarcodeFormatFilter< MatrixBarcodeFormat > MatrixBarcodeFormatFilter
Filter type for defining which matrix (2D) barcode formats to look for when reading barcodes.
Definition BarcodeFormats.h:183
constexpr BarcodeFormatFilter< LinearBarcodeFormat > operator|(LinearBarcodeFormat lhs, LinearBarcodeFormat rhs)
Definition BarcodeFormats.h:135
Definition Calibration.h:59
The main Zivid namespace. All Zivid code is found here.
Definition Application.h:85