Skip to content

Commit cc6ea3e

Browse files
committed
cam_test.py: fix KeyError due to socket name changes, add -cams cama/camb/camc options
1 parent 091845e commit cc6ea3e

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

utilities/cam_test.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
def socket_type_pair(arg):
5050
socket, type = arg.split(',')
51-
if not (socket in ['rgb', 'left', 'right', 'camd']):
51+
if not (socket in ['rgb', 'left', 'right', 'cama', 'camb', 'camc', 'camd']):
5252
raise ValueError("")
5353
if not (type in ['m', 'mono', 'c', 'color']):
5454
raise ValueError("")
@@ -112,20 +112,19 @@ def socket_type_pair(arg):
112112
'rgb' : dai.CameraBoardSocket.CAM_A,
113113
'left' : dai.CameraBoardSocket.CAM_B,
114114
'right': dai.CameraBoardSocket.CAM_C,
115+
'cama' : dai.CameraBoardSocket.CAM_A,
116+
'camb' : dai.CameraBoardSocket.CAM_B,
117+
'camc' : dai.CameraBoardSocket.CAM_C,
115118
'camd' : dai.CameraBoardSocket.CAM_D,
116119
}
117120

118-
cam_socket_to_name = {
119-
'RGB': 'rgb',
120-
'LEFT': 'left',
121-
'RIGHT': 'right',
122-
'CAM_D': 'camd',
123-
}
124-
125121
rotate = {
126122
'rgb': args.rotate in ['all', 'rgb'],
127123
'left': args.rotate in ['all', 'mono'],
128124
'right': args.rotate in ['all', 'mono'],
125+
'cama': args.rotate in ['all', 'rgb'],
126+
'camb': args.rotate in ['all', 'mono'],
127+
'camc': args.rotate in ['all', 'mono'],
129128
'camd': args.rotate in ['all', 'rgb'],
130129
}
131130

@@ -231,7 +230,7 @@ def exit_cleanly(signum, frame):
231230
f' -socket {p.socket.name:6}: {p.sensorName:6} {p.width:4} x {p.height:4} focus:', end='')
232231
print('auto ' if p.hasAutofocus else 'fixed', '- ', end='')
233232
print(*[type.name for type in p.supportedTypes])
234-
cam_name[cam_socket_to_name[p.socket.name]] = p.sensorName
233+
cam_name[p.socket.name] = p.sensorName
235234

236235
print('USB speed:', device.getUsbSpeed().name)
237236

@@ -311,7 +310,7 @@ def exit_cleanly(signum, frame):
311310
frame = pkt.getCvFrame()
312311
if c in capture_list:
313312
width, height = pkt.getWidth(), pkt.getHeight()
314-
capture_file_name = ('capture_' + c + '_' + cam_name[c]
313+
capture_file_name = ('capture_' + c + '_' + cam_name[cam_socket_opts[c].name]
315314
+ '_' + str(width) + 'x' + str(height)
316315
+ '_exp_' +
317316
str(int(

0 commit comments

Comments
 (0)