pfnc 0.1.0__cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. dataspree/pfnc/__about__.py +3 -0
  2. dataspree/pfnc/__init__.py +122 -0
  3. dataspree/pfnc/_internal/__init__.py +0 -0
  4. dataspree/pfnc/_internal/registry.cpython-312-x86_64-linux-gnu.so +0 -0
  5. dataspree/pfnc/_internal/registry.pyi +43 -0
  6. dataspree/pfnc/_internal/utils.cpython-312-x86_64-linux-gnu.so +0 -0
  7. dataspree/pfnc/_internal/utils.pyi +8 -0
  8. dataspree/pfnc/decoder_registry.cpython-312-x86_64-linux-gnu.so +0 -0
  9. dataspree/pfnc/decoder_registry.pyi +84 -0
  10. dataspree/pfnc/exceptions.cpython-312-x86_64-linux-gnu.so +0 -0
  11. dataspree/pfnc/exceptions.pyi +30 -0
  12. dataspree/pfnc/genicam/__init__.py +1 -0
  13. dataspree/pfnc/genicam/components.cpython-312-x86_64-linux-gnu.so +0 -0
  14. dataspree/pfnc/genicam/components.pyi +1077 -0
  15. dataspree/pfnc/genicam/data_types.cpython-312-x86_64-linux-gnu.so +0 -0
  16. dataspree/pfnc/genicam/data_types.pyi +115 -0
  17. dataspree/pfnc/genicam/interface_specifics.cpython-312-x86_64-linux-gnu.so +0 -0
  18. dataspree/pfnc/genicam/interface_specifics.pyi +102 -0
  19. dataspree/pfnc/genicam/number_of_bits.cpython-312-x86_64-linux-gnu.so +0 -0
  20. dataspree/pfnc/genicam/number_of_bits.pyi +53 -0
  21. dataspree/pfnc/genicam/packing_types.cpython-312-x86_64-linux-gnu.so +0 -0
  22. dataspree/pfnc/genicam/packing_types.pyi +81 -0
  23. dataspree/pfnc/genicam/pixel_format.cpython-312-x86_64-linux-gnu.so +0 -0
  24. dataspree/pfnc/genicam/pixel_format.pyi +95 -0
  25. dataspree/pfnc/pixel_format.cpython-312-x86_64-linux-gnu.so +0 -0
  26. dataspree/pfnc/pixel_format.pyi +40 -0
  27. dataspree/pfnc/py.typed +0 -0
  28. pfnc-0.1.0.dist-info/METADATA +134 -0
  29. pfnc-0.1.0.dist-info/RECORD +31 -0
  30. pfnc-0.1.0.dist-info/WHEEL +6 -0
  31. pfnc-0.1.0.dist-info/licenses/LICENSE.txt +21 -0
@@ -0,0 +1,1077 @@
1
+ from .._internal.registry import MappingSnapshot as MappingSnapshot, Registry as Registry
2
+ from .._internal.utils import all_implementations as all_implementations, join_designators as join_designators
3
+ from _typeshed import Incomplete
4
+ from abc import ABCMeta, abstractmethod
5
+ from collections.abc import Iterator, Sequence
6
+ from dataclasses import dataclass
7
+ from dataspree.pfnc.genicam.number_of_bits import Size as Size
8
+ from enum import Enum
9
+ from typing import Any, TypeGuard, TypeVar
10
+ from typing_extensions import Self
11
+
12
+ logger: Incomplete
13
+
14
+ class CompoundChannel(Enum):
15
+ """Enumeration of compound channels for pixel formats."""
16
+ RAW = 'Raw'
17
+ MONO = 'Mono'
18
+ CONFIDENCE = 'Confidence'
19
+ RED = 'R'
20
+ GREEN = 'G'
21
+ BLUE = 'B'
22
+ LUMA = 'Y'
23
+ ALPHA = 'a'
24
+ ALPHA_2 = 'A'
25
+ HUE = 'H'
26
+ SATURATION = 'S'
27
+ VALUE = 'V'
28
+ CHROMA = 'U'
29
+ WHITE = 'W'
30
+ INTENSITY = 'I'
31
+ BLUE_DIFFERENCE = 'Cb'
32
+ RED_DIFFERENCE = 'Cr'
33
+ CYAN = 'C'
34
+ MAGENTA = 'M'
35
+ YELLOW = 'Ye'
36
+ INFRARED = 'Ir'
37
+
38
+ class CoordinateChannel(Enum):
39
+ """Enumeration of coordinate channels for 3D spatial data."""
40
+ COORD3D_A = 'A'
41
+ COORD3D_B = 'B'
42
+ COORD3D_C = 'C'
43
+ Channel = CompoundChannel | CoordinateChannel | str
44
+
45
+ def is_channel(potential_channel: Any) -> TypeGuard[Channel]:
46
+ """Checks if a given object is a valid channel.
47
+
48
+ Args:
49
+ potential_channel: The object to validate.
50
+
51
+ Returns:
52
+ bool: True if the object is a valid channel, False otherwise.
53
+ """
54
+ def channel_name(channel: Channel) -> str:
55
+ """Retrieves the string representation of a channel.
56
+
57
+ Args:
58
+ channel (Channel): The channel to convert.
59
+
60
+ Returns:
61
+ str: The string representation of the channel.
62
+ """
63
+
64
+ @dataclass
65
+ class ChannelProperty:
66
+ """Represents properties of a channel.
67
+
68
+ Attributes:
69
+ combinable (bool): Whether the channel can be combined with others.
70
+
71
+ free (bool): Whether the channel can be freely used by the default implementation.
72
+ """
73
+ combinable: bool
74
+ free: bool = ...
75
+
76
+ @dataclass
77
+ class ChannelRegistry:
78
+ """Registry for channels and their properties with immutable defaults."""
79
+ def __post_init__(self) -> None:
80
+ """Populate default channel registries."""
81
+ def register_custom(self, channel: str, prop: ChannelProperty) -> None:
82
+ """Register a custom single-letter channel with its properties."""
83
+ def resolve_property(self, channel: Channel) -> ChannelProperty:
84
+ """Resolve the property for a channel."""
85
+ def restore(self, snap: MappingSnapshot[Channel, ChannelProperty]) -> None:
86
+ """Restore a snapshot and enforce that defaults are present and unchanged."""
87
+ def snapshot(self) -> MappingSnapshot[Channel, ChannelProperty]:
88
+ """Snapshot current state."""
89
+ def iter_free_designators_by_length(self) -> list[tuple[str, Channel]]:
90
+ """Return designator->channel pairs sorted by designator length (desc).
91
+
92
+ This is done in order to favor more complex designators (Cb) over C.
93
+ """
94
+
95
+ CHANNEL_REGISTRY: ChannelRegistry
96
+
97
+ class Channels(metaclass=ABCMeta):
98
+ """Abstract base class for handling pixel format channels."""
99
+ @abstractmethod
100
+ def name(self, indices: list[int] | None = None) -> str:
101
+ """Gets the name of the channel sequence.
102
+
103
+ Args:
104
+ indices (Optional[list[int]]): Indices to filter specific channels.
105
+
106
+ Returns:
107
+ str: The concatenated channel name.
108
+ """
109
+ @abstractmethod
110
+ def __len__(self) -> int:
111
+ """Gets the number of channels.
112
+
113
+ Returns:
114
+ int: The number of channels.
115
+ """
116
+ @abstractmethod
117
+ def __getitem__(self, item: int) -> Channel:
118
+ """Gets the channel at the specified index.
119
+
120
+ Args:
121
+ item (int): The index of the desired channel.
122
+
123
+ Returns:
124
+ Channel: The channel at the specified index.
125
+ """
126
+ def __iter__(self) -> Iterator[Channel]:
127
+ """Iterator implementation."""
128
+ @staticmethod
129
+ def create(channel_start: str, allow_repeat: bool = False) -> list[tuple[Channels, ColorSpaceStandard | None, str]]:
130
+ """Creates channel instances from a starting designation string.
131
+
132
+ Args:
133
+ channel_start (str): The starting designation string for channels.
134
+ allow_repeat (bool): Whether duplicate channels are allowed.
135
+
136
+ Returns:
137
+ list[tuple['Channels', Optional['ColorSpaceStandard'], str]]: Parsed channels, optional color space
138
+ standards, and remaining substrings.
139
+ """
140
+ @classmethod
141
+ @abstractmethod
142
+ def from_designation(cls, channel_start: str, allow_repeat: bool = False) -> list[tuple[Self, str]]:
143
+ """Parses a designation string into channels.
144
+
145
+ Args:
146
+ channel_start (str): The start of the channel designation.
147
+ allow_repeat (bool): Whether repeated channels are allowed.
148
+
149
+ Returns:
150
+ list[tuple['Channels', str]]: A list of channel instances and remaining substrings.
151
+ """
152
+
153
+ class CompoundChannels(Channels):
154
+ """Represents a compound set of pixel format channels."""
155
+ channels: Sequence[Channel]
156
+ def __init__(self, channels: Sequence[Channel], allow_repeat: bool = False) -> None:
157
+ """Initializes a compound channel set.
158
+
159
+ Args:
160
+ channels (Sequence[Channel]): The list of channels.
161
+ allow_repeat (bool): Whether duplicate channels are allowed.
162
+
163
+ Raises:
164
+ PixelFormatValueReject: If invalid channels or duplicates are encountered.
165
+ """
166
+ def __len__(self) -> int:
167
+ """Gets the number of channels in the compound channel set.
168
+
169
+ Returns:
170
+ int: The number of channels.
171
+ """
172
+ def __getitem__(self, item: int) -> Channel:
173
+ """Gets the channel at the specified index.
174
+
175
+ Args:
176
+ item (int): The index of the desired channel.
177
+
178
+ Returns:
179
+ Channel: The channel at the specified index.
180
+ """
181
+ def name(self, indices: list[int] | None = None) -> str:
182
+ """Gets the concatenated name of the channel sequence.
183
+
184
+ Args:
185
+ indices (Optional[list[int]]): A list of indices to filter specific channels.
186
+
187
+ Returns:
188
+ str: The concatenated name of the channels.
189
+ """
190
+ @classmethod
191
+ def from_designation(cls, channel_start: str, allow_repeat: bool = False) -> list[tuple[Self, str]]:
192
+ """Parses a designation string into compound channels.
193
+
194
+ Args:
195
+ channel_start (str): The start of the channel designation.
196
+ allow_repeat (bool): Whether repeated channels are allowed.
197
+
198
+ Returns:
199
+ list[tuple[CompoundChannels, str]]: A list of channel instances and remaining substrings.
200
+ """
201
+ def __eq__(self, other: Any) -> bool:
202
+ """Checks equality between two CompoundChannel objects.
203
+
204
+ Args:
205
+ other (Any): The object to compare.
206
+
207
+ Returns:
208
+ bool: True if the objects are equal, False otherwise.
209
+ """
210
+
211
+ class Coord3D(CompoundChannels):
212
+ """Represents 3D spatial coordinate channels."""
213
+ def __init__(self, channels: Sequence[Channel], allow_repeat: bool = False) -> None:
214
+ """Initializes a compound channel set.
215
+
216
+ Args:
217
+ channels (Sequence[Channel]): The list of channels to include.
218
+ allow_repeat (bool): Whether duplicate channels are allowed.
219
+
220
+ Raises:
221
+ ValueError: If invalid channels or duplicates are encountered.
222
+ """
223
+ def name(self, indices: list[int] | None = None) -> str:
224
+ """Generates the name of the Coord3D channel sequence.
225
+
226
+ Args:
227
+ indices (Optional[list[int]]): Indices to filter specific channels. If None, all channels are used.
228
+
229
+ Returns:
230
+ str: The formatted name of the Coord3D channel sequence.
231
+ """
232
+ @classmethod
233
+ def from_designation(cls, channel_start: str | None, allow_repeat: bool = False) -> list[tuple[Self, str]]:
234
+ """Parses a designation string into Coord3D compound channels.
235
+
236
+ Args:
237
+ channel_start (str | None): The start of the channel designation.
238
+ allow_repeat (bool): Whether repeated channels are allowed.
239
+
240
+ Returns:
241
+ list[tuple[Coord3D, str]]: A list of channel instances and remaining substrings.
242
+ """
243
+
244
+ class ColorSpaceStandard(metaclass=ABCMeta):
245
+ """Abstract base class for color space standards."""
246
+ name: str
247
+ def __init__(self, name: str) -> None:
248
+ """Initializes the ITU-R BT.601 color space standard."""
249
+ @classmethod
250
+ @abstractmethod
251
+ def initialize(cls, channels: Channels) -> Self:
252
+ """Initializes a color space standard for the given channels.
253
+
254
+ Args:
255
+ channels (Channels): The channel set for the standard.
256
+
257
+ Returns:
258
+ ColorSpaceStandard: An initialized color space standard.
259
+ """
260
+ @classmethod
261
+ def from_designation(cls, designation_substring: str, channels: Channels) -> list[tuple[Self, str]]:
262
+ """Parses a designation string into location objects.
263
+
264
+ Args:
265
+ designation_substring (str): The full designation string.
266
+
267
+ channels (Channels): List of channels to which this color space standard applies.
268
+
269
+ Returns:
270
+ list[tuple['Location', Channels, ColorSpaceStandard, str]]: Parsed locations, associated channels, optional
271
+ color space standards, and remaining substrings.
272
+ """
273
+ @staticmethod
274
+ def compatible_with(channels: Channels, designation_substring: str | None = None) -> str | None:
275
+ """Checks whether a designation substring is compatible with the channels.
276
+
277
+ Args:
278
+ channels (Channels): The channels to check.
279
+ designation_substring (Optional[str]): The designation substring to validate.
280
+
281
+ Returns:
282
+ Optional[str]: Remaining substring if compatible, otherwise None.
283
+ """
284
+ @staticmethod
285
+ def create(designation_substring: str, channels: Channels) -> list[tuple[ColorSpaceStandard | None, str]]:
286
+ """Creates color space standard objects from a designation substring.
287
+
288
+ Args:
289
+ designation_substring (str): The substring to parse.
290
+ channels (Channels): The associated channels.
291
+
292
+ Returns:
293
+ list[tuple[Optional['ColorSpaceStandard'], str]]: A list of parsed color space standards and remaining
294
+ substrings.
295
+ """
296
+
297
+ class ItuRBt601(ColorSpaceStandard):
298
+ """Represents the ITU-R BT.601 color space standard."""
299
+ def __init__(self) -> None:
300
+ """Initializes the ITU-R BT.601 color space standard."""
301
+ @classmethod
302
+ def initialize(cls, channels: Channels) -> Self:
303
+ """Initializes the Itu.RBt.601 color space standard.
304
+
305
+ Args:
306
+ channels (Channels): The channels to associate with this color space standard.
307
+
308
+ Returns:
309
+ ItuRBt601: An instance of the Itu.RBt.601 color space standard.
310
+ """
311
+ @staticmethod
312
+ def compatible_with(channels: Channels, designation_substring: str | None = None) -> str | None:
313
+ """Checks if the channels and designation substring are compatible with the Itu.Rbt.601 standard.
314
+
315
+ Args:
316
+ channels (Channels): The channels to validate against the standard.
317
+ designation_substring (Optional[str]): The remaining string to check for compatibility.
318
+
319
+ Returns:
320
+ Optional[str]: The remaining substring after removing the standard identifier if compatible,
321
+ otherwise None.
322
+ """
323
+ def __eq__(self, other: Any) -> bool:
324
+ """Checks equality between two ItuRBt601 objects.
325
+
326
+ Args:
327
+ other (Any): The object to compare.
328
+
329
+ Returns:
330
+ bool: True if the objects are equal, False otherwise.
331
+ """
332
+
333
+ class ItuRBt709(ColorSpaceStandard):
334
+ """Represents the ITU-R BT.709 color space standard."""
335
+ def __init__(self) -> None:
336
+ """Initializes the ITU-R BT.709 color space standard."""
337
+ @classmethod
338
+ def initialize(cls, channels: Channels) -> Self:
339
+ """Initializes the Itu.RBt.709 color space standard.
340
+
341
+ Args:
342
+ channels (Channels): The channels to associate with this color space standard.
343
+
344
+ Returns:
345
+ ItuRBt709: An instance of the Itu.RBt.709 color space standard.
346
+ """
347
+ @staticmethod
348
+ def compatible_with(channels: Channels, designation_substring: str | None = None) -> str | None:
349
+ """Checks if the channels and designation substring are compatible with the Itu.RBt.709 standard.
350
+
351
+ Args:
352
+ channels (Channels): The channels to validate against the standard.
353
+ designation_substring (Optional[str]): The remaining string to check for compatibility.
354
+
355
+ Returns:
356
+ Optional[str]: The remaining substring after removing the standard identifier if compatible,
357
+ otherwise None.
358
+ """
359
+ def __eq__(self, other: Any) -> bool:
360
+ """Checks equality between two ItuRBt709 objects.
361
+
362
+ Args:
363
+ other (Any): The object to compare.
364
+
365
+ Returns:
366
+ bool: True if the objects are equal, False otherwise.
367
+ """
368
+
369
+ class Bt601(ColorSpaceStandard):
370
+ """Represents the BT.601 color space standard."""
371
+ def __init__(self) -> None:
372
+ """Initializes the BT.601 color space standard."""
373
+ @classmethod
374
+ def initialize(cls, channels: Channels) -> Self:
375
+ """Initializes the BT.601 color space standard.
376
+
377
+ Args:
378
+ channels (Channels): The channels to associate with this color space standard.
379
+
380
+ Returns:
381
+ Bt601: An instance of the BT.601 color space standard.
382
+ """
383
+ @staticmethod
384
+ def compatible_with(channels: Channels, designation_substring: str | None = None) -> str | None:
385
+ """Checks if the channels and designation substring are compatible with the BT.601 standard.
386
+
387
+ Args:
388
+ channels (Channels): The channels to validate against the standard.
389
+ designation_substring (Optional[str]): The remaining string to check for compatibility.
390
+
391
+ Returns:
392
+ Optional[str]: The remaining substring after removing the standard identifier if compatible,
393
+ otherwise None.
394
+ """
395
+ def __eq__(self, other: Any) -> bool:
396
+ """Checks equality between two Bt601 objects.
397
+
398
+ Args:
399
+ other (Any): The object to compare.
400
+
401
+ Returns:
402
+ bool: True if the objects are equal, False otherwise.
403
+ """
404
+
405
+ class Bt709(ColorSpaceStandard):
406
+ """Represents the BT.709 color space standard."""
407
+ def __init__(self) -> None:
408
+ """Initializes the BT.709 color space standard."""
409
+ @classmethod
410
+ def initialize(cls, channels: Channels) -> Self:
411
+ """Initializes the BT.709 color space standard.
412
+
413
+ Args:
414
+ channels (Channels): The channels to associate with this color space standard.
415
+
416
+ Returns:
417
+ Bt709: An instance of the BT.709 color space standard.
418
+ """
419
+ @staticmethod
420
+ def compatible_with(channels: Channels, designation_substring: str | None = None) -> str | None:
421
+ """Checks if the channels and designation substring are compatible with the BT.709 standard.
422
+
423
+ Args:
424
+ channels (Channels): The channels to validate against the standard.
425
+ designation_substring (Optional[str]): The remaining string to check for compatibility.
426
+
427
+ Returns:
428
+ Optional[str]: The remaining substring after removing the standard identifier if compatible,
429
+ otherwise None.
430
+ """
431
+ def __eq__(self, other: Any) -> bool:
432
+ """Checks equality between two Bt601 objects.
433
+
434
+ Args:
435
+ other (Any): The object to compare.
436
+
437
+ Returns:
438
+ bool: True if the objects are equal, False otherwise.
439
+ """
440
+
441
+ @dataclass
442
+ class Location(metaclass=ABCMeta):
443
+ """Abstract base class for pixel locations."""
444
+ @abstractmethod
445
+ def location_designation(self, channels: Channels, color_space_name: str) -> str:
446
+ """Generates a location designation string.
447
+
448
+ Args:
449
+ channels (Channels): The associated channels.
450
+ color_space_name (str): The name of the color space.
451
+
452
+ Returns:
453
+ str: The location designation.
454
+ """
455
+ @abstractmethod
456
+ def location_name(self, channels: Channels) -> str:
457
+ """Gets the name of the component's location.
458
+
459
+ Args:
460
+ channels (Channels): The associated channels.
461
+
462
+ Returns:
463
+ str: The location name.
464
+ """
465
+ @abstractmethod
466
+ def number_of_channels(self) -> int:
467
+ """Returns the number of channels in the component.
468
+
469
+ This is determined by the length of the component.
470
+
471
+ Returns:
472
+ int: The number of channels.
473
+ """
474
+ @classmethod
475
+ def create(cls, full_designation: str) -> list[tuple[Self, Channels, ColorSpaceStandard | None, str]]:
476
+ """Creates location objects by parsing a full designation string.
477
+
478
+ Args:
479
+ full_designation (str): The full string to parse for location designation.
480
+
481
+ Returns:
482
+ list[tuple[Self, Channels, ColorSpaceStandard, str]]: A list of tuples containing:
483
+ - Self: The created location object.
484
+ - Channels: The associated channels.
485
+ - ColorSpaceStandard: The color space standard associated with the location.
486
+ - str: The remaining designation substring.
487
+ """
488
+ @classmethod
489
+ @abstractmethod
490
+ def from_designation(cls, full_designation: str) -> list[tuple[Self, Channels, ColorSpaceStandard | None, str]]:
491
+ """Parses a designation string into location instances.
492
+
493
+ Args:
494
+ full_designation (str): The full string to parse for location designation.
495
+
496
+ Returns:
497
+ list[tuple[Location, Channels, Optional[ColorSpaceStandard], str]]: A list of tuples containing:
498
+ - Location: The parsed Mono Location object.
499
+ - Channels: The associated channels.
500
+ - Optional[ColorSpaceStandard]: An optional color space standard.
501
+ - str: The remaining designation substring.
502
+ """
503
+
504
+ @dataclass
505
+ class MonoLocation(Location):
506
+ """If a monochrome camera uses one of the mono pixel formats, it outputs 8, 10, 12, or 14 bits of data per pixel.
507
+
508
+ If a Basler color camera uses one of the mono pixel formats, the values for each pixel are first converted to the
509
+ YCbCr color model and returns the Y component (brightness).
510
+ This is equivalent to the value that would be derived from a pixel in a monochrome sensor.
511
+ """
512
+ def location_designation(self, channels: Channels, color_space_name: str) -> str:
513
+ """Generates a location designation string.
514
+
515
+ Args:
516
+ channels (Channels): The associated channels.
517
+ color_space_name (str): The name of the color space.
518
+
519
+ Returns:
520
+ str: The location designation.
521
+ """
522
+ def location_name(self, channels: Channels) -> str:
523
+ """Gets the name of the component's location.
524
+
525
+ Args:
526
+ channels (Channels): The associated channels.
527
+
528
+ Returns:
529
+ str: The location name.
530
+ """
531
+ def number_of_channels(self) -> int:
532
+ """Returns the number of channels in the component.
533
+
534
+ This is determined by the length of the component.
535
+
536
+ Returns:
537
+ int: The number of channels.
538
+ """
539
+ @classmethod
540
+ def from_designation(cls, full_designation: str) -> list[tuple[Self, Channels, ColorSpaceStandard | None, str]]:
541
+ """Parses a designation string into Mono location instances.
542
+
543
+ Args:
544
+ full_designation (str): The full string to parse for location designation.
545
+
546
+ Returns:
547
+ list[tuple[Self, Channels, Optional[ColorSpaceStandard], str]]: A list of tuples containing:
548
+ - Location: The parsed Mono Location object.
549
+ - Channels: The associated channels.
550
+ - Optional[ColorSpaceStandard]: An optional color space standard.
551
+ - str: The remaining designation substring.
552
+ """
553
+ def __eq__(self, other: Any) -> bool:
554
+ """Checks equality between two MonoLocation objects.
555
+
556
+ Args:
557
+ other (Any): The object to compare.
558
+
559
+ Returns:
560
+ bool: True if the objects are equal, False otherwise.
561
+ """
562
+
563
+ @dataclass
564
+ class LMNLocation(Location):
565
+ """Represents an LMN-based pixel location."""
566
+ fields: tuple[int, ...]
567
+ def __post_init__(self) -> None:
568
+ """Performs validation checks on the LMNLocation fields after initialization.
569
+
570
+ Raises:
571
+ PixelFormatValueReject: If the fields are empty or have invalid values.
572
+ """
573
+ def location_designation(self, channels: Channels, color_space_name: str) -> str:
574
+ """Generates a location designation string.
575
+
576
+ Args:
577
+ channels (Channels): The associated channels.
578
+ color_space_name (str): The name of the color space.
579
+
580
+ Returns:
581
+ str: The location designation.
582
+ """
583
+ def location_name(self, channels: Channels) -> str:
584
+ """Gets the name of the component's location.
585
+
586
+ Args:
587
+ channels (Channels): The associated channels.
588
+
589
+ Returns:
590
+ str: The location name.
591
+ """
592
+ def number_of_channels(self) -> int:
593
+ """Returns the number of channels in the component.
594
+
595
+ This is determined by the length of the component.
596
+
597
+ Returns:
598
+ int: The number of channels.
599
+ """
600
+ @classmethod
601
+ def from_designation(cls, full_designation: str) -> list[tuple[Self, Channels, ColorSpaceStandard | None, str]]:
602
+ """Parses a designation string into LMN-based location instances.
603
+
604
+ Args:
605
+ full_designation (str): The full string to parse for location designation.
606
+
607
+ Returns:
608
+ list[tuple[Loc, Channels, Optional[ColorSpaceStandard], str]]: A list of tuples containing:
609
+ - Loc: The parsed LMNLocation object.
610
+ - Channels: The associated channels.
611
+ - Optional[ColorSpaceStandard]: An optional color space standard.
612
+ - str: The remaining designation substring.
613
+ """
614
+ def __eq__(self, other: Any) -> bool:
615
+ """Checks equality between two LMNLocation objects.
616
+
617
+ Args:
618
+ other (Any): The object to compare.
619
+
620
+ Returns:
621
+ bool: True if the objects are equal, False otherwise.
622
+ """
623
+
624
+ @dataclass
625
+ class BayerLocation(Location):
626
+ '''Modern color camera sensors are equipped with a Bayer color filter.
627
+
628
+ They record red, green, blue pixels in distinct areas and interpolate in between.
629
+ Interpolation can be proprietary.
630
+
631
+ If instead of the interpolated n x m values, you would like to directly receive the bayer
632
+ pattern, use a bayer pixel format. Each pixel is filtered to record only one of the colors.
633
+
634
+ array and can output color
635
+ images based on Bayer pixel formats.
636
+
637
+
638
+ If a color camera uses one of the Bayer pixel formats, it outputs 8, 10, or 12 bits of data per pixel.
639
+ Each pixel is filtered to record only one of the colors red, green, and blue. The pixel data is not processed or
640
+ interpolated in any way. This type of pixel data is sometimes referred to as "raw" output.
641
+
642
+ Which Bayer formats are available depends on your camera model.
643
+
644
+ If a monochrome camera uses one of the mono pixel formats, it outputs 8, 10, 12, or 14 bits of data per pixel.
645
+
646
+ If a Basler color camera uses one of the mono pixel formats, the values for each pixel are first converted to the
647
+ YCbCr color model and returns the Y component (brightness).
648
+ This is equivalent to the value that would be derived from a pixel in a monochrome sensor.
649
+ '''
650
+ fields: tuple[str, str, str, str]
651
+ indices: tuple[int, int, int, int] = ...
652
+ def __post_init__(self) -> None:
653
+ """Validates the BayerLocation fields after initialization.
654
+
655
+ Raises:
656
+ PixelFormatValueReject: If the field configuration is invalid.
657
+ """
658
+ def location_designation(self, channels: Channels, color_space_name: str) -> str:
659
+ """Generates a location designation string.
660
+
661
+ Args:
662
+ channels (Channels): The associated channels.
663
+ color_space_name (str): The name of the color space.
664
+
665
+ Returns:
666
+ str: The location designation.
667
+ """
668
+ def location_name(self, channels: Channels) -> str:
669
+ """Gets the name of the component's location.
670
+
671
+ Args:
672
+ channels (Channels): The associated channels.
673
+
674
+ Returns:
675
+ str: The location name.
676
+ """
677
+ def number_of_channels(self) -> int:
678
+ """Returns the number of channels in the component.
679
+
680
+ This is determined by the length of the component.
681
+
682
+ Returns:
683
+ int: The number of channels.
684
+ """
685
+ @classmethod
686
+ def from_designation(cls, full_designation: str) -> list[tuple[Self, Channels, ColorSpaceStandard | None, str]]:
687
+ """Parses a designation string into BayerLocation instances.
688
+
689
+ Args:
690
+ full_designation (str): The string to parse.
691
+
692
+ Returns:
693
+ list[tuple[Location, Channels, Optional[ColorSpaceStandard], str]]: Parsed BayerLocation instances,
694
+ associated channels, optional color space standards, and remaining substrings.
695
+ """
696
+ def __eq__(self, other: Any) -> bool:
697
+ """Checks equality between two BayerLocation objects.
698
+
699
+ Args:
700
+ other (Any): The object to compare.
701
+
702
+ Returns:
703
+ bool: True if the objects are equal, False otherwise.
704
+ """
705
+
706
+ @dataclass
707
+ class BiColor(Location):
708
+ """Represents a Bi-Color pattern pixel location."""
709
+ fields: tuple[str, str, str, str]
710
+ indices: tuple[int, int, int, int] = ...
711
+ def __post_init__(self) -> None:
712
+ """Processes and validates the BiColor fields during initialization."""
713
+ def location_designation(self, channels: Channels, color_space_name: str) -> str:
714
+ """Generates a location designation string.
715
+
716
+ Args:
717
+ channels (Channels): The associated channels.
718
+ color_space_name (str): The name of the color space.
719
+
720
+ Returns:
721
+ str: The location designation.
722
+ """
723
+ def location_name(self, channels: Channels) -> str:
724
+ """Gets the name of the component's location.
725
+
726
+ Args:
727
+ channels (Channels): The associated channels.
728
+
729
+ Returns:
730
+ str: The location name.
731
+ """
732
+ def number_of_channels(self) -> int:
733
+ """Returns the number of channels in the component.
734
+
735
+ This is determined by the length of the component.
736
+
737
+ Returns:
738
+ int: The number of channels.
739
+ """
740
+ @classmethod
741
+ def from_designation(cls, full_designation: str) -> list[tuple[Self, Channels, ColorSpaceStandard | None, str]]:
742
+ """Parses a designation string into BiColor instances.
743
+
744
+ Args:
745
+ full_designation (str): The string to parse.
746
+
747
+ Returns:
748
+ list[tuple[Location, Channels, Optional[ColorSpaceStandard], str]]: Parsed BiColor instances,
749
+ associated channels, optional color space standards, and remaining substrings.
750
+ """
751
+ def __eq__(self, other: Any) -> bool:
752
+ """Checks equality between two BiColor objects.
753
+
754
+ Args:
755
+ other (Any): The object to compare.
756
+
757
+ Returns:
758
+ bool: True if the objects are equal, False otherwise.
759
+ """
760
+
761
+ @dataclass
762
+ class ColorFilterArray(Location, metaclass=ABCMeta):
763
+ """Abstract base class for color filter arrays."""
764
+
765
+ @dataclass
766
+ class SquarePattern(ColorFilterArray, metaclass=ABCMeta):
767
+ """Represents a square pattern color filter array."""
768
+ def __post_init__(self) -> None:
769
+ """Handles post-initialization logic for square pattern color filter arrays.
770
+
771
+ Raises:
772
+ NotImplementedError: Indicates the method is not implemented.
773
+ """
774
+
775
+ @dataclass
776
+ class SparseColorFilterLocation(ColorFilterArray, metaclass=ABCMeta):
777
+ """A color filter array that includes panchromatic pixels with the red, green and blue color components.
778
+
779
+ Different tile patterns can be created.
780
+ """
781
+ fields: tuple[str, str, str, str]
782
+ def __post_init__(self) -> None:
783
+ """Validates the sparse color filter fields during initialization.
784
+
785
+ Raises:
786
+ PixelFormatValueReject: If the field configuration is invalid.
787
+ NotImplementedError: Indicates the method is not implemented.
788
+ """
789
+ Comp = TypeVar('Comp', bound='Components')
790
+
791
+ class Components(metaclass=ABCMeta):
792
+ """Abstract base class for pixel format components."""
793
+ @abstractmethod
794
+ def full_designation(self) -> str:
795
+ """Gets the full designation string for the component.
796
+
797
+ Returns:
798
+ str: The full designation string.
799
+ """
800
+ @abstractmethod
801
+ def channel_designation(self) -> str:
802
+ """Gets the designation string for the channels.
803
+
804
+ Returns:
805
+ str: The channel designation string.
806
+ """
807
+ @abstractmethod
808
+ def location_name(self) -> str:
809
+ """Gets the name of the component's location.
810
+
811
+ Returns:
812
+ str: The location name.
813
+ """
814
+ @property
815
+ def number_of_channels(self) -> int:
816
+ """Returns the number of channels in the component.
817
+
818
+ This is determined by the length of the component.
819
+
820
+ Returns:
821
+ int: The number of channels.
822
+ """
823
+ @abstractmethod
824
+ def __len__(self) -> int:
825
+ """Gets the number of components.
826
+
827
+ Returns:
828
+ int: The number of components.
829
+ """
830
+ @abstractmethod
831
+ def __getitem__(self, item: int) -> Channel:
832
+ """Gets the channel at the specified index.
833
+
834
+ Args:
835
+ item (int): The index of the desired channel.
836
+
837
+ Returns:
838
+ Channel: The channel at the specified index.
839
+ """
840
+ @staticmethod
841
+ def create(full_designation: str) -> list[tuple[Components, str]]:
842
+ """Parses a full designation string into component objects.
843
+
844
+ Iterates through all implementations of the `Components` class, attempting
845
+ to parse the given full designation string into a list of component objects
846
+ and their corresponding substrings.
847
+
848
+ Args:
849
+ full_designation (str): The string to parse into components.
850
+
851
+ Returns:
852
+ list[tuple[Components, str]]: A list of tuples containing the parsed
853
+ components and their remaining substrings.
854
+ """
855
+ @classmethod
856
+ @abstractmethod
857
+ def from_designation(cls, full_designation: str) -> list[tuple[Comp, str]]:
858
+ """Parses a designation string into component objects.
859
+
860
+ Args:
861
+ full_designation (str): The string to parse.
862
+
863
+ Returns:
864
+ list[tuple[Components, str]]: Parsed components and remaining substrings.
865
+ """
866
+
867
+ class GenicamComponents(Components):
868
+ """Represents GenICam-compatible pixel format components."""
869
+ channels: Channels
870
+ location: Location
871
+ color_space_standard: ColorSpaceStandard | None
872
+ def __init__(self, channels: Channels | Channel | Sequence[Channel], location: Location | None = None, color_space_standard: ColorSpaceStandard | None = None) -> None:
873
+ """Initializes a GenICam-compatible component with channels, location, and color space.
874
+
875
+ Args:
876
+ channels (Union[Channels, Channel, Sequence[Channel]]): The channels included in the component.
877
+ location (Optional[Location]): The location information of the component.
878
+ color_space_standard (Optional[ColorSpaceStandard]): The associated color space standard.
879
+ """
880
+ def channel_designation(self) -> str:
881
+ """Gets the designation string for the component's channels.
882
+
883
+ Returns:
884
+ str: The concatenated name of the channels in the component.
885
+ """
886
+ def full_designation(self) -> str:
887
+ """Generates the full designation string for the component.
888
+
889
+ This includes channel and location information, optionally combined with
890
+ the name of the associated color space standard.
891
+
892
+ Returns:
893
+ str: The full designation string of the component.
894
+ """
895
+ def location_name(self) -> str:
896
+ """Gets the name of the component's location.
897
+
898
+ Returns:
899
+ str: The location name.
900
+ """
901
+ def __len__(self) -> int:
902
+ """Gets the number of channels.
903
+
904
+ Returns:
905
+ int: The number of channels.
906
+ """
907
+ def __getitem__(self, item: int) -> Channel:
908
+ """Gets the channel at the specified index.
909
+
910
+ Args:
911
+ item (int): The index of the desired channel.
912
+
913
+ Returns:
914
+ Channel: The channel at the specified index.
915
+ """
916
+ def __eq__(self, other: Any) -> bool:
917
+ """Checks equality between two GenicamComponent objects.
918
+
919
+ Args:
920
+ other (Any): The object to compare.
921
+
922
+ Returns:
923
+ bool: True if the objects are equal, False otherwise.
924
+ """
925
+ @classmethod
926
+ def from_designation(cls, full_designation: str) -> list[tuple[Self, str]]:
927
+ """Parses a designation string into GenicamComponents instances.
928
+
929
+ Args:
930
+ full_designation (str): The full string representing the designation.
931
+
932
+ Returns:
933
+ list[tuple[Components, str]]: A list of tuples containing GenicamComponents and the remaining substring.
934
+
935
+ Logs:
936
+ Warnings are logged if exceptions occur during parsing by location implementations.
937
+ """
938
+
939
+ class CustomComponents(Components, metaclass=ABCMeta):
940
+ """Abstract base class for custom pixel format components."""
941
+
942
+ def bayer_rgb(location: tuple[str, str, str, str], color_space_standard: ColorSpaceStandard | None = None) -> GenicamComponents:
943
+ """Creates a Bayer RGB component.
944
+
945
+ Args:
946
+ location (tuple[str, str, str, str]): The Bayer pattern location.
947
+ color_space_standard (Optional[ColorSpaceStandard]): The associated color space standard.
948
+
949
+ Returns:
950
+ GenicamComponents: The Bayer RGB component.
951
+ """
952
+ def bi_color_rgb(location: tuple[str, str, str, str], color_space_standard: ColorSpaceStandard | None = None) -> GenicamComponents:
953
+ """Creates a Bi-Color RGB component.
954
+
955
+ Args:
956
+ location (tuple[str, str, str, str]): The Bi-Color pattern location.
957
+ color_space_standard (Optional[ColorSpaceStandard]): The associated color space standard.
958
+
959
+ Returns:
960
+ GenicamComponents: The Bi-Color RGB component.
961
+ """
962
+
963
+ class SizedColorSpaceStandard(metaclass=ABCMeta):
964
+ """Abstract base class for size-dependent color space standards."""
965
+ name: str
966
+ def __init__(self, name: str) -> None:
967
+ """Initializes a sized color space standard with a name."""
968
+ @classmethod
969
+ @abstractmethod
970
+ def from_designation(cls, designation_substring: str, comps: Components, sizes: Size) -> list[tuple[Self, str]]:
971
+ """Parses a designation string into a sized color space standard.
972
+
973
+ Args:
974
+ designation_substring (str): The string to parse.
975
+ comps (Components): The associated components.
976
+ sizes (Size): The associated size information.
977
+
978
+ Returns:
979
+ list[tuple[SizedColorSpaceStandard, str]]: Parsed standards and remaining substrings.
980
+ """
981
+ @staticmethod
982
+ def compatible_with(comps: Components, sizes: Size) -> bool:
983
+ """Checks if the components and size are compatible with the standard.
984
+
985
+ Args:
986
+ comps (Components): The components to check.
987
+ sizes (Size): The size information to validate.
988
+
989
+ Returns:
990
+ bool: True if compatible, False otherwise.
991
+ """
992
+ @staticmethod
993
+ def create(designation_substring: str, comps: Components, sizes: Size) -> list[tuple[SizedColorSpaceStandard | None, str]]:
994
+ """Creates sized color space standard objects from a designation substring.
995
+
996
+ Args:
997
+ designation_substring (str): The substring to parse.
998
+ comps (Components): The associated components.
999
+ sizes (Size): The associated size information.
1000
+
1001
+ Returns:
1002
+ list[tuple[Optional[SizedColorSpaceStandard], str]]: Parsed standards and remaining substrings.
1003
+ """
1004
+
1005
+ class RGB10V1(SizedColorSpaceStandard):
1006
+ """Represents the RGB10 V1 color space standard."""
1007
+ def __init__(self) -> None:
1008
+ """Initializes the RGB10 V1 color space standard."""
1009
+ @staticmethod
1010
+ def compatible_with(comps: Components, sizes: Size) -> bool:
1011
+ """Checks if the components and size are compatible with the RGB10 V1 standard.
1012
+
1013
+ Args:
1014
+ comps (Components): The components to check.
1015
+ sizes (Size): The size information to validate.
1016
+
1017
+ Returns:
1018
+ bool: True if compatible, False otherwise.
1019
+ """
1020
+ @classmethod
1021
+ def from_designation(cls, designation_substring: str, comps: Components, sizes: Size) -> list[tuple[Self, str]]:
1022
+ """Parses a designation string into an RGB10 V1 color space standard.
1023
+
1024
+ Args:
1025
+ designation_substring (str): The string to parse.
1026
+ comps (Components): The associated components.
1027
+ sizes (Size): The associated size information.
1028
+
1029
+ Returns:
1030
+ list[tuple[SizedColorSpaceStandard, str]]: Parsed standards and remaining substrings.
1031
+ """
1032
+ def __eq__(self, other: Any) -> bool:
1033
+ """Checks equality between two SizedColorSpaceStandard objects.
1034
+
1035
+ Args:
1036
+ other (Any): The object to compare.
1037
+
1038
+ Returns:
1039
+ bool: True if the objects are equal, False otherwise.
1040
+ """
1041
+
1042
+ class RGB12V1(SizedColorSpaceStandard):
1043
+ """Represents the RGB12 V1 color space standard."""
1044
+ def __init__(self) -> None:
1045
+ """Initializes the RGB12 V1 color space standard."""
1046
+ @staticmethod
1047
+ def compatible_with(comps: Components, sizes: Size) -> bool:
1048
+ """Checks if the components and size are compatible with the RGB12 V1 standard.
1049
+
1050
+ Args:
1051
+ comps (Components): The components to check.
1052
+ sizes (Size): The size information to validate.
1053
+
1054
+ Returns:
1055
+ bool: True if compatible, False otherwise.
1056
+ """
1057
+ @classmethod
1058
+ def from_designation(cls, designation_substring: str, comps: Components, sizes: Size) -> list[tuple[Self, str]]:
1059
+ """Parses a designation string into an RGB12 V1 color space standard.
1060
+
1061
+ Args:
1062
+ designation_substring (str): The string to parse.
1063
+ comps (Components): The associated components.
1064
+ sizes (Size): The associated size information.
1065
+
1066
+ Returns:
1067
+ list[tuple[Self, str]]: Parsed standards and remaining substrings.
1068
+ """
1069
+ def __eq__(self, other: Any) -> bool:
1070
+ """Checks equality between two RGB12V1 objects.
1071
+
1072
+ Args:
1073
+ other (Any): The object to compare.
1074
+
1075
+ Returns:
1076
+ bool: True if the objects are equal, False otherwise.
1077
+ """