From 337eba1403140ab69fc60b69c2d8d2a24e199dc1 Mon Sep 17 00:00:00 2001 From: Eran Date: Thu, 26 Oct 2023 22:03:45 +0300 Subject: [PATCH] remove exposure & discrete value handling in actual FPS calculations --- src/ds/ds-color-common.cpp | 3 +- src/metadata-parser.h | 58 ++------------------------------------ 2 files changed, 4 insertions(+), 57 deletions(-) diff --git a/src/ds/ds-color-common.cpp b/src/ds/ds-color-common.cpp index bfc0d571703..e12f6fc11ad 100644 --- a/src/ds/ds-color-common.cpp +++ b/src/ds/ds-color-common.cpp @@ -77,8 +77,7 @@ namespace librealsense void ds_color_common::register_metadata() { _color_ep.register_metadata(RS2_FRAME_METADATA_FRAME_TIMESTAMP, make_uvc_header_parser(&platform::uvc_header::timestamp)); - _color_ep.register_metadata(RS2_FRAME_METADATA_ACTUAL_FPS, std::make_shared(false, [](const rs2_metadata_type& param) - {return param * 100; })); //the units of the exposure of the RGB sensor are 100 microseconds so the md_attribute_actual_fps need the lambda to convert it to microseconds + _color_ep.register_metadata(RS2_FRAME_METADATA_ACTUAL_FPS, std::make_shared()); // attributes of md_capture_timing auto md_prop_offset = offsetof(metadata_raw, mode) + diff --git a/src/metadata-parser.h b/src/metadata-parser.h index 3bd06d3c0a0..2825aef256e 100644 --- a/src/metadata-parser.h +++ b/src/metadata-parser.h @@ -345,7 +345,7 @@ namespace librealsense class actual_fps_calculator { public: - double get_fps(const librealsense::frame & frm) + static double get_fps( const librealsense::frame & frm ) { // A computation involving unsigned operands can never overflow (ISO/IEC 9899:1999 (E) \A76.2.5/9) // In case of frame counter reset fallback use fps from the stream configuration @@ -373,67 +373,15 @@ namespace librealsense class ds_md_attribute_actual_fps : public md_attribute_parser_base { public: - ds_md_attribute_actual_fps(bool discrete = true, attrib_modifyer exposure_mod = [](const rs2_metadata_type& param) {return param; }) - : _fps_values{ 6, 15, 30, 60, 90 } , _exposure_modifyer(exposure_mod), _discrete(discrete) - {} - - rs2_metadata_type get(const librealsense::frame & frm) const override + rs2_metadata_type get( const librealsense::frame & frm ) const override { - if (frm.supports_frame_metadata(RS2_FRAME_METADATA_ACTUAL_EXPOSURE)) - { - if (frm.get_stream()->get_format() == RS2_FORMAT_Y16 && - frm.get_stream()->get_stream_type() == RS2_STREAM_INFRARED) //calibration mode - { - if (std::find(_fps_values.begin(), _fps_values.end(), 25) == _fps_values.end()) - { - _fps_values.push_back(25); - std::sort(_fps_values.begin(), _fps_values.end()); - } - - } - - auto exp = frm.get_frame_metadata(RS2_FRAME_METADATA_ACTUAL_EXPOSURE); - - auto exp_in_micro = _exposure_modifyer(exp); - if (exp_in_micro > 0) - { - auto fps = 1000000. / exp_in_micro; - - if (_discrete) - { - if (fps >= _fps_values.back()) - { - fps = static_cast(_fps_values.back()); - } - else - { - for (size_t i = 0; i < _fps_values.size() - 1; i++) - { - if (fps < _fps_values[i + 1]) - { - fps = static_cast(_fps_values[i]); - break; - } - } - } - } - return rs2_metadata_type( std::min( fps, (double)frm.get_stream()->get_framerate() ) * 1000 ); - } - } - - return rs2_metadata_type( _fps_calculator.get_fps( frm ) * 1000 ); + return rs2_metadata_type( actual_fps_calculator::get_fps( frm ) * 1000 ); } bool supports(const librealsense::frame & frm) const override { return true; } - - private: - mutable actual_fps_calculator _fps_calculator; - mutable std::vector _fps_values; - attrib_modifyer _exposure_modifyer; - bool _discrete; }; /**\brief A helper function to create a specialized parser for RS4xx sensor timestamp*/