diff --git a/tools/convert/converter.cpp b/tools/convert/converter.cpp index a52e6e1555..595fbfa3f1 100644 --- a/tools/convert/converter.cpp +++ b/tools/convert/converter.cpp @@ -28,13 +28,14 @@ void rs2::tools::converter::metadata_to_txtfile(const rs2::frame& frm, const std file.close(); } -bool converter_base::frames_map_get_and_set(rs2_stream streamType, frame_number_t frameNumber) +bool converter_base::frames_map_get_and_set(rs2_stream streamType, int index, frame_number_t frameNumber) { - if (_framesMap.find(streamType) == _framesMap.end()) { - _framesMap.emplace(streamType, std::unordered_set()); + auto stream_with_index = std::pair(streamType, index); + if (_framesMap.find(stream_with_index) == _framesMap.end()) { + _framesMap.emplace(stream_with_index, std::unordered_set()); } - auto& set = _framesMap[streamType]; + auto& set = _framesMap[stream_with_index]; bool result = (set.find(frameNumber) != set.end()); if (!result) { @@ -67,7 +68,7 @@ std::string converter_base::get_statistics() for (auto& i : _framesMap) { result << '\t' << i.second.size() << ' ' - << (static_cast(i.first) != rs2_stream::RS2_STREAM_ANY ? rs2_stream_to_string(static_cast(i.first)) : "") + << (i.first.first != rs2_stream::RS2_STREAM_ANY ? rs2_stream_to_string(i.first.first) : "") << " frame(s) processed" << '\n'; } diff --git a/tools/convert/converter.hpp b/tools/convert/converter.hpp index ccea9e5d67..4ebe46a6d8 100644 --- a/tools/convert/converter.hpp +++ b/tools/convert/converter.hpp @@ -4,7 +4,7 @@ #ifndef __RS_CONVERTER_CONVERTER_H #define __RS_CONVERTER_CONVERTER_H -#include +#include #include #include #include @@ -26,10 +26,10 @@ namespace rs2 { protected: std::thread _worker; std::vector _subWorkers; - std::unordered_map> _framesMap; + std::map, std::unordered_set> _framesMap; protected: - bool frames_map_get_and_set(rs2_stream streamType, frame_number_t frameNumber); + bool frames_map_get_and_set(rs2_stream streamType, int index, frame_number_t frameNumber); void wait_sub_workers(); template void start_worker(const F& f) diff --git a/tools/convert/converters/converter-bin.hpp b/tools/convert/converters/converter-bin.hpp index 69bfba4b4a..2ded3d2d94 100644 --- a/tools/convert/converters/converter-bin.hpp +++ b/tools/convert/converters/converter-bin.hpp @@ -79,7 +79,7 @@ namespace rs2 { return; } - if (frames_map_get_and_set(depthframe.get_profile().stream_type(), depthframe.get_frame_number())) { + if (frames_map_get_and_set(depthframe.get_profile().stream_type(), depthframe.get_profile().stream_index(), depthframe.get_frame_number())) { return; } diff --git a/tools/convert/converters/converter-csv.cpp b/tools/convert/converters/converter-csv.cpp index d364f139b3..770b5cdab3 100644 --- a/tools/convert/converters/converter-csv.cpp +++ b/tools/convert/converters/converter-csv.cpp @@ -53,7 +53,7 @@ converter_csv::converter_csv(const std::string& filePath, rs2_stream streamType) void converter_csv::convert_depth(rs2::depth_frame& depthframe) { - if (frames_map_get_and_set(depthframe.get_profile().stream_type(), depthframe.get_frame_number())) { + if (frames_map_get_and_set(depthframe.get_profile().stream_type(), depthframe.get_profile().stream_index(), depthframe.get_frame_number())) { return; } @@ -146,7 +146,7 @@ void converter_csv::save_motion_pose_data_to_file() void converter_csv::convert_motion_pose(rs2::frame& f) { - if (frames_map_get_and_set(f.get_profile().stream_type(), f.get_frame_number())) { + if (frames_map_get_and_set(f.get_profile().stream_type(), f.get_profile().stream_index(), f.get_frame_number())) { return; } diff --git a/tools/convert/converters/converter-ply.hpp b/tools/convert/converters/converter-ply.hpp index f9c663dd00..f412deaaca 100644 --- a/tools/convert/converters/converter-ply.hpp +++ b/tools/convert/converters/converter-ply.hpp @@ -37,7 +37,7 @@ namespace rs2 { auto frameColor = frameset.get_color_frame(); if (frameDepth && frameColor) { - if (frames_map_get_and_set(rs2_stream::RS2_STREAM_ANY, frameDepth.get_frame_number())) { + if (frames_map_get_and_set(rs2_stream::RS2_STREAM_ANY, frameDepth.get_profile().stream_index(), frameDepth.get_frame_number())) { return; } diff --git a/tools/convert/converters/converter-png.hpp b/tools/convert/converters/converter-png.hpp index fcfd6ce2f8..6db649cb9e 100644 --- a/tools/convert/converters/converter-png.hpp +++ b/tools/convert/converters/converter-png.hpp @@ -40,8 +40,7 @@ namespace rs2 { return; } - if (frames_map_get_and_set(videoframe.get_profile().stream_type(), - static_cast(videoframe.get_timestamp()))) { + if (frames_map_get_and_set(videoframe.get_profile().stream_type(), videoframe.get_profile().stream_index(), videoframe.get_frame_number())) { return; } diff --git a/tools/convert/converters/converter-raw.hpp b/tools/convert/converters/converter-raw.hpp index 5b855a008f..821b8e2f4c 100644 --- a/tools/convert/converters/converter-raw.hpp +++ b/tools/convert/converters/converter-raw.hpp @@ -38,7 +38,7 @@ namespace rs2 { return; } - if (frames_map_get_and_set(videoframe.get_profile().stream_type(), videoframe.get_frame_number())) { + if (frames_map_get_and_set(videoframe.get_profile().stream_type(), videoframe.get_profile().stream_index(), videoframe.get_frame_number())) { return; }