IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
metadata_key.py
Go to the documentation of this file.
1from dataclasses import dataclass
2from enum import Enum
3from typing import Type, Any
4
5from ids_peak_common.datatypes.geometry.rectangle import Rectangle
6
7
8@dataclass(frozen=True)
10 string_value: str
11 type: Type[Any]
12
13
14class MetadataKey(Enum):
15 """!
16 @brief
17 Enumerates all compile-time known metadata keys.
18
19 Each enum value carries both:
20 - A string identifier (used internally in Metadata).
21 - The expected Python type of its value.
22
23 This makes it easy to use type-safe keys without an extra trait class.
24
25 Example::
26
27 key = MetadataKey.DEVICE_TIMESTAMP
28 print(key.string_value) # outputs: device_timestamp
29 print(key.type) # outputs: <class 'int'>
30
31 @ingroup ids_peak_common_python_types
32 """
33
34 DEVICE_TIMESTAMP = _MetadataKeyInfo("DeviceTimestamp", int)
35 """!
36 @brief
37 Device-provided image acquisition timestamp in nanoseconds.
38
39 The timestamp is expressed in nanoseconds and is relative to an
40 unspecified reference point (t = 0). It does not represent an
41 absolute wall-clock time, but instead the elapsed time since
42 that reference. The difference between timestamps of consecutive
43 images indicates the time interval between their recordings.
44 """
45
46 DEVICE_FRAME_ID = _MetadataKeyInfo("DeviceFrameID", int)
47 """!
48 @brief
49 A sequentially incremented identifier for the frame.
50
51 The frame ID is a sequentially incremented value that increases by one
52 from one frame to the next. It serves as a means to detect missing or
53 out-of-order frames in a stream. Once the maximum value supported by
54 the underlying technology is reached, the frame ID wraps back to zero.
55 The exact wrap-around point is not fixed and depends on the implementation.
56 """
57
58 BINNING_HORIZONTAL = _MetadataKeyInfo("BinningHorizontal", int)
59 """!
60 @brief
61 Horizontal pixel binning factor.
62
63 Indicates how many adjacent pixels are combined horizontally.
64 """
65
66 BINNING_VERTICAL = _MetadataKeyInfo("BinningVertical", int)
67 """!
68 @brief
69 Vertical pixel binning factor.
70
71 Indicates how many adjacent pixels are combined vertically.
72 """
73
74 ROI = _MetadataKeyInfo("Roi", Rectangle)
75 """!
76 @brief
77 Region of interest applied to the image.
78
79 Defines the rectangular area of the image that remains after
80 processing steps such as cropping or scaling were applied.
81 Coordinates and dimensions are expressed in pixels.
82 """
83
84 DEVICE_EXPOSURE_TIME = _MetadataKeyInfo("DeviceExposureTime", float)
85 """!
86 @brief
87 Device exposure time the image was captured with.
88
89 Specified in microseconds (µs).
90 """
91
92 SYSTEM_TIMESTAMP = _MetadataKeyInfo("SystemTimestamp", int)
93 """!
94 @brief
95 Timestamp of the system since unix epoch in nanoseconds.
96
97 Provides the system timestamp corresponding to the device timestamp,
98 expressed as nanoseconds since the Unix epoch (00:00:00 UTC on January 1, 1970).
99 This allows data to be associated with a system time, for example
100 for logging or correlating with other system events.
101
102 The system timestamp is not intended for high-precision timing due to
103 device-side timestamping and host processing delays. For applications
104 requiring high timing accuracy, use the DeviceTimestamp directly.
105 """
106
107 DEVICE_EXPOSURE_TIME_SEQUENCE = _MetadataKeyInfo("DeviceExposureTimeSequence", list[float])
108 """!
109 @brief
110 Device exposure time sequence the image was captured with.
111
112 This feature applies exclusively to HDR pixel formats
113 where multiple exposures are acquired within a single image frame.
114 During unpacking, the individual exposures are separated into distinct images,
115 and the corresponding exposure time for each image is written to DEVICE_EXPOSURE_TIME
116
117 Specified in microseconds (µs).
118
119 @since ids_peak_common 1.3
120 """
121
122 DEVICE_GAIN = _MetadataKeyInfo("DeviceGain", float)
123 """!
124 @brief
125 Device gain the image was captured with.
126 """
127
128 DEVICE_GAIN_SEQUENCE = _MetadataKeyInfo("DeviceGainSequence", list[float])
129 """!
130 @brief
131 Device gain sequence the image was captured with.
132
133 This feature applies exclusively to HDR pixel formats
134 where multiple gains are used for acquisition within a single image frame.
135 During unpacking, the individual gains are separated into distinct images,
136 and the corresponding gain for each image is written to DEVICE_GAIN
137 """
138
139 @property
140 def string_value(self) -> str:
141 """!
142 @brief Return the string_value for this metadata key."""
143 return self.value.string_value
144
145 @property
146 def type(self) -> Type[Any]:
147 """!
148 @brief Return the expected Python type for this metadata key."""
149 return self.value.type
150
151 def __str__(self) -> str:
152 """!
153 @brief
154 Return a human-readable string of the MetadataKey object.
155 """
156 return f"{self.string_value} ({self.type.__name__})"
157
158 def __repr__(self) -> str:
159 """!
160 @brief
161 Return an unambiguous string of the MetadataKey object.
162 """
163 return (f"{self.__class__.__name__}.{self.name}"
164 f"(string_value={self.value.string_value!r}, "
165 f"type={self.value.type!r})")
Enumerates all compile-time known metadata keys.
Type[Any] type(self)
Return the expected Python type for this metadata key.
str string_value(self)
Return the string_value for this metadata key.
str __str__(self)
Return a human-readable string of the MetadataKey object.
str __repr__(self)
Return an unambiguous string of the MetadataKey object.