Zivid C++ API 2.17.1+7516d437-1
BarcodeFormats.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of the Zivid API
3 *
4 * Copyright 2015-2025 (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 };
71
78 enum class MatrixBarcodeFormat : uint32_t
79 {
80 qrcode = (1 << 0),
81 dataMatrix = (1 << 1),
82 };
83
88 template<typename FormatEnum>
90 {
91 public:
92 using Enum = FormatEnum;
93 using UnderlyingInt = std::underlying_type_t<FormatEnum>;
94
96 static constexpr BarcodeFormatFilter all()
97 {
99 }
100
102 constexpr bool has(FormatEnum enumVal) const
103 {
104 return (m_value & static_cast<UnderlyingInt>(enumVal)) != 0;
105 }
106
107 constexpr BarcodeFormatFilter(FormatEnum enumVal)
108 : m_value{ static_cast<UnderlyingInt>(enumVal) }
109 {}
110
111 constexpr BarcodeFormatFilter operator|(FormatEnum other) const
112 {
113 return BarcodeFormatFilter{ m_value | static_cast<UnderlyingInt>(other) };
114 }
115
117 {
118 return BarcodeFormatFilter{ m_value | other.m_value };
119 }
120
121 private:
122 constexpr BarcodeFormatFilter() = default;
123
124 constexpr explicit BarcodeFormatFilter(UnderlyingInt value)
125 : m_value{ value }
126 {}
127
128 UnderlyingInt m_value{ 0 };
129 };
130
131 template<typename FormatEnum>
132 constexpr BarcodeFormatFilter<FormatEnum> operator|(FormatEnum lhs, FormatEnum rhs)
133 {
134 return BarcodeFormatFilter<FormatEnum>{ lhs } | rhs;
135 }
136
137 template<typename FormatEnum>
139 {
140 return rhs | lhs;
141 }
142
153
164
165 } // namespace Toolbox
166 } // namespace Experimental
167} // namespace Zivid
Filter type for defining which barcode formats to look for when reading barcodes.
Definition BarcodeFormats.h:90
constexpr bool has(FormatEnum enumVal) const
Check if a filter includes a given format.
Definition BarcodeFormats.h:102
static constexpr BarcodeFormatFilter all()
Get a filter that includes all supported formats.
Definition BarcodeFormats.h:96
std::underlying_type_t< FormatEnum > UnderlyingInt
Definition BarcodeFormats.h:93
constexpr BarcodeFormatFilter operator|(FormatEnum other) const
Definition BarcodeFormats.h:111
FormatEnum Enum
Definition BarcodeFormats.h:92
constexpr BarcodeFormatFilter operator|(BarcodeFormatFilter other) const
Definition BarcodeFormats.h:116
constexpr BarcodeFormatFilter(FormatEnum enumVal)
Definition BarcodeFormats.h:107
Definition Barcode.h:62
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:79
@ qrcode
Definition BarcodeFormats.h:80
@ dataMatrix
Definition BarcodeFormats.h:81
BarcodeFormatFilter< LinearBarcodeFormat > LinearBarcodeFormatFilter
Filter type for defining which linear (1D) barcode formats to look for when reading barcodes.
Definition BarcodeFormats.h:152
constexpr BarcodeFormatFilter< FormatEnum > operator|(FormatEnum lhs, FormatEnum rhs)
Definition BarcodeFormats.h:132
BarcodeFormatFilter< MatrixBarcodeFormat > MatrixBarcodeFormatFilter
Filter type for defining which matrix (2D) barcode formats to look for when reading barcodes.
Definition BarcodeFormats.h:163
Definition Calibration.h:59
The main Zivid namespace. All Zivid code is found here.
Definition Application.h:84