Exemple #1
0
        def analysis(self):
            print("Number of frame drops is {}".format(self.count_drops))
            for k, v in self.frame_drops_info:
                print("Number of dropped frame before frame ", k, ", is :", v)

            test.check(self.count_drops == 0)
            test.finish()
Exemple #2
0
def expect(depth_frame=None, color_frame=None, nothing_else=False):
    """
    Looks at the syncer queue and gets the next frame from it if available, checking its contents
    against the expected frame numbers.
    """
    global syncer, playback_status
    f = syncer.poll_for_frame()
    if playback_status is not None:
        countdown = 50  # 5 seconds
        while not f and playback_status != rs.playback_status.stopped:
            countdown -= 1
            if countdown == 0:
                break
            time.sleep(0.1)
            f = syncer.poll_for_frame()
    # NOTE: f will never be None
    if not f:
        test.check(depth_frame is None, "expected a depth frame")
        test.check(color_frame is None, "expected a color frame")
        return False

    log.d("Got", f)

    fs = rs.composite_frame(f)

    if fs:
        depth = fs.get_depth_frame()
    else:
        depth = rs.depth_frame(f)
    test.info("actual depth", depth)
    test.check_equal(depth_frame is None, not depth)
    if depth_frame is not None and depth:
        test.check_equal(depth.get_frame_number(), depth_frame)

    if fs:
        color = fs.get_color_frame()
    elif not depth:
        color = rs.video_frame(f)
    else:
        color = None
    test.info("actual color", color)
    test.check_equal(color_frame is None, not color)
    if color_frame is not None and color:
        test.check_equal(color.get_frame_number(), color_frame)

    if nothing_else:
        f = syncer.poll_for_frame()
        test.info("Expected nothing else; actual", f)
        test.check(not f)

    return True
Exemple #3
0
            return 1
        if int(n1) < int(n2):
            return -1
    return 0


if compare_fw_versions(current_fw_version, bundled_fw_version) == 0:
    # Current is same as bundled
    if recovered or test.context != 'nightly':
        # In nightly, we always update; otherwise we try to save time, so do not do anything!
        log.d('versions are same; skipping FW update')
        test.finish()
        test.print_results_and_exit()
else:
    # It is expected that, post-recovery, the FW versions will be the same
    test.check(not recovered, abort_if_failed=True)

update_counter = get_update_counter(device)
log.d('update counter:', update_counter)
if update_counter >= 19:
    log.d('resetting update counter')
    reset_update_counter(device)
    update_counter = 0

# finding file containing image for FW update
image_name = product_line[0:2] + "XX_FW_Image-" + bundled_fw_version + ".bin"
image_mask = '(^|/)' + image_name + '$'
image_file = None
for image in file.find(repo.root, image_mask):
    image_file = os.path.join(repo.root, image)
if not image_file:
Exemple #4
0
    test.finish()
    test.print_results_and_exit()

for i in range(test_iterations):
    log.d("{} Iteration {} {}".format("=" * 50, i, "=" * 50))

    # Reset Control values
    log.d("Resetting Controls...")

    if (depth_ir_sensor.supports(rs.option.enable_auto_exposure)):
        depth_ir_sensor.set_option(rs.option.enable_auto_exposure, 0)
    if (depth_ir_sensor.supports(rs.option.exposure)):
        depth_ir_sensor.set_option(rs.option.exposure, 1)

        depth_ir_sensor.set_option(rs.option.gain, 248)

    log.d("Resetting Controls Done")

    time.sleep(0.1)
    for val in gain_values:
        log.d("Setting Gain To: {}".format(val))
        depth_ir_sensor.set_option(rs.option.gain, val)
        get_val = depth_ir_sensor.get_option(rs.option.gain)
        test.check(val == get_val)
        log.d("Gain Set To: {}".format(get_val))

test.finish()

################################################################################################
test.print_results_and_exit()
    return first_frame_time


# The device starts at D0 (Operational) state, allow time for it to get into idle state
time.sleep(3)

#####################################################################################################
test.start("Testing device creation time on " + platform.system() + " OS")
device_creation_stopwatch = Stopwatch()
dev = test.find_first_device_or_exit()
device_creation_time = device_creation_stopwatch.get_elapsed()
max_time_for_device_creation = 1.5
print("Device creation time is: {:.3f} [sec] max allowed is: {:.1f} [sec] ".
      format(device_creation_time, max_time_for_device_creation))
test.check(device_creation_time < max_time_for_device_creation)
test.finish()

# Set maximum delay for first frame according to product line
product_line = dev.get_info(rs.camera_info.product_line)
if product_line == "D400":
    max_delay_for_depth_frame = 1.5
    max_delay_for_color_frame = 1.5
elif product_line == "L500":
    max_delay_for_depth_frame = 2.5  # L515 depth frame has a 1.5 seconds built in delay at the FW side + 1.0 second for LRS
    max_delay_for_color_frame = 1.5
else:
    log.f("This test support only D400 + L515 devices")

