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")
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
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: log.f("Could not find image file for " + product_line + " device with FW version: " + bundled_fw_version) cmd = [fw_updater_exe, '-f', image_file] log.d('running:', cmd) sys.stdout.flush() subprocess.run(cmd) # may throw # make sure update worked devices.query(monitor_changes=False) sn_list = devices.all() device = devices.get_first(sn_list).handle current_fw_version = repo.pretty_fw_version( device.get_info(rs.camera_info.firmware_version)) test.check_equal(current_fw_version, bundled_fw_version) new_update_counter = get_update_counter(device) # According to FW: "update counter zeros if you load newer FW than (ever) before" if new_update_counter > 0: test.check_equal(new_update_counter, update_counter + 1) test.finish() # ############################################################################### test.print_results_and_exit()
"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() test.finish() ############################################################################################# # There is no default preset: so when one is specified, the code should calculate the preset! # Here, we intentionally should not fit into any of the defined presets, and check that the result is CUSTOM wrong_data_with_default_preset = """ {
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 and p.as_video_stream_profile().width() == 800 and p.as_video_stream_profile().height() == 600) depth_sensor.open( dp ) lrs_queue = rs.frame_queue(capacity=10, keep_frames=False) depth_sensor.start( lrs_queue ) try: lrs_frame = lrs_queue.wait_for_frame(5000) test.check_equal(lrs_frame.profile.format(), rs.format.fg) except: test.unexpected_exception() finally: debug_sensor.stop() debug_sensor.close() test.finish() ############################################################################################# test.print_results_and_exit()
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") depth_sensor.open([dp, irp])
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()
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: log.f("Could not find image file for " + product_line + " device with FW version: " + bundled_fw_version) test.start("Update FW") try: cmd = [fw_updater_exe, '-f', image_file] log.d('running:', cmd) subprocess.run(cmd) except Exception as e: test.unexpected_exception() # make sure update worked devices.query(monitor_changes=False) sn_list = devices.all() device = devices.get(list(sn_list)[0]) current_fw_version = repo.pretty_fw_version( device.get_info(rs.camera_info.firmware_version)) test.check_equal(current_fw_version, bundled_fw_version) if update_counter < 19: test.check_equal(get_update_counter(device), update_counter + 1) else: test.check_equal(get_update_counter(device), 1) test.finish() test.print_results_and_exit()
if not has_newer_fw(current_fw_version, bundled_fw_version): log.i("No update needed: FW version is already", current_fw_version) sys.exit(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 file in find(librealsense, image_mask): image_file = os.path.join(librealsense, file) if not image_file: log.e("Could not find image file for" + product_line + "device with FW version:" + bundled_fw_version) sys.exit(1) test.start("Update FW") try: cmd = [fw_updater_exe, '-f', image_file] log.d('running:', cmd) subprocess.run(cmd) except Exception as e: test.unexpected_exception() # make sure update worked devices.query(monitor_changes=False) sn_list = devices.all() device = devices.get(list(sn_list)[0]) current_fw_version = pretty_fw_version( device.get_info(rs.camera_info.firmware_version)) test.check_equal(current_fw_version, bundled_fw_version) test.finish() test.print_results_and_exit()