18 auto start = std::chrono::high_resolution_clock::now();
20 int num_instances = 0;
21 std::vector<armarx::aron::data::NDArrayPtr> images_snapshot;
22 std::vector<armarx::aron::data::FloatPtr> floats_snapshot;
23 std::vector<float> distances;
29 for (
auto key :
data->getAllKeys())
34 auto d =
data->at(key);
36 img_desc =
data->at(key)->getDescriptor();
40 ARMARX_INFO <<
"Problem with accessing image description";
46 images_snapshot.insert(images_snapshot.end(), img_nd);
52 floats_snapshot.push_back(fl);
58 <<
"Only ndarray and float data types are supported for "
59 "equality filters yet.";
64 if (images.size() < 2)
66 ARMARX_INFO <<
"Adding first images, because nothing to compare";
67 images.push_back(images_snapshot);
68 this->stats.accepted += 1;
69 auto end = std::chrono::high_resolution_clock::now();
71 stats.additional_time += (end - start);
74 else if (images.size() < max_images)
76 ARMARX_INFO <<
"Not enough elements yet to do full comparison of last " << max_images
78 images.push_back(images_snapshot);
79 this->stats.accepted += 1;
80 auto end = std::chrono::high_resolution_clock::now();
82 stats.additional_time += (end - start);
87 std::vector<armarx::aron::data::NDArrayPtr> lastCommittedImages;
88 int sizeOfCommited = 0;
89 for (
int i = 0; i < max_images; i++)
91 std::vector<armarx::aron::data::NDArrayPtr> lastCommitImages =
92 images.at(images.size() - i - 1);
93 sizeOfCommited = lastCommitImages.size();
94 for (
int j = 0; j < lastCommitImages.size(); j++)
96 lastCommittedImages.push_back(lastCommitImages.at(j));
103 for (
int i = 0; i < images_snapshot.size(); i++)
106 std::vector<armarx::aron::data::NDArrayPtr> commited_images;
107 for (
int j = 0; j < max_images; j++)
109 int index = i + 2 * j;
110 auto image = lastCommittedImages.at(
index);
111 commited_images.emplace_back(image);
115 commited_images, new_image, this->similarity_type);
117 distances.insert(distances.end(),
distance);
121 float sum_distances = 0;
122 float max_distance = 0;
123 for (
auto d : distances)
126 if (d > max_distance)
138 accept = (max_distance > this->threshold);
142 accept = (sum_distances > this->threshold);
148 images.push_back(images_snapshot);
149 this->stats.accepted += 1;
150 auto end = std::chrono::high_resolution_clock::now();
151 stats.additional_time += (end - start);
152 stats.end_time = end;
157 this->stats.rejected += 1;
158 auto end = std::chrono::high_resolution_clock::now();
159 stats.additional_time += (end - start);
160 stats.end_time = end;
173 stats.additional_info +=
"Threshold-Parameter: ";
174 stats.additional_info += std::to_string(threshold);
179 if (type_string ==
"MSE")
185 else if (type_string ==
"MAE")
191 else if (type_string ==
"Chernoff")
197 else if (type_string ==
"Cosine")
205 ARMARX_WARNING <<
"Undefined similarity measure detected in JSON file";
215 stats.number_of_compared_objects = max_images;
218 stats.start_time = std::chrono::high_resolution_clock::now();