5 #include <IceUtil/Time.h>
15 auto start = std::chrono::high_resolution_clock::now();
17 int num_instances = 0;
18 std::vector<armarx::aron::data::NDArrayPtr> images_snapshot;
19 std::vector<armarx::aron::data::FloatPtr> floats_snapshot;
20 std::vector<float> distances;
26 for (
auto key :
data->getAllKeys())
31 auto d =
data->at(key);
33 img_desc =
data->at(key)->getDescriptor();
37 ARMARX_INFO <<
"Problem with accessing image description";
43 images_snapshot.insert(images_snapshot.end(), img_nd);
49 floats_snapshot.push_back(fl);
55 <<
"Only ndarray and float data types are supported for "
56 "equality filters yet.";
61 if (images.size() < 2)
63 ARMARX_INFO <<
"Adding first images, because nothing to compare";
64 images.push_back(images_snapshot);
66 auto end = std::chrono::high_resolution_clock::now();
71 else if (images.size() < max_images)
73 ARMARX_INFO <<
"Not enough elements yet to do full comparison of last " << max_images
75 images.push_back(images_snapshot);
77 auto end = std::chrono::high_resolution_clock::now();
84 std::vector<armarx::aron::data::NDArrayPtr> lastCommittedImages;
85 int sizeOfCommited = 0;
86 for (
int i = 0; i < max_images; i++)
88 std::vector<armarx::aron::data::NDArrayPtr> lastCommitImages =
89 images.at(images.size() - i - 1);
90 sizeOfCommited = lastCommitImages.size();
91 for (
int j = 0; j < lastCommitImages.size(); j++)
93 lastCommittedImages.push_back(lastCommitImages.at(j));
100 for (
int i = 0; i < images_snapshot.size(); i++)
103 std::vector<armarx::aron::data::NDArrayPtr> commited_images;
104 for (
int j = 0; j < max_images; j++)
106 int index = i + 2 * j;
107 auto image = lastCommittedImages.at(
index);
108 commited_images.emplace_back(image);
112 commited_images, new_image, this->similarity_type);
114 distances.insert(distances.end(),
distance);
118 float sum_distances = 0;
119 float max_distance = 0;
120 for (
auto d : distances)
123 if (d > max_distance)
135 accept = (max_distance > this->threshold);
139 accept = (sum_distances > this->threshold);
145 images.push_back(images_snapshot);
147 auto end = std::chrono::high_resolution_clock::now();
155 auto end = std::chrono::high_resolution_clock::now();
175 if (type_string ==
"MSE")
181 else if (type_string ==
"MAE")
187 else if (type_string ==
"Chernoff")
193 else if (type_string ==
"Cosine")
201 ARMARX_WARNING <<
"Undefined similarity measure detected in JSON file";
214 stats.
start_time = std::chrono::high_resolution_clock::now();