Skip to content
Snippets Groups Projects
Commit bf11b504 authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

save poses to file in init()

parent 8a445122
No related branches found
No related tags found
1 merge request!336WIP: save/load poses from file
Pipeline #29216 passed
......@@ -35,6 +35,14 @@ void Camera::init() {
overlay_ = std::unique_ptr<ftl::overlay::Overlay>
(ftl::create<ftl::overlay::Overlay>(this, "overlay"));
try {
ftl::file::unpack(file::config_dir() / "poses.bin", poses_);
LOG(INFO) << "Poses loaded from file (" << poses_.size() << " items)";
}
catch (msgpack::insufficient_bytes&) {
LOG(INFO) << "No poses loaded from file";
}
}
void Camera::update(double delta) {
......@@ -660,13 +668,14 @@ void Camera::resetOrigin() {
void Camera::saveCursorToPoser() {
ftl::codecs::Shape3D shape;
shape.type = ftl::codecs::Shape3DType::CURSOR;
shape.id = cursor_save_id_++;
shape.id = poses_.size();
shape.label = std::string("Cursor") + std::to_string(shape.id);
shape.pose = cursor().inverse().cast<float>();
shape.size = Eigen::Vector3f(0.1f,0.1f,0.1f);
auto k = (*(io->feed()->getFrameSet(frame_id_.frameset())))[frame_id_.source()].name();
poses_[k].push_back(shape);
poses_.push_back(shape);
ftl::file::pack(ftl::file::config_dir() / "poses.bin", poses_);
ftl::operators::Poser::add(shape, frame_id_);
}
......@@ -700,18 +709,3 @@ void Camera::transformActivePose(const Eigen::Matrix4d &pose) {
void Camera::setActivePose(const Eigen::Matrix4d &pose) {
cursor_ = pose; //.inverse();
}
void Camera::posesToFile(const std::string& path) {
ftl::file::pack(path, poses_);
}
void Camera::posesFromFile(const std::string& path) {
ftl::file::unpack(path, poses_);
const auto name = (*(io->feed()->getFrameSet(frame_id_.frameset())))[frame_id_.source()].name();
for (const auto& [k, v] : poses_) {
if (k != name) { continue; }
for (const auto& shape : v) {
ftl::operators::Poser::add(shape, frame_id_);
}
}
}
\ No newline at end of file
......@@ -98,7 +98,7 @@ private:
ftl::data::FrameID frame_id_;
ftl::codecs::Channel channel_ = ftl::codecs::Channel::Colour;
ftl::stream::Feed::Filter *filter_ = nullptr;
std::atomic_bool paused_ = false; // TODO: implement in InputOutput
std::atomic_bool paused_ = false;
bool has_seen_frame_ = false;
ftl::codecs::Touch point_;
bool live_=false;
......@@ -112,7 +112,6 @@ private:
Eigen::Vector3f cursor_pos_;
Eigen::Vector3f cursor_target_;
Eigen::Vector3f cursor_normal_;
int cursor_save_id_=0;
Eigen::Matrix4d cursor_;
ftl::data::FrameSetPtr current_fs_;
......@@ -134,7 +133,10 @@ private:
void _updateCapabilities(ftl::data::Frame &frame);
Eigen::Matrix4d _cursor() const;
std::map<std::string, std::vector<ftl::codecs::Shape3D>> poses_;
std::vector<ftl::codecs::Shape3D> poses_;
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment