Skip to content

Commit

Permalink
PR #12449 from AviaAv: image quality test - adding comparison to lase…
Browse files Browse the repository at this point in the history
…r off if depth is detected
  • Loading branch information
Nir-Az committed Dec 3, 2023
2 parents c918402 + 2fe2802 commit bfe95cd
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions unit-tests/live/image-quality/test-image-quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Defines how far in cm do pixels have to be, to be considered in a different distance
# for example, 10 for 10cm, will define the range 100-109 cm as one (as 100)
DETAIL_LEVEL = 10
FRAMES_TO_CHECK = 30

dev = test.find_first_device_or_exit()

Expand Down Expand Up @@ -172,10 +173,24 @@ def is_depth_meaningful(config, laser_enabled=True, save_image=False, show_image
################################################################################################

test.start("Testing depth frame - laser ON -", dev.get_info(rs.camera_info.name))
res, laser_black_pixels = is_depth_meaningful(cfg, laser_enabled=True, save_image=DEBUG_MODE, show_image=DEBUG_MODE)
test.check(res is True)
test.finish()
is_there_depth = False
max_black_pixels = float('inf')

################################################################################################
# we perform the check on a few different frames to make sure we get the best indication if we have depth
for frame_num in range(FRAMES_TO_CHECK):
result, laser_black_pixels = is_depth_meaningful(cfg, laser_enabled=True, save_image=DEBUG_MODE, show_image=DEBUG_MODE)
is_there_depth = is_there_depth or result # we check if we found depth at any frame checked
max_black_pixels = min(max_black_pixels, laser_black_pixels)

test.check(is_there_depth is True)
test.finish()

# if there is no depth, we might get different results running this test, so we only run it if we actually find depth
if is_there_depth is True:
test.start("Testing less black pixels present with the laser on")
is_there_depth, no_laser_black_pixels = is_depth_meaningful(cfg, laser_enabled=False, save_image=DEBUG_MODE, show_image=DEBUG_MODE)
test.check(no_laser_black_pixels > max_black_pixels)
test.finish()
else:
log.i("Frame has no depth!")
test.print_results_and_exit()

0 comments on commit bfe95cd

Please sign in to comment.