1
- from typing import List , Optional , Union
1
+ from typing import List , Optional , Union , Tuple
2
2
3
3
import depthai as dai
4
4
@@ -21,6 +21,7 @@ def __init__(
21
21
pipeline : dai .Pipeline ,
22
22
source : Union [str , dai .CameraBoardSocket , None ] = None ,
23
23
align_to : Optional [CameraComponent ] = None ,
24
+ fps : Optional [int ] = None ,
24
25
):
25
26
super ().__init__ ()
26
27
self .out = self .Out (self )
@@ -40,17 +41,19 @@ def __init__(
40
41
self .camera_node .setBoardSocket (source )
41
42
self .camera_socket = source
42
43
43
- self .node = pipeline .create (dai .node .ToF )
44
+ if fps is not None :
45
+ self .camera_node .setFps (fps )
46
+
47
+ self .node : dai .node .ToF = pipeline .create (dai .node .ToF )
44
48
self ._control_in = pipeline .create (dai .node .XLinkIn )
45
49
self .camera_node .raw .link (self .node .input )
46
50
self ._control_in .setStreamName (f"{ self .node .id } _inputControl" )
47
51
self ._control_in .out .link (self .node .inputConfig )
48
52
53
+ self ._align_to_output : dai .Node .Output = None
54
+
49
55
if align_to is not None :
50
- self ._align = pipeline .create (dai .node .ImageAlign )
51
- self ._align_to_output = align_to .node .isp
52
- self .node .depth .link (self ._align .input )
53
- self ._align_to_output .link (self ._align .inputAlignTo )
56
+ self .set_align_to (align_to )
54
57
55
58
def _find_tof (self , device : dai .Device ) -> dai .CameraBoardSocket :
56
59
# Use the first ToF sensor, usually, there will only be one
@@ -62,14 +65,34 @@ def _find_tof(self, device: dai.Device) -> dai.CameraBoardSocket:
62
65
f"No ToF sensor found on this camera! { device .getConnectedCameraFeatures ()} "
63
66
)
64
67
65
- def set_align_to (self , align_to : CameraComponent ) -> None :
68
+ def set_align_to (self , align_to : CameraComponent , output_size : Optional [ Tuple ] = None ) -> None :
66
69
if self ._align is None :
67
70
self ._align = self ._pipeline .create (dai .node .ImageAlign )
68
71
self .node .depth .link (self ._align .input )
69
72
if align_to .is_mono ():
70
- align_to .node .out . link ( self . _align . inputAlignTo )
73
+ self . _align_to_output = align_to .node .out
71
74
else :
72
- align_to .node .isp .link (self ._align .inputAlignTo )
75
+ self ._align_to_output = align_to .node .isp
76
+
77
+ self ._align_to_output .link (self ._align .inputAlignTo )
78
+
79
+ if output_size is not None :
80
+ self ._align .setOutputSize (* output_size )
81
+
82
+
83
+ def configure_tof (self ,
84
+ phaseShuffleTemporalFilter : bool = None ,
85
+ phaseUnwrappingLevel : int = None ,
86
+ phaseUnwrapErrorThreshold : int = None ,
87
+ ) -> None :
88
+ tofConfig = self .node .initialConfig .get ()
89
+ if phaseShuffleTemporalFilter is not None :
90
+ tofConfig .enablePhaseShuffleTemporalFilter = phaseShuffleTemporalFilter
91
+ if phaseUnwrappingLevel is not None :
92
+ tofConfig .phaseUnwrappingLevel = phaseUnwrappingLevel
93
+ if phaseUnwrapErrorThreshold is not None :
94
+ tofConfig .phaseUnwrapErrorThreshold = phaseUnwrapErrorThreshold
95
+ self .node .initialConfig .set (tofConfig )
73
96
74
97
def on_pipeline_started (self , device : dai .Device ) -> None :
75
98
self .control .set_input_queue (
0 commit comments