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