From 5655e1c8f03ec1edd9b3788be1050696dcb2991f Mon Sep 17 00:00:00 2001 From: noacoohen Date: Sun, 19 Nov 2023 19:50:40 +0200 Subject: [PATCH] PR notes fixed --- .../test-post-processing-from-bag.py | 43 +++++++++---------- wrappers/python/pyrs_sensor.cpp | 10 ++--- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/unit-tests/post-processing/test-post-processing-from-bag.py b/unit-tests/post-processing/test-post-processing-from-bag.py index 4f75792a1c..e4347ce51a 100644 --- a/unit-tests/post-processing/test-post-processing-from-bag.py +++ b/unit-tests/post-processing/test-post-processing-from-bag.py @@ -15,7 +15,7 @@ frame_processor_lock = threading.Lock() frames_lock = threading.Lock() completion_event = threading.Event() -all_paris = True +all_pairs = True composite_frames = [] sensor_to_frames = {} sensor_to_framesets = {} @@ -41,7 +41,7 @@ def process(self, frame): def create_sw_frame(video_frame, profile): new_video_frame = rs.software_video_frame() - new_video_frame.data = np.array(np.hstack(np.asarray(video_frame.get_data(), dtype=np.uint8)), dtype=np.uint8) + new_video_frame.data = bytearray(video_frame.get_data()) new_video_frame.bpp = video_frame.get_bytes_per_pixel() new_video_frame.stride = video_frame.get_width() * video_frame.get_bytes_per_pixel() new_video_frame.timestamp = video_frame.get_timestamp() @@ -58,13 +58,13 @@ def validate_ppf_results(result_frame, reference_frame): test.check_equal(result_profile.width(), reference_profile.width()) test.check_equal(result_profile.height(), reference_profile.height()) - v1 = np.asarray(result_frame.get_data()).astype(dtype=np.uint8).reshape(-1) - v2 = np.asarray(reference_frame.get_data()).astype(dtype=np.uint8).reshape(-1) + v1 = bytearray(result_frame.get_data()) + v2 = bytearray(reference_frame.get_data()) test.check_equal_lists(v1,v2) def process_frame(frame, frame_source): - sensor_name = rs.sensor_from_frame(frame).get_info(rs.camera_info.name) + sensor_name = rs.sensor.from_frame(frame).get_info(rs.camera_info.name) with frame_processor_lock: if sensor_name in sensor_to_frames: sensor_to_frames[sensor_name].append(frame) @@ -75,9 +75,9 @@ def process_frame(frame, frame_source): frameset = frame_source.allocate_composite_frame(sensor_to_frames[sensor_name]) frameset.keep() sensor_to_framesets[sensor_name] = frameset - all_paris = True + all_pairs = True else: - all_paris = False + all_pairs = False def check_condition(sensors): @@ -95,7 +95,7 @@ def callback_for_get_frames(frame, sensor_to_frame, sensors): with frames_lock: if len(sensor_to_frame) < len(sensors): frame.keep() - sensor_name = rs.sensor_from_frame(frame).get_info(rs.camera_info.name) + sensor_name = rs.sensor.from_frame(frame).get_info(rs.camera_info.name) sensor_to_frame[sensor_name] = frame @@ -138,7 +138,7 @@ def get_composite_frames(sensors): while True: with frame_processor_lock: - if len(sensor_to_framesets) >= len(sensors) and all_paris is True: + if len(sensor_to_framesets) >= len(sensors) and all_pairs is True: break time.sleep(0.0001) @@ -178,24 +178,21 @@ def compare_processed_frames_vs_recorded_frames(record_block, file): ################################################################################################ -test.start("Test align depth to color from recording") +with test.closure("Test align depth to color from recording"): + record_block = AlignRecordBlock(rs.stream.color, rs.stream.depth) + compare_processed_frames_vs_recorded_frames(record_block, "[aligned_2c]_all_combinations_depth_color.bag") -record_block = AlignRecordBlock(rs.stream.color, rs.stream.depth) -compare_processed_frames_vs_recorded_frames(record_block, "[aligned_2c]_all_combinations_depth_color.bag") - -test.finish() ################################################################################################ -test.start("Test align color to depth from recording") +with test.closure("Test align color to depth from recording"): -composite_frames = [] -sensor_to_frames = {} -sensor_to_framesets = {} -sensor_to_frame = {} -all_paris = True + composite_frames = [] + sensor_to_frames = {} + sensor_to_framesets = {} + sensor_to_frame = {} + all_pairs = True -record_block = AlignRecordBlock(rs.stream.depth, rs.stream.color) -compare_processed_frames_vs_recorded_frames(record_block, "[aligned_2d]_all_combinations_depth_color.bag") + record_block = AlignRecordBlock(rs.stream.depth, rs.stream.color) + compare_processed_frames_vs_recorded_frames(record_block, "[aligned_2d]_all_combinations_depth_color.bag") -test.finish() ################################################################################################ test.print_results_and_exit() diff --git a/wrappers/python/pyrs_sensor.cpp b/wrappers/python/pyrs_sensor.cpp index 4bf3b5001f..bf4d1f48f0 100644 --- a/wrappers/python/pyrs_sensor.cpp +++ b/wrappers/python/pyrs_sensor.cpp @@ -56,10 +56,10 @@ void init_sensor(py::module &m) { }, "Start passing frames into user provided callback.", "callback"_a,py::call_guard< py::gil_scoped_release >()) .def("start", [](const rs2::sensor& self, rs2::syncer& syncer) { self.start(syncer); - }, "Start passing frames into user provided syncer.", "syncer"_a) + }, "Start passing frames into user provided syncer.", "syncer"_a, py::call_guard< py::gil_scoped_release >()) .def("start", [](const rs2::sensor& self, rs2::frame_queue& queue) { self.start(queue); - }, "start passing frames into specified frame_queue", "queue"_a) + }, "start passing frames into specified frame_queue", "queue"_a, py::call_guard< py::gil_scoped_release >()) .def("stop", &rs2::sensor::stop, "Stop streaming.", py::call_guard()) .def("get_stream_profiles", &rs2::sensor::get_stream_profiles, "Retrieves the list of stream profiles supported by the sensor.") .def("get_active_streams", &rs2::sensor::get_active_streams, "Retrieves the list of stream profiles currently streaming on the sensor.") @@ -91,9 +91,9 @@ void init_sensor(py::module &m) { ss << ": \"" << self.get_info( RS2_CAMERA_INFO_NAME ) << "\""; ss << ">"; return ss.str(); - } ); - m.def("sensor_from_frame", [](rs2::frame f) { - auto sptr = rs2::sensor_from_frame(f); + } ) + .def_static("from_frame", [](rs2::frame frame) { + auto sptr = rs2::sensor_from_frame(frame); return *sptr; }, "frame"_a);