Skip to content
Snippets Groups Projects
Commit 986df882 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Store virtual camera pose in FTL recording

parent 44750fc1
No related branches found
No related tags found
No related merge requests found
......@@ -82,7 +82,7 @@ class Camera {
inline int64_t getFrameTimeMS() const { return int64_t(delta_ * 1000.0f); }
const ftl::rgbd::Camera &getIntrinsics() const { return state_.getLeft(); }
const Eigen::Matrix4d &getPose() const { return state_.getPose(); }
const Eigen::Matrix4d getPose() const { UNIQUE_LOCK(mutex_, lk); return state_.getPose(); }
/**
* @internal. Used to inform the camera if it is the active camera or not.
......@@ -183,7 +183,7 @@ class Camera {
std::array<Eigen::Matrix4d,ftl::stream::kMaxStreams> transforms_; // Frameset transforms for virtual cam
Eigen::Matrix4d T_ = Eigen::Matrix4d::Identity();
MUTEX mutex_;
mutable MUTEX mutex_;
#ifdef HAVE_OPENVR
vr::TrackedDevicePose_t rTrackedDevicePose_[ vr::k_unMaxTrackedDeviceCount ];
......
......@@ -6,6 +6,8 @@
#include "frameset_mgr.hpp"
#include <ftl/profiler.hpp>
#include <ftl/codecs/shapes.hpp>
#include <ftl/utility/vectorbuffer.hpp>
#include <nanogui/imageview.h>
#include <nanogui/textbox.h>
......@@ -112,7 +114,36 @@ SourceWindow::SourceWindow(ftl::gui::Screen *screen)
interceptor_->onIntercept([this] (const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) {
//LOG(INFO) << (std::string)spkt;
if (recorder_->active() && pkt.data.size() > 0) recorder_->post(spkt, pkt);
if (recorder_->active() && pkt.data.size() > 0) {
if (spkt.channel == Channel::Shapes3D && spkt.frame_number == 255) {
// Decode the shapes channel to insert the virtual camera...
std::vector<ftl::codecs::Shape3D> shapes;
auto unpacked = msgpack::unpack((const char*)pkt.data.data(), pkt.data.size());
unpacked.get().convert(shapes);
auto *cam = screen_->activeCamera();
if (cam) {
// Modify shapes
auto &s = shapes.emplace_back();
s.id = shapes.size();
s.label = std::string("virtual-")+std::to_string(shapes.size());
s.type = ftl::codecs::Shape3DType::CAMERA;
s.pose = cam->getPose().cast<float>();
//LOG(INFO) << "Inject virtual : " << shapes.size();
}
auto npkt = pkt;
npkt.data.resize(0);
ftl::util::FTLVectorBuffer buf(npkt.data);
msgpack::pack(buf, shapes);
recorder_->post(spkt, npkt);
} else {
recorder_->post(spkt, pkt);
}
}
});
paused_ = false;
......
......@@ -27,7 +27,7 @@ bool Poser::apply(ftl::rgbd::FrameSet &in, ftl::rgbd::FrameSet &out, cudaStream_
//LOG(INFO) << "Found shapes 3D global: " << (int)transforms.size();
//for (auto &t : transforms) {
//LOG(INFO) << "Have FS transform: " << t.id;
// LOG(INFO) << "Have FS transform: " << t.label;
//}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment