Exemple #1
0
    test.check(not updatable_device.check_firmware_compatibility(fw_image))


def check_firmware_compatible(updatable_device, fw_image):
    test.check(updatable_device.check_firmware_compatibility(fw_image))

def get_fw_version_path(product_line_dir, fw_version):
    return fw_dir + product_line_dir + fw_version

ctx = rs.context()
dev = ctx.query_devices()[0]
updatable_device = dev.as_updatable()
product_line_dir = dev.get_info(rs.camera_info.product_line) + '/'

#############################################################################################
test.start("checking firmware compatibility with device")
# test scenario:
# get min fw for device, check compatibility, check one before is not compatible
# get max fw for device, check compatibility, check one after is not compatible
# skip any case that is not applicable (for example, max version to check is only for SR300)
pid = dev.get_info(rs.camera_info.product_id)
print(dev.get_info(rs.camera_info.name) + " found")

if pid in pid_to_min_fw_version:
    min_fw_version = pid_to_min_fw_version[pid]
    min_fw_version_path = get_fw_version_path(product_line_dir, min_fw_version)
    print("fw min version: " + min_fw_version)
    with open(min_fw_version_path, 'rb') as binary_file:
        fw_image = bytearray(binary_file.read())
        check_firmware_compatible(updatable_device, fw_image)
    rs.format.yuyv and p.as_video_stream_profile().width() == 1280
    and p.as_video_stream_profile().height() == 720)

dp = next(
    p for p in depth_sensor.profiles
    if p.fps() == 30 and p.stream_type() == rs.stream.depth and p.format() ==
    rs.format.z16 and p.as_video_stream_profile().width() == 1024
    and p.as_video_stream_profile().height() == 768)

depth_sensor.open(dp)
depth_sensor.start(lambda f: None)
color_sensor.open(cp)
color_sensor.start(lambda f: None)

#############################################################################################
test.start("Failing check_conditions function")
# If ambient light is RS2_DIGITAL_GAIN_LOW (2) receiver_gain must be 18
# If ambient light is RS2_DIGITAL_GAIN_HIGH (1) receiver_gain must be 9
old_receiver_gain = depth_sensor.get_option(rs.option.receiver_gain)
depth_sensor.set_option(rs.option.receiver_gain, 15)
try:
    d2r.trigger_device_calibration(rs.calibration_type.manual_depth_to_rgb)
    test.unreachable()
    ac.wait_for_calibration()
except Exception as e:
    test.check_exception(e, RuntimeError)
else:
    test.unexpected_exception()
test.check_equal_lists(ac.status_list, [rs.calibration_status.bad_conditions])
depth_sensor.set_option(rs.option.receiver_gain, old_receiver_gain)
test.finish()
# 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()
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2021 Intel Corporation. All Rights Reserved.

#test:timeout 20

import os
import pyrealsense2 as rs2
from rspy import test
import tempfile

# This test checks that stop of pipeline with playback file
# and non realtime mode is not stuck due to deadlock of
# pipeline stop thread and syncer blocking enqueue thread (DSO-15157)
#############################################################################################
test.start("Playback with non realtime isn't stuck at stop")

filename = tempfile.gettempdir() + os.sep + 'recording_deadlock.bag'

pipeline = rs2.pipeline()
config = rs2.config()
config.enable_all_streams()
config.enable_device_from_file(filename, repeat_playback=False)
profile = pipeline.start(config)
device = profile.get_device().as_playback().set_real_time(False)
success = True
while success:
    success, _ = pipeline.try_wait_for_frames(1000)
print("stopping...")
pipeline.stop()
print("stopped")
Exemple #5
0
else:
    log.f("This test support only D400 + L515 devices")


def time_to_first_frame(config):
    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)
Exemple #6
0
if not fw_updater_exe:
    log.f("Could not find the update tool file (rs-fw-update.exe)")

devices.query(monitor_changes=False)
sn_list = devices.all()
# acroname should ensure there is always 1 available device
if len(sn_list) != 1:
    log.f("Expected 1 device, got", len(sn_list))
device = devices.get_first(sn_list).handle
log.d('found:', device)
product_line = device.get_info(rs.camera_info.product_line)
log.d('product line:', product_line)

###############################################################################
#
test.start("Update FW")
# check if recovery. If so recover
recovered = False
if device.is_update_device():
    log.d("recovering device ...")
    try:
        # TODO: this needs to improve for L535
        image_name = product_line[:-2] + "XX_FW_Image-"
        image_mask = '(^|/)' + image_name + '(\d+\.){4}bin$'
        image_file = None
        for image in file.find(repo.root, image_mask):
            image_file = image
        if not image_file:
            log.f("Could not find image file for", product_line,
                  "recovery device")
Exemple #7
0
                     and p.format() == rs.format.yuyv
                     and p.as_video_stream_profile().width() == 640
                     and p.as_video_stream_profile().height() == 480)

depth_sensor.open(depth_profile)
depth_sensor.start(check_depth_frame_drops)
color_sensor.open(color_profile)
color_sensor.start(check_color_frame_drops)

#############################################################################################
# Test #1

laser_power = rs.option.laser_power
current_laser_control = 10

test.start("Checking for frame drops when setting laser power several times")

for i in range(1,5):
   new_value = current_laser_control + 10*i
   set_new_value(depth_sensor, laser_power, new_value)

test.finish()

# reset everything back
depth_sensor.set_option( rs.option.visual_preset, int(rs.l500_visual_preset.max_range) )


#############################################################################################

options_to_ignore = [] 
n_depth_frame = 0
n_ir_frame = 0


def frames_counter(frame):
    if frame.get_profile().stream_type() == rs.stream.depth:
        global n_depth_frame
        n_depth_frame += 1
    elif frame.get_profile().stream_type() == rs.stream.infrared:
        global n_ir_frame
        n_ir_frame += 1

wait_frames_timer = Timer(MAX_TIME_TO_WAIT_FOR_FRAMES)

# Test Part 1
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)
Exemple #9
0
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2020 Intel Corporation. All Rights Reserved.

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
Exemple #10
0
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2021 Intel Corporation. All Rights Reserved.

#test:device L500*
#test:device D400*
#test:device SR300*

import pyrealsense2 as rs
from rspy import test

#############################################################################################
# get metadata depth units value and make sure it's non zero and equal to the depth sensor matching option value
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()
    "Pre Processing Sharpening": 0.0,
    "Receiver Gain": 18,
    "Reset Camera Accuracy Health": 0.0,
    "Sensor Mode": 0.0,
    "Trigger Camera Accuracy Health": 0.0,
    "Visual Preset": 1,
    "Zero Order Enabled": 0.0,
    "stream-depth-format": "Z16",
    "stream-fps": "30",
    "stream-height": "480",
    "stream-ir-format": "Y8",
    "stream-width": "640"
}
"""

test.start("Trying to load default settings from json")
try:
    sd.load_json(data)
    visual_preset_number = depth_sensor.get_option(rs.option.visual_preset)
    visual_preset_name = rs.l500_visual_preset(int(visual_preset_number))

    test.check_equal(visual_preset_name,
                     rs.l500_visual_preset.low_ambient_light)
except:
    test.unexpected_exception()
test.finish()

#############################################################################################
test.start("Trying to load non default presets")
presets = [
    rs.l500_visual_preset.custom, rs.l500_visual_preset.no_ambient_light,
Exemple #12
0
# The timestamp jumps are closely correlated to the FPS passed to the video streams:
# syncer expects frames to arrive every 1000/FPS milliseconds!
sw.fps_c = sw.fps_d = 60
sw.init()

import tempfile, os
temp_dir = tempfile.TemporaryDirectory( prefix = 'recordings_' )
filename = os.path.join( temp_dir.name, 'rec.bag' )
recorder = rs.recorder( filename, sw.device )

sw.start()

#############################################################################################
#
test.start( "Init" )

# It can take a few frames for the syncer to actually produce a matched frameset (it doesn't
# know what to match to in the beginning)

# D  C  @timestamp  comment
# -- -- ----------- ----------------
# 0     @0          so next expected frame timestamp is at 0+16.67
#    0  @0
#
sw.generate_depth_and_color( frame_number = 0, timestamp = 0 )
sw.expect( depth_frame = 0 )                          # syncer doesn't know about C yet, so releases right away
sw.expect( color_frame = 0, nothing_else = True )     # no hope for a match: D@0 is already out, so it's released
#
# NOTE: if the syncer queue wasn't 100 (see above) then we'd only get the color frame!
# (it will output D to the queue, then C to the queue, but the queue size is 1 so we lose D)
# test:device D400*
import sys

import pyrealsense2 as rs
from rspy import test

ctx = rs.context()
dev = ctx.query_devices()[0]
pid = dev.get_info(rs.camera_info.product_id)
print(dev.get_info(rs.camera_info.name) + " found")
if pid != "0B5B":
    print("This test is dedicated to run with D405 only - stepping over test")
    sys.exit(0)

#############################################################################################
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)
                        rte
                ) != "stop_streaming() failed. UVC device is not streaming!":
                    test.unexpected_exception()
            except Exception:
                test.unexpected_exception()
            sensor.close()


# create temporary folder to record to that will be deleted automatically at the end of the script
# (requires that no files are being held open inside this directory. Important to not keep any handle open to a file
# in this directory, any handle as such must be set to None)
temp_dir = tempfile.TemporaryDirectory(prefix='recordings_')
file_name = temp_dir.name + os.sep + 'rec.bag'

################################################################################################
test.start("Trying to record and playback using pipeline interface")

cfg = pipeline = None
try:
    # creating a pipeline and recording to a file
    pipeline = rs.pipeline()
    cfg = rs.config()
    cfg.enable_record_to_file(file_name)
    pipeline.start(cfg)
    time.sleep(3)
    pipeline.stop()
    # we create a new pipeline and use it to playback from the file we just recoded to
    pipeline = rs.pipeline()
    cfg = rs.config()
    cfg.enable_device_from_file(file_name)
    pipeline.start(cfg)
    # 2. timeout of 'max_delay_allowed' + 1 extra second reached.
    while first_frame_time == max_delay_allowed and open_call_stopwatch.get_elapsed(
    ) < max_delay_allowed + 1:
        time.sleep(0.05)

    sensor.stop()
    sensor.close()

    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":
# Copyright(c) 2021 Intel Corporation. All Rights Reserved.

import pyrealsense2 as rs
from rspy import log, test
import sw

# The timestamp jumps are closely correlated to the FPS passed to the video streams:
# syncer expects frames to arrive every 1000/FPS milliseconds!
sw.fps_d = 100
sw.fps_c = 10
sw.init()
sw.start()

#############################################################################################
#
test.start("Wait for framesets")

# It can take a few frames for the syncer to actually produce a matched frameset (it doesn't
# know what to match to in the beginning)

# D  C  @timestamp
# -- -- -----------
# 0     @0
# 1     @10
#    0  @0
#
sw.generate_depth_frame(frame_number=0, timestamp=sw.gap_d * 0)
sw.generate_depth_frame(1, sw.gap_d * 1)  # @10
sw.generate_color_frame(0, sw.gap_c * 0)  # @0 -- small latency
sw.expect(depth_frame=0)  # syncer doesn't know about color yet
sw.expect(depth_frame=1)
Exemple #17
0
# test:device D400*

import pyrealsense2 as rs
from rspy import test, log
import time
import datetime

# Test multiple set_pu commands checking that the set control event polling works as expected.
# We expect no exception thrown -  See [DSO-17185]

test_iterations = 200
gain_values = [16, 74, 132, 190, 248]

################################################################################################
test.start("Stress test for setting a PU (gain) option")

dev = test.find_first_device_or_exit()
time.sleep(
    3
)  # The device starts at D0 (Operational) state, allow time for it to get into idle state
depth_ir_sensor = dev.first_depth_sensor()

# Test only devices that supports set gain option
if not depth_ir_sensor.supports(rs.option.gain):
    test.finish()
    test.print_results_and_exit()

for i in range(test_iterations):
    log.d("{} Iteration {} {}".format("=" * 50, i, "=" * 50))
Exemple #18
0
    "Ma Temperature": 39.667610168457,
    "Mc Temperature": 31.6955661773682,
    "Min Distance": 190,
    "Noise Estimation": 0.0,
    "Noise Filtering": 4,
    "Post Processing Sharpening": 1,
    "Pre Processing Sharpening": 0.0,
    "Receiver Gain": 18,
    "Reset Camera Accuracy Health": 0.0,
    "Sensor Mode": 0.0,
    "Trigger Camera Accuracy Health": 0.0,
    "Visual Preset": 1
}
"""

test.start("Trying to load settings with default preset from json")
try:
    sd.load_json(low_ambient_data_with_default_preset)
    visual_preset_number = depth_sensor.get_option(rs.option.visual_preset)
    visual_preset_name = rs.l500_visual_preset(int(visual_preset_number))

    # if this check fails it is most likely because FW changed the default settings
    equal = test.check_equal(visual_preset_name,
                             rs.l500_visual_preset.low_ambient_light)
    if not equal:
        log.w(
            "It is possible that FW changed the default settings of the camera."
        )
        log_settings_differences(low_ambient_data_with_default_preset)
except:
    test.unexpected_exception()
Exemple #19
0
    if p.fps() == 30 and p.stream_type() == rs.stream.color and p.format() ==
    rs.format.yuyv and p.as_video_stream_profile().width() == 640
    and p.as_video_stream_profile().height() == 480)

depth_sensor.open(depth_profile)
depth_sensor.start(check_depth_frame_drops)
color_sensor.open(color_profile)
color_sensor.start(check_color_frame_drops)

#############################################################################################
# Test #1

laser_power = rs.option.laser_power
current_laser_control = 10

