3#include <opencv2/core/core.hpp>
4#include <opencv2/imgcodecs.hpp>
5#include <opencv2/imgproc/imgproc.hpp>
7#include <SimoxUtility/algorithm/string.h>
8#include <SimoxUtility/filesystem/list_directory.h>
9#include <SimoxUtility/json.h>
10#include <SimoxUtility/shapes/AxisAlignedBoundingBox.h>
11#include <SimoxUtility/shapes/OrientedBox.h>
18#include <VisionX/libraries/armem_human/aron/Person.aron.generated.h>
23 namespace fs = std::filesystem;
26 const path& absPackageDataDir,
27 const path& relativePath,
28 const std::string&
id) :
29 _packageName(packageName),
30 _absPackageDataDir(absPackageDataDir),
31 _relativePath(relativePath),
39 this->_logError = enabled;
55 Info::_relativeProfileDirectory()
const
57 return _relativePath / _id;
61 Info::file(
const std::string& _extension,
const std::string& suffix)
const
63 std::string extension = _extension;
64 if (extension.at(0) !=
'.')
66 extension =
"." + extension;
68 std::string filename = suffix + extension;
77 std::string name = suffix;
78 return PackagePath(_packageName, _relativeProfileDirectory() / name);
84 return file(
".json",
"profile");
94 std::vector<PackagePath>
105 std::vector<PackagePath> imageFiles;
107 for (
const fs::path&
path : simox::fs::list_directory(directory.
toSystemPath(), local))
109 for (
const std::string& ext : extensions)
111 if (fs::is_regular_file(
path) and simox::alg::ends_with(
path.string(), ext))
114 _relativeProfileDirectory() /
"faces-images" /
116 imageFiles.push_back(imageFile);
123 std::optional<Info::Person>
130 j = nlohmann::read_json(
profileJson().toSystemPath());
132 catch (
const std::exception& e)
147 cv::imread(imagePath.toSystemPath().string(), cv::ImreadModes::IMREAD_COLOR);
148 cv::cvtColor(image, image, cv::ColorConversionCodes::COLOR_BGR2RGB);
150 armarx::arondto::PackagePath packagePath;
151 toAron(packagePath, imagePath);
153 armarx::human::arondto::FaceImage faceImage;
154 faceImage.filepath = packagePath;
155 faceImage.image = image;
156 toAron(profile.faceImages.emplace_back(), faceImage);
165 namespace fs = std::filesystem;
168 if (!fs::is_regular_file(
profileJson().toSystemPath()))
172 ARMARX_WARNING <<
"Expected simox object file for object " << *
this <<
": "
186 return os << rhs.
id();
static std::filesystem::path toSystemPath(const data::PackagePath &pp)
Accessor for human profile files.
std::vector< PackagePath > faceImages(const std::vector< std::string > &extensions={".png", ".jpg"}) const
virtual bool checkPaths() const
Checks the existence of expected files.
std::string package() const
void setLogError(bool enabled)
std::optional< Person > loadProfile(const bool loadFaceImages=true) const
PackagePath file(const std::string &extension, const std::string &suffix="") const
std::filesystem::path path
PackagePath sub_directory(const std::string &suffix) const
armarx::human::arondto::Person Person
PackagePath faceImageDir() const
PackagePath profileJson() const
Info(const std::string &packageName, const path &absPackageDataDir, const path &relativePath, const std::string &id)
Info.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
#define ARMARX_VERBOSE
The logging level for verbose information.
void toAron(armarx::human::arondto::HumanPose &dto, const HumanPose &bo)
std::ostream & operator<<(std::ostream &os, const Info &rhs)