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

Merge branch 'bug/260/recording' into 'master'

Resolves #260 scene recording

Closes #260

See merge request nicolas.pope/ftl!189
parents f8b1df81 789d7cdf
No related branches found
No related tags found
1 merge request!189Resolves #260 scene recording
Pipeline #16899 passed
...@@ -284,21 +284,24 @@ static void run(ftl::Configurable *root) { ...@@ -284,21 +284,24 @@ static void run(ftl::Configurable *root) {
stream->add(vs); stream->add(vs);
// ---- Recording code ----------------------------------------------------- // ---- Recording code -----------------------------------------------------
/*
std::ofstream fileout; std::ofstream fileout;
ftl::codecs::Writer writer(fileout); ftl::codecs::Writer writer(fileout);
auto recorder = [&writer,&groups](ftl::rgbd::Source *src, const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) {
ftl::codecs::StreamPacket s = spkt;
// Patch stream ID to match order in group
s.streamID = groups[0]->streamID(src);
writer.write(s, pkt);
};
root->set("record", false); root->set("record", false);
// Add a recording callback to all reconstruction scenes
for (size_t i=0; i<sources.size(); ++i) {
sources[i]->addRawCallback([&writer,&groups,i](ftl::rgbd::Source *src, const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) {
ftl::codecs::StreamPacket s = spkt;
// Patch stream ID to match order in group
s.streamID = i;
writer.write(s, pkt);
});
}
// Allow stream recording // Allow stream recording
root->on("record", [&groups,&fileout,&writer,&recorder](const ftl::config::Event &e) { root->on("record", [&groups,&fileout,&writer,&sources](const ftl::config::Event &e) {
if (e.entity->value("record", false)) { if (e.entity->value("record", false)) {
char timestamp[18]; char timestamp[18];
std::time_t t=std::time(NULL); std::time_t t=std::time(NULL);
...@@ -306,24 +309,20 @@ static void run(ftl::Configurable *root) { ...@@ -306,24 +309,20 @@ static void run(ftl::Configurable *root) {
fileout.open(std::string(timestamp) + ".ftl"); fileout.open(std::string(timestamp) + ".ftl");
writer.begin(); writer.begin();
// TODO: Add to all grounds / reconstructions
groups[0]->addRawCallback(std::function(recorder));
// TODO: Write pose+calibration+config packets // TODO: Write pose+calibration+config packets
auto sources = groups[0]->sources();
for (size_t i=0; i<sources.size(); ++i) { for (size_t i=0; i<sources.size(); ++i) {
//writeSourceProperties(writer, i, sources[i]); //writeSourceProperties(writer, i, sources[i]);
sources[i]->inject(Channel::Calibration, sources[i]->parameters(), Channel::Left, sources[i]->getCapabilities()); sources[i]->inject(Channel::Calibration, sources[i]->parameters(), Channel::Left, sources[i]->getCapabilities());
sources[i]->inject(sources[i]->getPose()); sources[i]->inject(sources[i]->getPose());
} }
} else { } else {
// FIXME: Remove doesn't work, so multiple records fail.
groups[0]->removeRawCallback(recorder);
writer.end(); writer.end();
fileout.close(); fileout.close();
} }
}); });
*/
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
stream->setLatency(6); // FIXME: This depends on source!? stream->setLatency(6); // FIXME: This depends on source!?
......
...@@ -82,6 +82,10 @@ void Reconstruction::addSource(ftl::rgbd::Source *src) { ...@@ -82,6 +82,10 @@ void Reconstruction::addSource(ftl::rgbd::Source *src) {
group_->addSource(src); // TODO: check if source is already in group? group_->addSource(src); // TODO: check if source is already in group?
} }
void Reconstruction::addRawCallback(const std::function<void(ftl::rgbd::Source *src, const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt)> &cb) {
group_->addRawCallback(cb);
}
void Reconstruction::render(ftl::rgbd::VirtualSource *vs, ftl::rgbd::Frame &out) { void Reconstruction::render(ftl::rgbd::VirtualSource *vs, ftl::rgbd::Frame &out) {
// Create scene transform, intended for axis aligning the walls and floor // Create scene transform, intended for axis aligning the walls and floor
Eigen::Matrix4d transform; Eigen::Matrix4d transform;
......
...@@ -18,6 +18,8 @@ class Reconstruction : public ftl::Configurable { ...@@ -18,6 +18,8 @@ class Reconstruction : public ftl::Configurable {
void addSource(ftl::rgbd::Source *); void addSource(ftl::rgbd::Source *);
void addRawCallback(const std::function<void(ftl::rgbd::Source *src, const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt)> &cb);
/** /**
* Do the render for a specified virtual camera. * Do the render for a specified virtual camera.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment