Processors.cpp
Go to the documentation of this file.
1 #include "Processors.h"
2 
4 
12 
14 {
15  void
16  Processors::configure(const nlohmann::json& config)
17  {
18  // Filters:
19  snapFilters.clear();
21  {
22  ARMARX_IMPORTANT << "ADDING SNAPSHOT FREQUENCY FILTER";
23  auto f = std::make_unique<processor::filter::SnapshotFrequencyFilter>();
25  snapFilters.push_back(std::move(f));
26  }
28  {
29  ARMARX_IMPORTANT << "ADDING SNAPSHOT SIMILARITY FILTER";
30  auto f = std::make_unique<processor::filter::SnapshotSimilarityFilter>();
32  snapFilters.push_back(std::move(f));
33  }
35  {
36  ARMARX_IMPORTANT << "ADDING SNAPSHOT IMPORTANCE FILTER";
37  auto f = std::make_unique<processor::filter::SnapshotImportanceFilter>();
39  snapFilters.push_back(std::move(f));
40  }
41 
42  // Converters
44  {
45  ARMARX_IMPORTANT << "ADDING IMG CONVERTER PNG";
46  auto f = std::make_unique<processor::converter::data::image::PngConverter>();
48  converters.push_back(std::move(f));
49  }
51  {
52  ARMARX_IMPORTANT << "ADDING IMG CONVERTER EXR";
53  auto f = std::make_unique<processor::converter::data::image::ExrConverter>();
55  converters.push_back(std::move(f));
56  }
57  }
58 
59  std::map<std::string, processor::SnapshotFilter::FilterStatistics>
61  {
62  std::map<std::string, processor::SnapshotFilter::FilterStatistics> stats;
63  bool recordedOverall = false;
64  ARMARX_INFO << "Number of active filters: " << snapFilters.size();
65  for (std::size_t i = 0; i < snapFilters.size(); i++)
66  {
67  auto statistics = snapFilters.at(i)->getFilterStatistics();
68  auto recorded = statistics.accepted + statistics.rejected;
69  stats[snapFilters.at(i)->getName()] = statistics;
70  if (recorded > 0)
71  {
72  recordedOverall = true;
73  }
74  }
75  if (!recordedOverall)
76  {
77  throw InvalidArgumentException(
78  "NoFilters recorded any data being accepted or rejected, "
79  "cant store empty statistics");
80  }
81  return stats;
82  }
83 
85  {
86  ARMARX_DEBUG << "Resetting statistics for filters";
87  for(const auto& filter_ptr: this->snapFilters){
88  filter_ptr->resetStatisticsForNewEpisode();
89  }
90  }
91 } // namespace armarx::armem::server::ltm
armarx::armem::server::ltm::processor::filter::SnapshotSimilarityFilter::NAME
static const constexpr char * NAME
Definition: EqualityFilter.h:21
EqualityFilter.h
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:183
armarx::armem::server::ltm::Processors::resetFilterStatisticsForNewEpisode
void resetFilterStatisticsForNewEpisode()
resetFilterStatisticsForNewEpisode runs resetFilterStatisticsForNewEpisode on all snapshot filters
Definition: Processors.cpp:84
armarx::armem::server::ltm::processor::filter::SnapshotImportanceFilter::NAME
static const constexpr char * NAME
Definition: ImportanceFilter.h:20
ExrConverter.h
armarx::armem::server::ltm::Processors::snapFilters
std::vector< std::unique_ptr< processor::SnapshotFilter > > snapFilters
Definition: Processors.h:39
armarx::armem::server::ltm::processor::converter::data::image::PngConverter::NAME
static const constexpr char * NAME
Definition: PngConverter.h:12
Processors.h
armarx::armem::server::ltm::processor::converter::data::image::ExrConverter::NAME
static const constexpr char * NAME
Definition: ExrConverter.h:13
armarx::armem::server::ltm::processor::filter::SnapshotFrequencyFilter::NAME
static const constexpr char * NAME
Definition: FrequencyFilter.h:12
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
DepthImageExtractor.h
ImportanceFilter.h
armarx::armem::server::ltm
Definition: forward_declarations.h:20
armarx::armem::server::ltm::Processors::getSnapshotFilterStatistics
std::map< std::string, processor::SnapshotFilter::FilterStatistics > getSnapshotFilterStatistics()
Definition: Processors.cpp:60
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
FrequencyFilter.h
ImageExtractor.h
Logging.h
PngConverter.h
armarx::armem::server::ltm::Processors::configure
void configure(const nlohmann::json &config)
Definition: Processors.cpp:16
armarx::armem::server::ltm::Processors::converters
std::vector< std::unique_ptr< processor::DataConverter > > converters
Definition: Processors.h:45