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
std::vector< std::unique_ptr< processor::SnapshotFilter > > snapFilters
Definition Processors.h:40
void configure(const nlohmann::json &config)
std::vector< std::unique_ptr< processor::DataConverter > > converters
Definition Processors.h:46
std::map< std::string, processor::SnapshotFilter::FilterStatistics > getSnapshotFilterStatistics()
void resetFilterStatisticsForNewEpisode()
resetFilterStatisticsForNewEpisode runs resetFilterStatisticsForNewEpisode on all snapshot filters
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
Definition Logging.h:184