test.start("Checking for frame drops when setting laser power several times")

for i in range(1, 5):
    new_value = current_laser_control + 10 * i
    set_new_value(depth_sensor, laser_power, new_value)

test.finish()

# reset everything back
depth_sensor.set_option(rs.option.visual_preset,
                        int(rs.l500_visual_preset.max_range))

#############################################################################################
# Test #2

time.sleep(0.5)  # jic
Exemple #20
0
            if delta > ideal_delta + delta_tolerance_in_us:
                self.count_drops += 1
                self.frame_drops_info[fnum] = fnum - self.prev_fnum
            self.prev_hw_timestamp = curr_hw_timestamp
            self.prev_fnum = fnum
            #print("* frame drops = ", self.count_drops)

        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()

    test.start("Testing D455 frame drops on " + product_line + " device ")
    for ii in range(60):
        print("================ Iteration {} ================".format(ii))
        test = Test(rgb_sensor)
        rgb_sensor.set_option(rs.option.global_time_enabled, 0)
        rgb_sensor.open([rgb_profile])

        producer_thread = threading.Thread(target=test.produce_frames,
                                           name="producer_thread")
        producer_thread.start()
        consumer_thread = threading.Thread(target=test.consume_frames,
                                           name="consumer_thread")
        consumer_thread.start()

        test.start_rgb_sensor()
        time.sleep(30)
Exemple #21
0
                     rs.frame_metadata_value.saturation,
                     rs.frame_metadata_value.sharpness,
                     rs.frame_metadata_value.auto_white_balance_temperature,
                     rs.frame_metadata_value.manual_white_balance]

def check_option_and_metadata_values(option, metadata, value_to_set, frame):
    changed = color_sensor.get_option(option)
    test.check_equal(changed, value_to_set)
    if frame.supports_frame_metadata(metadata):
        changed_md = frame.get_frame_metadata(metadata)
        test.check_equal(changed_md, value_to_set)
    else:
        print("metadata " + repr(metadata) + " not supported")

#############################################################################################
test.start("checking color options")
# test scenario:
# for each option, set value, wait 10 frames, check value with get_option and get_frame_metadata
# values set for each option are min, max, and default values
ctx = rs.context()
dev = ctx.query_devices()[0]

try:
    color_sensor = dev.first_color_sensor()
    # Using a profile common to both L500 and D400
    color_profile = next(p for p in color_sensor.profiles if p.fps() == 30
                         and p.stream_type() == rs.stream.color
                         and p.format() == rs.format.yuyv
                         and p.as_video_stream_profile().width() == 640
                         and p.as_video_stream_profile().height() == 480)
    color_sensor.open(color_profile)
def filter_special_frames( list ):
    """
    Removes consecutive special frame statuses from the status list since we have a built-in
    retry mechanism and more than one request can be made.
    E.g., [triggered, special_frame, special_frame, started, successful]
    """
    i = 1
    while i < len(list):
        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 )
Exemple #23
0

def depth_frame_call_back(frame):
    global previous_depth_frame_number
    test.check_frame_drops(frame, previous_depth_frame_number)
    previous_depth_frame_number = frame.get_frame_number()


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

#############################################################################################
# Test #1
test.start("Checking for frame drops in", n_cal, "calibrations")
for i in range(n_cal):
    try:
        dcs.reset_calibration()
        ccs.reset_calibration()
        d2r.trigger_device_calibration(rs.calibration_type.manual_depth_to_rgb)
        ac.wait_for_calibration()
    except:
        test.unexpected_exception()
test.finish()

#############################################################################################
# Test #2
test.start("Checking for frame drops in a failed calibration")
ac.reset_status_list()
try:
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2021 Intel Corporation. All Rights Reserved.

import pyrealsense2 as rs
from rspy import log, test
import sw

# The timestamp jumps are closely correlated to the FPS passed to the video streams:
# syncer expects frames to arrive every 1000/FPS milliseconds!
sw.fps_c = sw.fps_d = 60
sw.init()
sw.start()

#############################################################################################
#
test.start("Wait for framesets")

# It can take a few frames for the syncer to actually produce a matched frameset (it doesn't
# know what to match to in the beginning)

sw.generate_depth_and_color(frame_number=0, timestamp=0)
sw.expect(depth_frame=0)  # syncer doesn't know about color yet
sw.expect(color_frame=0, nothing_else=True)  # less than next expected of D
#
# NOTE: if the syncer queue wasn't 100 (see above) then we'd only get the color frame!
#
sw.generate_depth_and_color(1, sw.gap_d * 1)
sw.expect(depth_frame=1, color_frame=1, nothing_else=True)  # frameset 1

test.finish()
#