Skip to content

Commit ae60f11

Browse files
committed
cam_test.py: / to toggle printing camera settings: exp/ISO/lens/colortemp
1 parent c4b58d6 commit ae60f11

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

utilities/cam_test.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
For the 'Select control: ...' options, use these keys to modify the value:
3131
'-' or '_' to decrease
3232
'+' or '=' to increase
33+
34+
'/' to toggle printing camera settings: exposure, ISO, lens position, color temperature
3335
"""
3436

3537
import os
@@ -310,6 +312,7 @@ def exit_cleanly(signum, frame):
310312
luma_denoise = 0
311313
chroma_denoise = 0
312314
control = 'none'
315+
show = False
313316

314317
print("Cam:", *[' ' + c.ljust(8)
315318
for c in cam_list], "[host | capture timestamp]")
@@ -327,6 +330,13 @@ def exit_cleanly(signum, frame):
327330
fps_capt[c].update(pkt.getTimestamp().total_seconds())
328331
width, height = pkt.getWidth(), pkt.getHeight()
329332
frame = pkt.getCvFrame()
333+
if show:
334+
txt = f"[{c:5}, {pkt.getSequenceNum():4}] "
335+
txt += f"Exp: {pkt.getExposureTime().total_seconds()*1000:6.3f} ms, "
336+
txt += f"ISO: {pkt.getSensitivity():4}, "
337+
txt += f"Lens pos: {pkt.getLensPosition():3}, "
338+
txt += f"Color temp: {pkt.getColorTemperature()} K"
339+
print(txt)
330340
capture = c in capture_list
331341
if capture:
332342
capture_file_info = ('capture_' + c + '_' + cam_name[c]
@@ -365,13 +375,17 @@ def exit_cleanly(signum, frame):
365375
cv2.imwrite(filename, frame)
366376
cv2.imshow(c, frame)
367377
print("\rFPS:",
368-
*["{:6.2f}|{:6.2f}".format(fps_host[c].get(),
369-
fps_capt[c].get()) for c in cam_list],
370-
end='', flush=True)
378+
*["{:6.2f}|{:6.2f}".format(fps_host[c].get(), fps_capt[c].get()) for c in cam_list],
379+
end=' ', flush=True)
380+
if show: print()
371381

372382
key = cv2.waitKey(1)
373383
if key == ord('q'):
374384
break
385+
elif key == ord('/'):
386+
show = not show
387+
# Print empty string as FPS status new-line separator
388+
print("" if show else "Printing camera settings: OFF")
375389
elif key == ord('c'):
376390
capture_list = streams.copy()
377391
capture_time = time.strftime('%Y%m%d_%H%M%S')

0 commit comments

Comments
 (0)