Skip to content

Commit 147eec1

Browse files
FlorinBuica-luxonisalex-luxonis
authored andcommitted
add amplitude separately
-- cherry-picked, with few more ToF related changes included
1 parent 2c43c8c commit 147eec1

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

utilities/cam_test.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,19 @@ def socket_type_pair(arg):
8181
help="Make OpenCV windows resizable. Note: may introduce some artifacts")
8282
parser.add_argument('-tun', '--camera-tuning', type=Path,
8383
help="Path to custom camera tuning database")
84-
parser.add_argument('-d', '--device', default="", type=str,
85-
help="Optional MX ID of the device to connect to.")
8684
parser.add_argument('-raw', '--enable-raw', default=False, action="store_true",
8785
help='Enable the RAW camera streams')
86+
parser.add_argument('-tofraw', '--tof-raw', action='store_true',
87+
help="Show just ToF raw output instead of post-processed depth")
88+
parser.add_argument('-tofamp', '--tof-amplitude', action='store_true',
89+
help="Show also ToF amplitude output alongside depth")
90+
parser.add_argument('-tofcm', '--tof-cm', action='store_true',
91+
help="Show ToF depth output in centimeters, capped to 255")
92+
parser.add_argument('-rgbprev', '--rgb-preview', action='store_true',
93+
help="Show RGB `preview` stream instead of full size `isp`")
94+
95+
parser.add_argument('-d', '--device', default="", type=str,
96+
help="Optional MX ID of the device to connect to.")
8897

8998
parser.add_argument('-ctimeout', '--connection-timeout', default=30000,
9099
help="Connection timeout in ms. Default: %(default)s (sets DEPTHAI_CONNECTION_TIMEOUT environment variable)")
@@ -188,6 +197,7 @@ def get(self):
188197
tof = {}
189198
xout = {}
190199
xout_raw = {}
200+
xout_tof_amp = {}
191201
streams = []
192202
tofConfig = {}
193203
for c in cam_list:
@@ -209,6 +219,12 @@ def get(self):
209219
tofConfig.depthParams.avgPhaseShuffle = False
210220
tofConfig.depthParams.minimumAmplitude = 3.0
211221
tof[c].initialConfig.set(tofConfig)
222+
if args.tof_amplitude:
223+
amp_name = 'tof_amplitude_' + c
224+
xout_tof_amp[c] = pipeline.create(dai.node.XLinkOut)
225+
xout_tof_amp[c].setStreamName(amp_name)
226+
streams.append(amp_name)
227+
tof[c].amplitude.link(xout_tof_amp[c].input)
212228
elif cam_type_color[c]:
213229
cam[c] = pipeline.createColorCamera()
214230
cam[c].setResolution(color_res_opts[args.color_resolution])
@@ -240,7 +256,7 @@ def get(self):
240256
xout_raw[c] = pipeline.create(dai.node.XLinkOut)
241257
xout_raw[c].setStreamName(raw_name)
242258
streams.append(raw_name)
243-
tof[c].amplitude.link(xout_raw[c].input)
259+
cam[c].raw.link(xout_raw[c].input)
244260
cam[c].setRawOutputPacked(False)
245261

246262
if args.camera_tuning:
@@ -271,6 +287,8 @@ def exit_cleanly(signum, frame):
271287
cam_name[p.socket.name] = p.sensorName
272288
if args.enable_raw:
273289
cam_name['raw_'+p.socket.name] = p.sensorName
290+
if args.tof_amplitude:
291+
cam_name['tof_amplitude_'+p.socket.name] = p.sensorName
274292

275293
print('USB speed:', device.getUsbSpeed().name)
276294

@@ -352,7 +370,7 @@ def exit_cleanly(signum, frame):
352370
fps_capt[c].update(pkt.getTimestamp().total_seconds())
353371
width, height = pkt.getWidth(), pkt.getHeight()
354372
frame = pkt.getCvFrame()
355-
if cam_type_tof[c.split('_')[-1]] and not c.startswith('raw_'):
373+
if cam_type_tof[c.split('_')[-1]] and not (c.startswith('raw_') or c.startswith('tof_amplitude_')):
356374
if args.tof_cm:
357375
# pixels represent `cm`, capped to 255. Value can be checked hovering the mouse
358376
frame = (frame // 10).clip(0, 255).astype(np.uint8)
@@ -379,7 +397,7 @@ def exit_cleanly(signum, frame):
379397
)
380398
capture_list.remove(c)
381399
print()
382-
if c.startswith('raw_'):
400+
if c.startswith('raw_') or c.startswith('tof_amplitude_'):
383401
if capture:
384402
filename = capture_file_info + '_10bit.bw'
385403
print('Saving:', filename)

0 commit comments

Comments
 (0)