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

Virtual stream to GUI works

parent aff0a5b3
Branches
Tags
1 merge request!23Feature/gui implements #53
......@@ -426,7 +426,7 @@ static void run() {
ftl::rgbd::Streamer stream(config, &net);
stream.add(virt);
stream.run();
//stream.run();
unsigned char frameCount = 0;
bool paused = false;
......@@ -472,7 +472,9 @@ static void run() {
frameCount++;
stream.poll();
display.update();
//sleep_for(milliseconds(10));
}
}
......
......@@ -123,7 +123,7 @@ void Display::update() {
source_->setPose(viewPose);
Mat rgb, depth;
source_->grab();
//source_->grab();
source_->getRGBD(rgb, depth);
if (rgb.rows > 0) cv::imshow(name_, rgb);
wait(1);
......
......@@ -51,6 +51,7 @@ class Streamer : public ftl::Configurable {
void run(bool block=false);
void stop();
void poll();
RGBDSource *get(const std::string &uri);
......
......@@ -113,11 +113,7 @@ void Streamer::stop() {
active_ = false;
}
void Streamer::run(bool block) {
active_ = true;
if (block) {
while (active_) {
void Streamer::poll() {
double wait = 1.0f / 25.0f;
auto start = std::chrono::high_resolution_clock::now();
// Create frame jobs at correct FPS interval
......@@ -128,19 +124,19 @@ void Streamer::run(bool block) {
sleep_for(milliseconds((long long)((wait - elapsed.count()) * 1000.0f)));
}
void Streamer::run(bool block) {
active_ = true;
if (block) {
while (active_) {
poll();
}
} else {
// Create thread job for frame ticking
pool_.push([this](int id) {
while (active_) {
double wait = 1.0f / 25.0f;
auto start = std::chrono::high_resolution_clock::now();
// Create frame jobs at correct FPS interval
_schedule();
std::chrono::duration<double> elapsed =
std::chrono::high_resolution_clock::now() - start;
sleep_for(milliseconds((long long)((wait - elapsed.count()) * 1000.0f)));
poll();
}
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment