Skip to content

Commit

Permalink
Merge pull request #420 from agri-gaia/fix/queryAllLabel
Browse files Browse the repository at this point in the history
fix query for multiple labels at once
  • Loading branch information
Mark-Niemeyer authored Jan 10, 2025
2 parents 94a32b7 + 0916f47 commit a4d4c0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions seerep_srv/seerep_core/include/seerep_core/core_dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class CoreDataset
* @param query the query parameters
* @return set of UUIDs of the images matching the query
*/
std::optional<std::set<boost::uuids::uuid>> querySemanticWithAnyOfLabels(
std::set<boost::uuids::uuid> querySemanticWithAnyOfLabels(
std::shared_ptr<DatatypeSpecifics> datatypeSpecifics,
const seerep_core_msgs::Query& query);

Expand All @@ -395,7 +395,7 @@ class CoreDataset
* @param query the query parameters
* @return set of UUIDs of the images matching the query
*/
std::optional<std::set<boost::uuids::uuid>> querySemanticWithAllTheLabels(
std::set<boost::uuids::uuid> querySemanticWithAllTheLabels(
std::shared_ptr<DatatypeSpecifics> datatypeSpecifics,
const seerep_core_msgs::Query& query);

Expand Down
20 changes: 9 additions & 11 deletions seerep_srv/seerep_core/src/core_dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,11 @@ CoreDataset::querySemantic(std::shared_ptr<DatatypeSpecifics> datatypeSpecifics,
return std::nullopt;
}

std::optional<std::set<boost::uuids::uuid>>
CoreDataset::querySemanticWithAnyOfLabels(
std::set<boost::uuids::uuid> CoreDataset::querySemanticWithAnyOfLabels(
std::shared_ptr<DatatypeSpecifics> datatypeSpecifics,
const seerep_core_msgs::Query& query)
{
std::optional<std::set<boost::uuids::uuid>> result =
std::set<boost::uuids::uuid>();
std::set<boost::uuids::uuid> result = std::set<boost::uuids::uuid>();
// find the queried label in the label-imageID-map
for (auto categorylabelquery : query.label.value())
{
Expand All @@ -400,7 +398,7 @@ CoreDataset::querySemanticWithAnyOfLabels(
// add all imageIDs to result set
for (boost::uuids::uuid id : labelPtr->second)
{
result.value().insert(id);
result.insert(id);
}
}
}
Expand All @@ -409,12 +407,12 @@ CoreDataset::querySemanticWithAnyOfLabels(
return result;
}

std::optional<std::set<boost::uuids::uuid>>
CoreDataset::querySemanticWithAllTheLabels(
std::set<boost::uuids::uuid> CoreDataset::querySemanticWithAllTheLabels(
std::shared_ptr<DatatypeSpecifics> datatypeSpecifics,
const seerep_core_msgs::Query& query)
{
std::set<boost::uuids::uuid> result;
std::set<boost::uuids::uuid> result = std::set<boost::uuids::uuid>();
;
bool firstLabel = true;
// find the queried label in the label-imageID-map
for (auto categorylabelquery : query.label.value())
Expand Down Expand Up @@ -453,17 +451,17 @@ CoreDataset::querySemanticWithAllTheLabels(
}
else
{
return std::nullopt;
return std::set<boost::uuids::uuid>();
}
firstLabel = false;
if (result.empty())
{
return std::nullopt;
return std::set<boost::uuids::uuid>();
}
}
else
{
return std::nullopt;
return std::set<boost::uuids::uuid>();
}
}
}
Expand Down

0 comments on commit a4d4c0b

Please sign in to comment.