ds = dev.first_depth_sensor()
cs = dev.first_color_sensor()
Exemple #6
0
def check_firmware_compatible(updatable_device, fw_image):
    test.check(updatable_device.check_firmware_compatibility(fw_image))
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2021 Intel Corporation. All Rights Reserved.

#test:device each(L500*)
#test:device each(D400*)
#test:priority 1
#test:flag windows

import pyrealsense2 as rs
from rspy import test, log

test.start("checking metadata is enabled")
dev = test.find_first_device_or_exit()
test.check(dev.is_metadata_enabled())

test.finish()
test.print_results_and_exit()
        if list[i - 1] == list[i] == rs.calibration_status.special_frame:
            del list[i]
        else:
            i += 1

#############################################################################################
# Test #1
test.start("Depth sensor is off, should get an error")
try:
    d2r.trigger_device_calibration( rs.calibration_type.manual_depth_to_rgb )
    ac.wait_for_calibration()
except Exception as e:
    test.check_exception(e, RuntimeError, "not streaming")
else:
    test.unexpected_exception() # No error Occurred, should have received a RuntimeError
test.check(ac.status_list_is_empty()) # No status changes are expected, list should remain empty
test.finish()

#############################################################################################
# Test #2
test.start("Color sensor is off, calibration should succeed")
ac.reset_status_list() # Deleting previous test
depth_sensor.open( dp )
depth_sensor.start( lambda f: None )
try:
    d2r.trigger_device_calibration( rs.calibration_type.manual_depth_to_rgb )
    ac.wait_for_calibration()
    ac.trim_irrelevant_statuses(irrelevant_statuses)
    filter_special_frames( ac.status_list )
    test.check_equal_lists(ac.status_list, successful_calibration_status_list)
except Exception:
Exemple #9
0
import pyrealsense2 as rs
from rspy import test,ac

devices = test.find_devices_by_product_line_or_exit(rs.product_line.L500)
depth_sensor = devices[0].first_depth_sensor()

debug_sensor = rs.debug_stream_sensor(depth_sensor)
debug_profiles = debug_sensor.get_debug_stream_profiles()


#############################################################################################
test.start("FG isn't exposed by get_stream_profiles")

matches = list(p for p in depth_sensor.profiles if p.format() == rs.format.fg)
test.check(len(matches) == 0 )
test.finish()

#############################################################################################
test.start("FG exposed by debug_stream_sensor")

matches = list(p for p in debug_profiles if p.format() == rs.format.fg)
test.check(len(matches) > 0 )
test.finish()

#############################################################################################
test.start("streaming FG 800x600")

