Exemplo n.º 1
0
def test_option_changes(sensor):
    options = sensor.get_supported_options()
    for option in options:
        try:
            if sensor.is_option_read_only(option):
                continue
            old_value = sensor.get_option(option)
            range = sensor.get_option_range(option)
            new_value = range.min
            if old_value == new_value:
                new_value = range.max
            if not log.d(str(option), old_value, '->', new_value):
                test.info(str(option), new_value, persistent=True)
            set_new_value(sensor, option, new_value)
            sensor.set_option(option, old_value)
        except:
            test.unexpected_exception()
            break
        finally:
            test.reset_info(persistent=True)
Exemplo n.º 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
Exemplo n.º 3
0
depth_options = depth_sensor.get_supported_options()
color_options = color_sensor.get_supported_options()

test.start("Checking for frame drops when setting any option")

for option in depth_options:
    try:
        if depth_sensor.is_option_read_only(option):
            continue
        old_value = depth_sensor.get_option(option)
        range = depth_sensor.get_option_range(option)
        new_value = range.min
        if old_value == new_value:
            new_value = range.max
        if not log.d(str(option), old_value, '->', new_value):
            test.info(str(option), new_value, persistent=True)
        set_new_value(depth_sensor, option, new_value)
        depth_sensor.set_option(option, old_value)
    except:
        test.unexpected_exception()
        test.abort()
    finally:
        test.reset_info(persistent=True)

for option in color_options:
    try:
        if color_sensor.is_option_read_only(option):
            continue
        new_value = color_sensor.get_option_range(option).min
        set_new_value(color_sensor, option, new_value)
    except:
Exemplo n.º 4
0
# Test #2

depth_options = depth_sensor.get_supported_options()
color_options = color_sensor.get_supported_options()

test.start("Checking for frame drops when setting any option")

for option in depth_options:
    try:
        if depth_sensor.is_option_read_only(option):
            continue
        new_value = depth_sensor.get_option_range(option).min
        set_new_value(depth_sensor, option, new_value)
    except:
        option_name = "Depth sensor - " + str(option)
        test.info(option_name, new_value)
        test.unexpected_exception()
        test.abort()

for option in color_options:
    try:
        if color_sensor.is_option_read_only(option):
            continue
        new_value = color_sensor.get_option_range(option).min
        set_new_value(color_sensor, option, new_value)
    except:
        option_name = "Color sensor - " + str(option)
        test.info(option_name, new_value)
        test.unexpected_exception()
        test.abort()
Exemplo n.º 5
0
#
#############################################################################################
#
test.start("Stop giving color; wait_for_frames() should throw (after 5s)")

sw.generate_depth_frame(5, sw.gap_d * 5)

# We expect the syncer to try and wait for a Color frame to fit the Depth we just gave it.
# The syncer relies on frame inputs to actually run -- and, if we wait for a frame, we're
# not feeding it frames so can't get back any, either.
try:
    fs = sw.syncer.wait_for_frames()
except RuntimeError as e:
    test.check_exception(e, RuntimeError, "Frame did not arrive in time!")
else:
    test.info("Unexpected frameset", fs)
    test.unreachable()

test.finish()
#
#############################################################################################
#
test.start(
    "try_wait_for_frames() allows us to keep feeding frames; eventually we get one"
)

# The syncer will not immediately release framesets because it's still waiting for a color frame to
# match Depth #10. But, if we advance the timestamp sufficiently, it should eventually release it
# as it deems Color "inactive".

# The last color frame we sent was at gap*4, so it's next expected at gap*5 plus a buffer of gap*7