dp = next(p for p in debug_profiles if p.fps() == 30
                        and p.stream_type() == rs.stream.depth
                        and p.format() == rs.format.fg
Exemple #10
0
test.start("checking depth units on metadata")

dev = test.find_first_device_or_exit()
depth_sensor = dev.first_depth_sensor()

try:
    cfg = pipeline = None
    pipeline = rs.pipeline()
    cfg = rs.config()
    pipeline_profile = pipeline.start(cfg)

    # Check that depth units on meta data is non zero
    frame_set = pipeline.wait_for_frames()
    depth_frame = frame_set.get_depth_frame()
    depth_units_from_metadata = depth_frame.get_units()
    test.check(depth_units_from_metadata > 0)

    # Check metadata depth unit value match option value
    dev = pipeline_profile.get_device()
    ds = dev.first_depth_sensor()
    test.check(ds.supports(rs.option.depth_units))
    test.check_equal(ds.get_option(rs.option.depth_units),
                     depth_units_from_metadata)

    pipeline.stop()

except Exception:
    test.unexpected_exception()

test.finish()
test.print_results_and_exit()
test.start("Ask for depth only - make sure only depth frames arrive")

depth_sensor.open(dp)
depth_sensor.start(frames_counter)
wait_frames_timer.start()

# we wait for first NUMBER_OF_FRAMES_BEFORE_CHECK frames OR MAX_TIME_TO_WAIT_FOR_FRAMES seconds
while (not wait_frames_timer.has_expired() 
    and n_depth_frame + n_ir_frame < NUMBER_OF_FRAMES_BEFORE_CHECK):
    time.sleep(1)

if wait_frames_timer.has_expired():
    print(str(NUMBER_OF_FRAMES_BEFORE_CHECK) + " frames did not arrived at "+ str(MAX_TIME_TO_WAIT_FOR_FRAMES) + " seconds , abort...")
    test.fail()
else:
    test.check(n_depth_frame >= NUMBER_OF_FRAMES_BEFORE_CHECK)
    test.check_equal(n_ir_frame, 0)

depth_sensor.stop()
depth_sensor.close()

time.sleep(1) # Allow time to ensure no more frame callbacks after stopping sensor

test.finish()

n_depth_frame = 0
n_ir_frame = 0

# Test Part 2
test.start("Ask for depth+IR - make sure both frames arrive")
test.start("D405 explicit configuration - IR calibration, Color in HD")
try:
    pipeline = rs.pipeline()
    config = rs.config()
    config.enable_stream(rs.stream.infrared, 1, 1288, 808, rs.format.y16, 15)
    config.enable_stream(rs.stream.infrared, 2, 1288, 808, rs.format.y16, 15)
    config.enable_stream(rs.stream.color, 1280, 720, rs.format.rgb8, 15)
    pipeline.start(config)

    iteration = 0
    while True:
        iteration = iteration + 1
        if iteration > 10:
            break
        frames = pipeline.wait_for_frames()
        test.check(frames.size() == 3)
        ir_1_stream_found = False
        ir_2_stream_found = False
        color_stream_found = False
        for f in frames:
            profile = f.get_profile()
            if profile.stream_type() == rs.stream.infrared:
                if profile.stream_index() == 1:
                    ir_1_stream_found = True
                elif profile.stream_index() == 2:
                    ir_2_stream_found = True
            elif profile.stream_type() == rs.stream.color:
                color_stream_found = True
        test.check(ir_1_stream_found and ir_2_stream_found
                   and color_stream_found)
    pass
    depth_sensor = playback.first_depth_sensor()
    color_sensor = playback.first_color_sensor()

    restart_profiles()

    depth_sensor.open(dp)
    depth_sensor.start(depth_frame_call_back)
    color_sensor.open(cp)
    color_sensor.start(color_frame_call_back)

    time.sleep(3)

    # if record and playback worked we will receive frames, the callback functions will be called and got-frames
    # will be True. If the record and playback failed it will be false
    test.check(got_frames_depth)
    test.check(got_frames_rgb)
except Exception:
    test.unexpected_exception()
finally:  # we must remove all references to the file so we can use it again in the next test
    stop_sensor(depth_sensor)
    depth_sensor = None
    stop_sensor(color_sensor)
    color_sensor = None
    if recorder:
        recorder = None
    if playback:
        playback = None

test.finish()
Exemple #14
0
    pipe = rs.pipeline()
    start_call_stopwatch = Stopwatch()
    pipe.start(config)
    pipe.wait_for_frames()
    delay = start_call_stopwatch.get_elapsed()
    pipe.stop()
    return delay


################################################################################################
test.start("Testing pipeline first depth frame delay on " + product_line + " device - " + platform.system() + " OS")
depth_cfg = rs.config()
depth_cfg.enable_stream(rs.stream.depth, rs.format.z16, 30)
frame_delay = time_to_first_frame(depth_cfg)
print("Delay from pipeline.start() until first depth frame is: {:.3f} [sec] max allowed is: {:.1f} [sec] ".format(frame_delay, max_delay_for_depth_frame))
test.check(frame_delay < max_delay_for_depth_frame)
test.finish()


################################################################################################
test.start("Testing pipeline first color frame delay on " + product_line + " device - " + platform.system() + " OS")
color_cfg = rs.config()
color_cfg.enable_stream(rs.stream.color, rs.format.rgb8, 30)
frame_delay = time_to_first_frame(color_cfg)
print("Delay from pipeline.start() until first color frame is: {:.3f} [sec] max allowed is: {:.1f} [sec] ".format(frame_delay, max_delay_for_color_frame))
test.check(frame_delay < max_delay_for_color_frame)
test.finish()


################################################################################################
test.print_results_and_exit()
    depth_sensor = playback.first_depth_sensor()
    color_sensor = playback.first_color_sensor()

    restart_profiles()

    depth_sensor.open(dp)
    depth_sensor.start(depth_frame_call_back)
    color_sensor.open(cp)
    color_sensor.start(color_frame_call_back)

    time.sleep(3)

    # if record and playback worked we will receive frames, the callback functions will be called and got-frames
    # will be True. If the record and playback failed it will be false
    test.check(got_frames)
except Exception:
    test.unexpected_exception()
finally:  # we must remove all references to the file so we can use it again in the next test
    if recorder:
        recorder.pause()
        recorder = None
    if playback:
        playback.pause()
        playback = None
    stop_sensor(depth_sensor)
    depth_sensor = None
    stop_sensor(color_sensor)
    color_sensor = None

test.finish()
lrs_fq = LRSFrameQueueManager()
lrs_fq.register_callback(cb)

pipe = rs.pipeline()
test.start("Testing color frame drops on " + product_line + " device ")
for i in range(iterations):
    lrs_fq.start()
    print('iteration #{}'.format(i))
    hw_ts = []
    print('\tStart stream'.format(i))
    cfg = rs.config()
    cfg.enable_stream(rs.stream.color, width, height, _format, fps)
    pipe.start(cfg, lrs_fq.lrs_queue)
    time.sleep(sleep)
    print('\tStop stream'.format(i))
    pipe.stop()

    expected_delta = 1000 / fps
    deltas_ms = [(ts1 - ts2) / 1000 for ts1, ts2 in zip(hw_ts[1:], hw_ts[:-1])]
    count_drops = False
    for idx, delta in enumerate(deltas_ms, 1):
        if delta > (expected_delta * 1.95):
            count_drops = True
            print('\tFound drop #{} actual delta {} vs expected delta: {}'.
                  format(idx, delta, expected_delta))
    lrs_fq.stop()

    test.check(not count_drops)
    test.finish()